fix lapi option names
This commit is contained in:
parent
7f42f94fe3
commit
ba6aefc5b0
3 changed files with 25 additions and 25 deletions
|
@ -222,12 +222,12 @@ Disable given information push to the central API.`,
|
|||
activated = string(emoji.CheckMarkButton)
|
||||
}
|
||||
table.Append([]string{option, activated, "Send alerts from tainted scenarios to the console"})
|
||||
case csconfig.SEND_LABEL:
|
||||
case csconfig.SEND_CONTEXT:
|
||||
activated := string(emoji.CrossMark)
|
||||
if *csConfig.API.Server.ConsoleConfig.ShareLabel {
|
||||
if *csConfig.API.Server.ConsoleConfig.ShareContext {
|
||||
activated = string(emoji.CheckMarkButton)
|
||||
}
|
||||
table.Append([]string{option, activated, "Send label with alerts to the console"})
|
||||
table.Append([]string{option, activated, "Send context with alerts to the console"})
|
||||
}
|
||||
}
|
||||
table.Render()
|
||||
|
@ -248,7 +248,7 @@ Disable given information push to the central API.`,
|
|||
{"share_manual_decisions", fmt.Sprintf("%t", *csConfig.API.Server.ConsoleConfig.ShareManualDecisions)},
|
||||
{"share_custom", fmt.Sprintf("%t", *csConfig.API.Server.ConsoleConfig.ShareCustomScenarios)},
|
||||
{"share_tainted", fmt.Sprintf("%t", *csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios)},
|
||||
{"share_labels", fmt.Sprintf("%t", *csConfig.API.Server.ConsoleConfig.ShareLabel)},
|
||||
{"share_context", fmt.Sprintf("%t", *csConfig.API.Server.ConsoleConfig.ShareContext)},
|
||||
}
|
||||
for _, row := range rows {
|
||||
err = csvwriter.Write(row)
|
||||
|
@ -309,7 +309,7 @@ Disable given information push to the central API.`,
|
|||
Run: func(cmd *cobra.Command, args []string) {
|
||||
dump, err := yaml.Marshal(csConfig.Crowdsec.ContextToSend)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to show labels status: %s", err)
|
||||
log.Fatalf("unable to show context status: %s", err)
|
||||
}
|
||||
fmt.Println(string(dump))
|
||||
|
||||
|
@ -404,7 +404,7 @@ Disable given information push to the central API.`,
|
|||
var valuesToDelete []string
|
||||
cmdContextDelete := &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "List label to send with alerts",
|
||||
Short: "Delete context to send with alerts",
|
||||
DisableAutoGenTag: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(keysToDelete) == 0 && len(valuesToDelete) == 0 {
|
||||
|
@ -422,10 +422,10 @@ Disable given information push to the central API.`,
|
|||
|
||||
for _, value := range valuesToDelete {
|
||||
valueFound := false
|
||||
for key, labels := range csConfig.Crowdsec.ContextToSend {
|
||||
if inSlice(value, labels) {
|
||||
for key, context := range csConfig.Crowdsec.ContextToSend {
|
||||
if inSlice(value, context) {
|
||||
valueFound = true
|
||||
csConfig.Crowdsec.ContextToSend[key] = removeFromSlice(value, labels)
|
||||
csConfig.Crowdsec.ContextToSend[key] = removeFromSlice(value, context)
|
||||
log.Infof("value '%s' has been removed from key '%s'", value, key)
|
||||
}
|
||||
if len(csConfig.Crowdsec.ContextToSend[key]) == 0 {
|
||||
|
@ -494,18 +494,18 @@ func SetConsoleOpts(args []string, wanted bool) {
|
|||
log.Infof("%s set to %t", csconfig.SEND_MANUAL_SCENARIOS, wanted)
|
||||
csConfig.API.Server.ConsoleConfig.ShareManualDecisions = types.BoolPtr(wanted)
|
||||
}
|
||||
case csconfig.SEND_LABEL:
|
||||
case csconfig.SEND_CONTEXT:
|
||||
/*for each flag check if it's already set before setting it*/
|
||||
if csConfig.API.Server.ConsoleConfig.ShareLabel != nil {
|
||||
if *csConfig.API.Server.ConsoleConfig.ShareLabel == wanted {
|
||||
log.Infof("%s already set to %t", csconfig.SEND_LABEL, wanted)
|
||||
if csConfig.API.Server.ConsoleConfig.ShareContext != nil {
|
||||
if *csConfig.API.Server.ConsoleConfig.ShareContext == wanted {
|
||||
log.Infof("%s already set to %t", csconfig.SEND_CONTEXT, wanted)
|
||||
} else {
|
||||
log.Infof("%s set to %t", csconfig.SEND_LABEL, wanted)
|
||||
*csConfig.API.Server.ConsoleConfig.ShareLabel = wanted
|
||||
log.Infof("%s set to %t", csconfig.SEND_CONTEXT, wanted)
|
||||
*csConfig.API.Server.ConsoleConfig.ShareContext = wanted
|
||||
}
|
||||
} else {
|
||||
log.Infof("%s set to %t", csconfig.SEND_LABEL, wanted)
|
||||
csConfig.API.Server.ConsoleConfig.ShareLabel = types.BoolPtr(wanted)
|
||||
log.Infof("%s set to %t", csconfig.SEND_CONTEXT, wanted)
|
||||
csConfig.API.Server.ConsoleConfig.ShareContext = types.BoolPtr(wanted)
|
||||
}
|
||||
default:
|
||||
log.Fatalf("unknown flag %s", arg)
|
||||
|
|
|
@ -159,7 +159,7 @@ func (a *apic) Push() error {
|
|||
if ok := shouldShareAlert(alert, a.consoleConfig); ok {
|
||||
signals = append(signals, alertToSignal(alert, getScenarioTrustOfAlert(alert)))
|
||||
}
|
||||
if !*a.consoleConfig.ShareLabel {
|
||||
if !*a.consoleConfig.ShareContext {
|
||||
alert.Meta = models.Meta{}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ const (
|
|||
SEND_CUSTOM_SCENARIOS = "custom"
|
||||
SEND_TAINTED_SCENARIOS = "tainted"
|
||||
SEND_MANUAL_SCENARIOS = "manual"
|
||||
SEND_LABEL = "label"
|
||||
SEND_CONTEXT = "context"
|
||||
)
|
||||
|
||||
var CONSOLE_CONFIGS = []string{SEND_CUSTOM_SCENARIOS, SEND_MANUAL_SCENARIOS, SEND_TAINTED_SCENARIOS, SEND_LABEL}
|
||||
var CONSOLE_CONFIGS = []string{SEND_CUSTOM_SCENARIOS, SEND_MANUAL_SCENARIOS, SEND_TAINTED_SCENARIOS, SEND_CONTEXT}
|
||||
|
||||
var DefaultConsoleConfigFilePath = DefaultConfigPath("console.yaml")
|
||||
|
||||
|
@ -26,7 +26,7 @@ type ConsoleConfig struct {
|
|||
ShareManualDecisions *bool `yaml:"share_manual_decisions"`
|
||||
ShareTaintedScenarios *bool `yaml:"share_tainted"`
|
||||
ShareCustomScenarios *bool `yaml:"share_custom"`
|
||||
ShareLabel *bool `yaml:"share_labels"`
|
||||
ShareContext *bool `yaml:"share_context"`
|
||||
}
|
||||
|
||||
func (c *LocalApiServerCfg) LoadConsoleConfig() error {
|
||||
|
@ -36,7 +36,7 @@ func (c *LocalApiServerCfg) LoadConsoleConfig() error {
|
|||
c.ConsoleConfig.ShareCustomScenarios = types.BoolPtr(true)
|
||||
c.ConsoleConfig.ShareTaintedScenarios = types.BoolPtr(true)
|
||||
c.ConsoleConfig.ShareManualDecisions = types.BoolPtr(false)
|
||||
c.ConsoleConfig.ShareLabel = types.BoolPtr(false)
|
||||
c.ConsoleConfig.ShareContext = types.BoolPtr(false)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,9 @@ func (c *LocalApiServerCfg) LoadConsoleConfig() error {
|
|||
c.ConsoleConfig.ShareManualDecisions = types.BoolPtr(false)
|
||||
}
|
||||
|
||||
if c.ConsoleConfig.ShareLabel == nil {
|
||||
log.Debugf("no 'label' found, setting to false")
|
||||
c.ConsoleConfig.ShareLabel = types.BoolPtr(false)
|
||||
if c.ConsoleConfig.ShareContext == nil {
|
||||
log.Debugf("no 'context' found, setting to false")
|
||||
c.ConsoleConfig.ShareContext = types.BoolPtr(false)
|
||||
}
|
||||
|
||||
log.Debugf("Console configuration '%s' loaded successfully", c.ConsoleConfigPath)
|
||||
|
|
Loading…
Reference in a new issue