MCPcopy Index your code
hub / github.com/crowdsecurity/crowdsec / Status

Method Status

cmd/crowdsec-cli/clicapi/capi.go:216–264  ·  view source on GitHub ↗
(ctx context.Context, db *database.Client, out io.Writer, hub *cwhub.Hub)

Source from the content-addressed store, hash-verified

214}
215
216func (cli *cliCapi) Status(ctx context.Context, db *database.Client, out io.Writer, hub *cwhub.Hub) error {
217 cfg := cli.cfg()
218
219 if err := require.CAPIRegistered(cfg); err != nil {
220 return err
221 }
222
223 cred := cfg.API.Server.OnlineClient.Credentials
224
225 fmt.Fprintf(out, "Loaded credentials from %s\n", cfg.API.Server.OnlineClient.CredentialsFilePath)
226 fmt.Fprintf(out, "Trying to authenticate with username %s on %s\n", cred.Login, cred.URL)
227
228 status, err := queryCAPIStatus(ctx, db, hub, cred.URL, cred.Login, cred.Password)
229 if err != nil {
230 return fmt.Errorf("failed to authenticate to Central API (CAPI): %w", err)
231 }
232
233 if status.authenticated {
234 fmt.Fprint(out, "You can successfully interact with Central API (CAPI)\n")
235 }
236
237 if status.enrolled {
238 fmt.Fprint(out, "Your instance is enrolled in the console\n")
239 fmt.Fprintf(out, "Subscription type: %s\n", status.subscriptionType)
240 }
241
242 switch *cfg.API.Server.OnlineClient.Sharing {
243 case true:
244 fmt.Fprint(out, "Sharing signals is enabled\n")
245 case false:
246 fmt.Fprint(out, "Sharing signals is disabled\n")
247 }
248
249 switch *cfg.API.Server.OnlineClient.PullConfig.Community {
250 case true:
251 fmt.Fprint(out, "Pulling community blocklist is enabled\n")
252 case false:
253 fmt.Fprint(out, "Pulling community blocklist is disabled\n")
254 }
255
256 switch *cfg.API.Server.OnlineClient.PullConfig.Blocklists {
257 case true:
258 fmt.Fprint(out, "Pulling blocklists from the console is enabled\n")
259 case false:
260 fmt.Fprint(out, "Pulling blocklists from the console is disabled\n")
261 }
262
263 return nil
264}
265
266func (cli *cliCapi) newStatusCmd() *cobra.Command {
267 cmd := &cobra.Command{

Callers 9

newStatusCmdMethod · 0.95
HeartBeatMethod · 0.45
CheckInAllowlistMethod · 0.45
UsageMetricsMethod · 0.45
CreateMachineMethod · 0.45
DeleteMachineMethod · 0.45
dumpLAPIStatusMethod · 0.45
dumpCAPIStatusMethod · 0.45
dumpPAPIStatusMethod · 0.45

Calls 3

CAPIRegisteredFunction · 0.92
queryCAPIStatusFunction · 0.85
cfgMethod · 0.80

Tested by

no test coverage detected