add simulated scenario flags
This commit is contained in:
parent
7af17baa8a
commit
64123b7249
2 changed files with 31 additions and 9 deletions
|
@ -119,6 +119,7 @@ Enable given information push to the central API. Allows to empower the console`
|
|||
csConfig.API.Server.ConsoleConfig.ShareDecisions = types.BoolPtr(true)
|
||||
csConfig.API.Server.ConsoleConfig.ShareManualDecisions = types.BoolPtr(true)
|
||||
csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = types.BoolPtr(true)
|
||||
csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = types.BoolPtr(true)
|
||||
|
||||
} else {
|
||||
SetConsoleOpts(args, true)
|
||||
|
@ -147,6 +148,7 @@ Disable given information push to the central API.`,
|
|||
csConfig.API.Server.ConsoleConfig.ShareDecisions = types.BoolPtr(false)
|
||||
csConfig.API.Server.ConsoleConfig.ShareManualDecisions = types.BoolPtr(false)
|
||||
csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = types.BoolPtr(false)
|
||||
csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = types.BoolPtr(false)
|
||||
|
||||
} else {
|
||||
SetConsoleOpts(args, false)
|
||||
|
@ -173,6 +175,8 @@ Disable given information push to the central API.`,
|
|||
fmt.Printf(" - Share tainted scenarios alerts : %t\n", *csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios)
|
||||
fmt.Printf(" - Share custom scenarios alerts : %t\n", *csConfig.API.Server.ConsoleConfig.ShareCustomScenarios)
|
||||
fmt.Printf(" - Share manual decisions alerts : %t\n", *csConfig.API.Server.ConsoleConfig.ShareManualDecisions)
|
||||
fmt.Printf(" - Share alerts in simulion mode : %t\n", *csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions)
|
||||
|
||||
case "json":
|
||||
data, err := json.MarshalIndent(csConfig.API.Server.ConsoleConfig, "", " ")
|
||||
if err != nil {
|
||||
|
@ -241,6 +245,17 @@ func SetConsoleOpts(args []string, wanted bool) {
|
|||
} else {
|
||||
csConfig.API.Server.ConsoleConfig.ShareDecisions = types.BoolPtr(wanted)
|
||||
}
|
||||
case csconfig.SEND_SIMULATED_DECISIONS:
|
||||
/*for each flag check if it's already set before setting it*/
|
||||
if csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions != nil {
|
||||
if *csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions == wanted {
|
||||
log.Infof("%s already set to %t", wanted)
|
||||
} else {
|
||||
*csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = wanted
|
||||
}
|
||||
} else {
|
||||
csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = types.BoolPtr(wanted)
|
||||
}
|
||||
default:
|
||||
log.Fatalf("unknown flag %s", arg)
|
||||
}
|
||||
|
|
|
@ -11,21 +11,23 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
SEND_CUSTOM_SCENARIOS = "custom"
|
||||
SEND_TAINTED_SCENARIOS = "tainted"
|
||||
SEND_MANUAL_SCENARIOS = "manual"
|
||||
SEND_LIVE_DECISIONS = "live_decisions"
|
||||
SEND_CUSTOM_SCENARIOS = "custom"
|
||||
SEND_TAINTED_SCENARIOS = "tainted"
|
||||
SEND_MANUAL_SCENARIOS = "manual"
|
||||
SEND_LIVE_DECISIONS = "live_decisions"
|
||||
SEND_SIMULATED_DECISIONS = "simulated_decisions"
|
||||
)
|
||||
|
||||
var DefaultConsoleConfgFilePath = "/etc/crowdsec/console_config.yaml"
|
||||
|
||||
var CONSOLE_CONFIGS = []string{SEND_CUSTOM_SCENARIOS, SEND_LIVE_DECISIONS, SEND_MANUAL_SCENARIOS, SEND_TAINTED_SCENARIOS}
|
||||
var CONSOLE_CONFIGS = []string{SEND_CUSTOM_SCENARIOS, SEND_LIVE_DECISIONS, SEND_MANUAL_SCENARIOS, SEND_TAINTED_SCENARIOS, SEND_SIMULATED_DECISIONS}
|
||||
|
||||
type ConsoleConfig struct {
|
||||
ShareManualDecisions *bool `yaml:"share_manual_decisions"`
|
||||
ShareTaintedScenarios *bool `yaml:"share_custom"`
|
||||
ShareCustomScenarios *bool `yaml:"share_tainted"`
|
||||
ShareDecisions *bool `yaml:"share_decisions"`
|
||||
ShareManualDecisions *bool `yaml:"share_manual_decisions"`
|
||||
ShareTaintedScenarios *bool `yaml:"share_custom"`
|
||||
ShareCustomScenarios *bool `yaml:"share_tainted"`
|
||||
ShareDecisions *bool `yaml:"share_decisions"`
|
||||
ShareSimulatedDecisions *bool `yaml:"share_simulated_decisions"`
|
||||
}
|
||||
|
||||
func (c *LocalApiServerCfg) LoadConsoleConfig() error {
|
||||
|
@ -36,6 +38,7 @@ func (c *LocalApiServerCfg) LoadConsoleConfig() error {
|
|||
c.ConsoleConfig.ShareTaintedScenarios = new(bool)
|
||||
c.ConsoleConfig.ShareManualDecisions = new(bool)
|
||||
c.ConsoleConfig.ShareDecisions = new(bool)
|
||||
c.ConsoleConfig.ShareSimulatedDecisions = new(bool)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -64,6 +67,10 @@ func (c *LocalApiServerCfg) LoadConsoleConfig() error {
|
|||
log.Debugf("no share_decisions scenarios found, setting to false")
|
||||
c.ConsoleConfig.ShareDecisions = new(bool)
|
||||
}
|
||||
if c.ConsoleConfig.ShareSimulatedDecisions == nil {
|
||||
log.Debugf("no share_simulated_decisions scenarios found, setting to false")
|
||||
c.ConsoleConfig.ShareSimulatedDecisions = new(bool)
|
||||
}
|
||||
log.Debugf("Console configuration '%s' loaded successfully", c.ConsoleConfigPath)
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue