remove PAPI feature flag (#2601)
This commit is contained in:
parent
c707b72b03
commit
04f3dc09f9
|
@ -16,7 +16,6 @@ import (
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
|
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/fflag"
|
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/models"
|
"github.com/crowdsecurity/crowdsec/pkg/models"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||||
|
|
||||||
|
@ -98,9 +97,6 @@ func NewCapiRegisterCmd() *cobra.Command {
|
||||||
Password: password.String(),
|
Password: password.String(),
|
||||||
URL: types.CAPIBaseURL,
|
URL: types.CAPIBaseURL,
|
||||||
}
|
}
|
||||||
if fflag.PapiClient.IsEnabled() {
|
|
||||||
apiCfg.PapiURL = types.PAPIBaseURL
|
|
||||||
}
|
|
||||||
apiConfigDump, err := yaml.Marshal(apiCfg)
|
apiConfigDump, err := yaml.Marshal(apiCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to marshal api credentials: %w", err)
|
return fmt.Errorf("unable to marshal api credentials: %w", err)
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
|
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/fflag"
|
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||||
|
|
||||||
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
|
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
|
||||||
|
@ -252,9 +251,6 @@ func SetConsoleOpts(args []string, wanted bool) error {
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
switch arg {
|
switch arg {
|
||||||
case csconfig.CONSOLE_MANAGEMENT:
|
case csconfig.CONSOLE_MANAGEMENT:
|
||||||
if !fflag.PapiClient.IsEnabled() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
/*for each flag check if it's already set before setting it*/
|
/*for each flag check if it's already set before setting it*/
|
||||||
if csConfig.API.Server.ConsoleConfig.ConsoleManagement != nil {
|
if csConfig.API.Server.ConsoleConfig.ConsoleManagement != nil {
|
||||||
if *csConfig.API.Server.ConsoleConfig.ConsoleManagement == wanted {
|
if *csConfig.API.Server.ConsoleConfig.ConsoleManagement == wanted {
|
||||||
|
|
|
@ -242,7 +242,7 @@ It is meant to allow you to manage bans, parsers/scenarios/etc, api and generall
|
||||||
rootCmd.AddCommand(NewHubTestCmd())
|
rootCmd.AddCommand(NewHubTestCmd())
|
||||||
rootCmd.AddCommand(NewCLINotifications().NewCommand())
|
rootCmd.AddCommand(NewCLINotifications().NewCommand())
|
||||||
rootCmd.AddCommand(NewCLISupport().NewCommand())
|
rootCmd.AddCommand(NewCLISupport().NewCommand())
|
||||||
|
rootCmd.AddCommand(NewCLIPapi().NewCommand())
|
||||||
rootCmd.AddCommand(NewCollectionCLI().NewCommand())
|
rootCmd.AddCommand(NewCollectionCLI().NewCommand())
|
||||||
rootCmd.AddCommand(NewParserCLI().NewCommand())
|
rootCmd.AddCommand(NewParserCLI().NewCommand())
|
||||||
rootCmd.AddCommand(NewScenarioCLI().NewCommand())
|
rootCmd.AddCommand(NewScenarioCLI().NewCommand())
|
||||||
|
|
|
@ -29,7 +29,6 @@ import (
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/csplugin"
|
"github.com/crowdsecurity/crowdsec/pkg/csplugin"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/database"
|
"github.com/crowdsecurity/crowdsec/pkg/database"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/fflag"
|
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -220,7 +219,6 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
|
||||||
log.Infof("CAPI manager configured successfully")
|
log.Infof("CAPI manager configured successfully")
|
||||||
isMachineEnrolled = isEnrolled(apiClient.apiClient)
|
isMachineEnrolled = isEnrolled(apiClient.apiClient)
|
||||||
controller.AlertsAddChan = apiClient.AlertsAddChan
|
controller.AlertsAddChan = apiClient.AlertsAddChan
|
||||||
if fflag.PapiClient.IsEnabled() {
|
|
||||||
if isMachineEnrolled {
|
if isMachineEnrolled {
|
||||||
log.Infof("Machine is enrolled in the console, Loading PAPI Client")
|
log.Infof("Machine is enrolled in the console, Loading PAPI Client")
|
||||||
papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel)
|
papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel)
|
||||||
|
@ -231,7 +229,6 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("Machine is not enrolled in the console, can't synchronize with the console")
|
log.Errorf("Machine is not enrolled in the console, can't synchronize with the console")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
apiClient = nil
|
apiClient = nil
|
||||||
controller.AlertsAddChan = nil
|
controller.AlertsAddChan = nil
|
||||||
|
@ -357,7 +354,6 @@ func (s *APIServer) Run(apiReady chan bool) error {
|
||||||
|
|
||||||
//csConfig.API.Server.ConsoleConfig.ShareCustomScenarios
|
//csConfig.API.Server.ConsoleConfig.ShareCustomScenarios
|
||||||
if s.isEnrolled {
|
if s.isEnrolled {
|
||||||
if fflag.PapiClient.IsEnabled() {
|
|
||||||
if s.consoleConfig.ConsoleManagement != nil && *s.consoleConfig.ConsoleManagement {
|
if s.consoleConfig.ConsoleManagement != nil && *s.consoleConfig.ConsoleManagement {
|
||||||
if s.papi.URL != "" {
|
if s.papi.URL != "" {
|
||||||
log.Infof("Starting PAPI decision receiver")
|
log.Infof("Starting PAPI decision receiver")
|
||||||
|
@ -383,7 +379,6 @@ func (s *APIServer) Run(apiReady chan bool) error {
|
||||||
log.Warningf("Machine is not allowed to synchronize decisions, you can enable it with `cscli console enable console_management`")
|
log.Warningf("Machine is not allowed to synchronize decisions, you can enable it with `cscli console enable console_management`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s.apic.metricsTomb.Go(func() error {
|
s.apic.metricsTomb.Go(func() error {
|
||||||
s.apic.SendMetrics(make(chan bool))
|
s.apic.SendMetrics(make(chan bool))
|
||||||
|
|
|
@ -8,8 +8,6 @@ import (
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/crowdsecurity/go-cs-lib/ptr"
|
"github.com/crowdsecurity/go-cs-lib/ptr"
|
||||||
|
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/fflag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -66,9 +64,7 @@ func (c *LocalApiServerCfg) LoadConsoleConfig() error {
|
||||||
c.ConsoleConfig.ShareManualDecisions = ptr.Of(false)
|
c.ConsoleConfig.ShareManualDecisions = ptr.Of(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fflag.PapiClient.IsEnabled() {
|
if c.ConsoleConfig.ConsoleManagement == nil {
|
||||||
c.ConsoleConfig.ConsoleManagement = ptr.Of(false)
|
|
||||||
} else if c.ConsoleConfig.ConsoleManagement == nil {
|
|
||||||
log.Debugf("no console_management found, setting to false")
|
log.Debugf("no console_management found, setting to false")
|
||||||
c.ConsoleConfig.ConsoleManagement = ptr.Of(false)
|
c.ConsoleConfig.ConsoleManagement = ptr.Of(false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ var Crowdsec = FeatureRegister{EnvPrefix: "CROWDSEC_FEATURE_"}
|
||||||
var CscliSetup = &Feature{Name: "cscli_setup", Description: "Enable cscli setup command (service detection)"}
|
var CscliSetup = &Feature{Name: "cscli_setup", Description: "Enable cscli setup command (service detection)"}
|
||||||
var DisableHttpRetryBackoff = &Feature{Name: "disable_http_retry_backoff", Description: "Disable http retry backoff"}
|
var DisableHttpRetryBackoff = &Feature{Name: "disable_http_retry_backoff", Description: "Disable http retry backoff"}
|
||||||
var ChunkedDecisionsStream = &Feature{Name: "chunked_decisions_stream", Description: "Enable chunked decisions stream"}
|
var ChunkedDecisionsStream = &Feature{Name: "chunked_decisions_stream", Description: "Enable chunked decisions stream"}
|
||||||
var PapiClient = &Feature{Name: "papi_client", Description: "Enable Polling API client"}
|
var PapiClient = &Feature{Name: "papi_client", Description: "Enable Polling API client", State: RetiredState}
|
||||||
var Re2GrokSupport = &Feature{Name: "re2_grok_support", Description: "Enable RE2 support for GROK patterns"}
|
var Re2GrokSupport = &Feature{Name: "re2_grok_support", Description: "Enable RE2 support for GROK patterns"}
|
||||||
var Re2RegexpInfileSupport = &Feature{Name: "re2_regexp_in_file_support", Description: "Enable RE2 support for RegexpInFile expr helper"}
|
var Re2RegexpInfileSupport = &Feature{Name: "re2_regexp_in_file_support", Description: "Enable RE2 support for RegexpInFile expr helper"}
|
||||||
|
|
||||||
|
|
|
@ -193,14 +193,17 @@ func (c *LongPollClient) PullOnce(since time.Time) ([]Event, error) {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
decoder := json.NewDecoder(resp.Body)
|
decoder := json.NewDecoder(resp.Body)
|
||||||
|
evts := []Event{}
|
||||||
|
for {
|
||||||
var pollResp pollResponse
|
var pollResp pollResponse
|
||||||
err = decoder.Decode(&pollResp)
|
err = decoder.Decode(&pollResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
c.logger.Debugf("server closed connection")
|
c.logger.Debugf("server closed connection")
|
||||||
return nil, nil
|
break
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("error decoding poll response: %v", err)
|
log.Errorf("error decoding poll response: %v", err)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Tracef("got response: %+v", pollResp)
|
c.logger.Tracef("got response: %+v", pollResp)
|
||||||
|
@ -208,11 +211,14 @@ func (c *LongPollClient) PullOnce(since time.Time) ([]Event, error) {
|
||||||
if len(pollResp.ErrorMessage) > 0 {
|
if len(pollResp.ErrorMessage) > 0 {
|
||||||
if pollResp.ErrorMessage == timeoutMessage {
|
if pollResp.ErrorMessage == timeoutMessage {
|
||||||
c.logger.Debugf("got timeout message")
|
c.logger.Debugf("got timeout message")
|
||||||
return nil, nil
|
break
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("longpoll API error message: %s", pollResp.ErrorMessage)
|
log.Errorf("longpoll API error message: %s", pollResp.ErrorMessage)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
return pollResp.Events, nil
|
evts = append(evts, pollResp.Events...)
|
||||||
|
}
|
||||||
|
return evts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLongPollClient(config LongPollClientConfig) (*LongPollClient, error) {
|
func NewLongPollClient(config LongPollClientConfig) (*LongPollClient, error) {
|
||||||
|
|
|
@ -72,9 +72,8 @@ setup() {
|
||||||
assert_stderr --partial "manual already set to true"
|
assert_stderr --partial "manual already set to true"
|
||||||
assert_stderr --partial "tainted already set to true"
|
assert_stderr --partial "tainted already set to true"
|
||||||
assert_stderr --partial "context already set to true"
|
assert_stderr --partial "context already set to true"
|
||||||
assert_stderr --partial "All features have been enabled successfully"
|
|
||||||
CROWDSEC_FEATURE_PAPI_CLIENT=true rune -0 cscli console enable --all --debug
|
|
||||||
assert_stderr --partial "console_management set to true"
|
assert_stderr --partial "console_management set to true"
|
||||||
|
assert_stderr --partial "All features have been enabled successfully"
|
||||||
rune -1 cscli console enable tralala
|
rune -1 cscli console enable tralala
|
||||||
assert_stderr --partial "unknown flag tralala"
|
assert_stderr --partial "unknown flag tralala"
|
||||||
}
|
}
|
||||||
|
@ -94,9 +93,8 @@ setup() {
|
||||||
assert_stderr --partial "manual already set to false"
|
assert_stderr --partial "manual already set to false"
|
||||||
assert_stderr --partial "tainted already set to false"
|
assert_stderr --partial "tainted already set to false"
|
||||||
assert_stderr --partial "context already set to false"
|
assert_stderr --partial "context already set to false"
|
||||||
assert_stderr --partial "All features have been disabled"
|
|
||||||
CROWDSEC_FEATURE_PAPI_CLIENT=true rune -0 cscli console disable --all --debug
|
|
||||||
assert_stderr --partial "console_management already set to false"
|
assert_stderr --partial "console_management already set to false"
|
||||||
|
assert_stderr --partial "All features have been disabled"
|
||||||
rune -1 cscli console disable tralala
|
rune -1 cscli console disable tralala
|
||||||
assert_stderr --partial "unknown flag tralala"
|
assert_stderr --partial "unknown flag tralala"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue