Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions cmd/tls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ func osctrlService() {
muxTLS.HandleFunc("GET "+errorPath, handlersTLS.ErrorHandler)
// TLS: Specific routes for osquery nodes
// FIXME this forces all paths to be the same

muxTLS.Handle("POST /{env}/"+environments.DefaultEnrollPath, handlersTLS.PrometheusMiddleware(http.HandlerFunc(handlersTLS.EnrollHandler)))
muxTLS.Handle("POST /{env}/"+environments.DefaultConfigPath, handlersTLS.PrometheusMiddleware(http.HandlerFunc(handlersTLS.ConfigHandler)))
muxTLS.Handle("POST /{env}/"+environments.DefaultLogPath, handlersTLS.PrometheusMiddleware(http.HandlerFunc(handlersTLS.LogHandler)))
Expand All @@ -293,14 +292,19 @@ func osctrlService() {
muxTLS.HandleFunc("GET /{env}/{secretpath}/{script}", handlersTLS.QuickEnrollHandler)
// TLS: Download enrolling package
muxTLS.HandleFunc("GET /{env}/{secretpath}/package/{package}", handlersTLS.EnrollPackageHandler)
// TLS: osctrld retrieve flags
muxTLS.HandleFunc("POST /{env}/"+environments.DefaultFlagsPath, handlersTLS.FlagsHandler)
// TLS: osctrld retrieve certificate
muxTLS.HandleFunc("POST /{env}/"+environments.DefaultCertPath, handlersTLS.CertHandler)
// TLS: osctrld verification
muxTLS.HandleFunc("POST /{env}/"+environments.DefaultVerifyPath, handlersTLS.VerifyHandler)
// TLS: osctrld retrieve script to install/remove osquery
muxTLS.HandleFunc("POST /{env}/{action}/{platform}/"+environments.DefaultScriptPath, handlersTLS.ScriptHandler)

// Enable osctrld endpoints
if flagParams.OsctrldConfigValues.Enabled {
log.Info().Msg("Enabling osctrld endpoints")
// TLS: osctrld retrieve flags
muxTLS.HandleFunc("POST /{env}/"+environments.DefaultFlagsPath, handlersTLS.FlagsHandler)
// TLS: osctrld retrieve certificate
muxTLS.HandleFunc("POST /{env}/"+environments.DefaultCertPath, handlersTLS.CertHandler)
// TLS: osctrld verification
muxTLS.HandleFunc("POST /{env}/"+environments.DefaultVerifyPath, handlersTLS.VerifyHandler)
// TLS: osctrld retrieve script to install/remove osquery
muxTLS.HandleFunc("POST /{env}/{action}/{platform}/"+environments.DefaultScriptPath, handlersTLS.ScriptHandler)
}

// ////////////////////////////// Everything is ready at this point!
serviceListener := flagParams.ConfigValues.Listener + ":" + flagParams.ConfigValues.Port
Expand Down
17 changes: 17 additions & 0 deletions pkg/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ type ServiceFlagParams struct {
// Debug HTTP configuration values
DebugHTTPValues DebugHTTPConfiguration

// osctrld configuration values
OsctrldConfigValues OsctrldConfiguration

// Service configuration values
ConfigValues JSONConfigurationService
// DB writer configuration values
Expand Down Expand Up @@ -129,6 +132,7 @@ func InitTLSFlags(params *ServiceFlagParams) []cli.Flag {
allFlags = append(allFlags, initRedisFlags(params)...)
allFlags = append(allFlags, initDBFlags(params)...)
allFlags = append(allFlags, initTLSSecurityFlags(params)...)
allFlags = append(allFlags, initOsctrldFlags(params)...)
allFlags = append(allFlags, initCarverFlags(params, ServiceTLS)...)
allFlags = append(allFlags, initS3LoggingFlags(params)...)
allFlags = append(allFlags, initKafkaFlags(params)...)
Expand Down Expand Up @@ -788,3 +792,16 @@ func initDebugFlags(params *ServiceFlagParams, service string) []cli.Flag {
},
}
}

// initOsctrldFlags initializes all the flags needed for the osctrld service
func initOsctrldFlags(params *ServiceFlagParams) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "enable-osctrld",
Value: false,
Usage: "Enable osctrld endpoints.",
EnvVars: []string{"OSCTRLD"},
Destination: &params.OsctrldConfigValues.Enabled,
},
}
}
5 changes: 5 additions & 0 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,8 @@ type DebugHTTPConfiguration struct {
File string `json:"file"`
ShowBody bool `json:"showBody"`
}

// OsctrldConfiguration to hold osctrld configuration values
type OsctrldConfiguration struct {
Enabled bool `json:"enabled"`
}
Loading