From ba6aefc5b082454eba94f80acf124f202b4555c5 Mon Sep 17 00:00:00 2001 From: alteredCoder Date: Fri, 15 Apr 2022 16:04:13 +0200 Subject: [PATCH] fix lapi option names --- cmd/crowdsec-cli/console.go | 34 +++++++++++++++++----------------- pkg/apiserver/apic.go | 2 +- pkg/csconfig/console.go | 14 +++++++------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cmd/crowdsec-cli/console.go b/cmd/crowdsec-cli/console.go index b3ffecdd4..eb86d6a4b 100644 --- a/cmd/crowdsec-cli/console.go +++ b/cmd/crowdsec-cli/console.go @@ -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) diff --git a/pkg/apiserver/apic.go b/pkg/apiserver/apic.go index 6ef7d6177..2f75c335a 100644 --- a/pkg/apiserver/apic.go +++ b/pkg/apiserver/apic.go @@ -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{} } } diff --git a/pkg/csconfig/console.go b/pkg/csconfig/console.go index 37bc1ac9a..c37bf815b 100644 --- a/pkg/csconfig/console.go +++ b/pkg/csconfig/console.go @@ -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)