Commit graph

439 commits

Author SHA1 Message Date
mmetc
1bc3b0870b
command "cscli doc --target /path/to/dir" (#3169)
* command "cscli doc --target /path/to/dir"

* typos and improved messages

* CI: remove obsolete parameters for golangi-lint action

* lint
2024-08-07 12:45:54 +02:00
Thibault "bui" Koechlin
6bd4096a3e
fix #1742 : Allow QueryCAPIStatus to return as well enrollment status (#3159)
* fix #1742 : Allow QueryCAPIStatus to return as well enrollment status

---------

Co-authored-by: marco <marco@crowdsec.net>
2024-08-05 12:04:07 +02:00
mmetc
136dba61d9
reduce log verbosity, minor CI fixes, lint (#3157)
* pkg/cwhub: redundant log messages

* CI: fixture output and elapsed time

* CI: preload only essential hub items

* report full version (including -rc2 etc.) with cscli hub update --debug

* lint
2024-08-01 10:55:04 +02:00
mmetc
6f5d75c5f1
cscli metrics: explicit message "no bouncer metrics found" (#3155) 2024-07-29 14:13:06 +02:00
mmetc
64e4ecde90
LAPI: detailed metrics endpoint (#2858) 2024-07-24 10:29:18 +02:00
blotus
a3d7900b5f
update expr (#3144) 2024-07-22 12:14:46 +02:00
mmetc
8d96ddd48e
refact cscli metrics: fix lines between tables, skip wrapper api (#3137)
* fix empty line between metrics tables

* refact metrics tables: use go-pretty api directly

* lint
2024-07-17 12:30:52 +02:00
blotus
c4bfdf1991
Store alert remediations status in DB (#3115) 2024-07-16 10:08:00 +02:00
mmetc
f130ce677d
command "cscli metrics show bouncers" (#3126)
* cscli metrics show bouncers

* db metrics: increase payload size

* func tests
2024-07-15 09:55:52 +02:00
mmetc
1b0104186a
cscli machines/bouncers: dry helper code and move to cscli (#3123) 2024-07-11 12:19:10 +02:00
mmetc
aab59b6287
typos (#3104)
* typos

* lint
2024-07-09 14:51:31 +02:00
mmetc
ea2098f6e6
refact cscli metrics: split stat types to own files (#3107) 2024-07-04 15:55:47 +02:00
mmetc
7cc33b5854
cscli refact: extract metrics to own package (#3106) 2024-07-04 14:43:35 +02:00
mmetc
90e3299373
cscli refact: extract table wrapper to own package (#3105)
* cscli refact: extract table wrapper to own package

* lint
2024-07-04 13:42:02 +02:00
mmetc
9cebcf96b4
command cscli [machines|bouncers] inspect (#3103)
* command cscli [machines|bouncers] inspect

* lint
2024-07-03 17:20:20 +02:00
mmetc
27935f6d4c
fix "cscli [machines|bouncers] delete" autocompletion (#3101)
* fix "cscli [machines|bouncers] delete" autocompletion

* func test
2024-07-01 16:35:34 +02:00
mmetc
4b988701ed
lint (intrange) (#2970) 2024-06-21 13:47:26 +02:00
mmetc
659774fd3d
refactor: prefer logrus.WithField over WithFields with a single param (#3087) 2024-06-20 10:38:23 +02:00
mmetc
4521a98ecc
db: don't set machine heartbeat until first connection (#3019)
* db: don't set machine heartbeat until first connection

* cscli machines prune: if hearbeat is not set, look at creation date

* lint
2024-06-17 10:39:50 +02:00
mmetc
44a2014f62
db: don't set bouncer last_pull until first connection (#3020)
* db: don't set bouncer last_pull until first connection

* cscli bouncers prune: query creation date if they never connected
2024-06-17 10:16:46 +02:00
mmetc
2f6d4cccd7
cscli: refactor hubtests / extract methods run(), coverage() (#3086) 2024-06-13 11:17:27 +02:00
mmetc
a529e66cd8
Typos (#3084)
* comment fix

* redundancy

* typo nill -> nil

* remove extra newline from log
2024-06-13 11:07:44 +02:00
mmetc
4e09ae2182
cscli: fixed some inconsistency in returning errors (#3076) 2024-06-12 13:06:44 +02:00
mmetc
fd433a7e73
cscli: refactor "cscli setup" to avoid global variable (#3075)
* cscli refactor: extract method cliSetup.detect()
* cscli refactor: extract method cliSetup.install()
* cscli refactor: extract method cliSetup.dataSources()
* cscli refactor: method ccliSetup.validate()
* skip redundant pre-loop checks
2024-06-12 11:07:10 +02:00
mmetc
bd4540b1bf
refactor context (cscli, pkg/database) (#3071)
* cscli: helper require.DBClient()

* refactor pkg/database: explicit context to dbclient constructor

* lint
2024-06-11 12:13:18 +02:00
Laurence Jones
24687e982a
enhancement: add deprecation notice to cscli dashboard prerun (#3079) 2024-06-11 09:34:37 +01:00
mmetc
c39c9cf8b7
cscli: fix deprecation message for "context delete" (#3078)
missing newline, proper return code, same msg as dashboard, test
2024-06-11 09:28:10 +02:00
mmetc
7fd01ae3fc
CI: update golangci-lint to 1.59; enforce canonical HTTP headers (#3074) 2024-06-10 16:13:49 +02:00
mmetc
dd6cf2b844
pkg/cwhub: use explicit context for item install, upgrade (#3067) 2024-06-07 17:32:52 +02:00
mmetc
cad760e605
pkg/cwhub: use explicit context for version check, index update (#3064)
* cscli refactor: explicit context for hub (version lookup)

* change order of version checks

* pkg/cwhub: split NewHub() + Update() + Load()

* cscli refactor: explicit context for hub (index update)

* updated pkg/cwhub docs

* lint
2024-06-07 16:56:02 +02:00
mmetc
7d75290a0f
Use cmp.Or from go 1.22 (#3058) 2024-06-06 14:53:30 +02:00
mmetc
114a966129
refactor "cscli decisions" (#3061)
* cscli decisions: extract method add()

* cscli decisions: extract method delete()

* cscli lapi: avoid apiclient global

* cscli capi: avoid apiclient global

* cscli decisions: error cleanup, avoid global for api client

* update test

* cscli alerts: extract method delete()

* lint
2024-06-06 10:21:03 +02:00
mmetc
9e859c0c8c
refactor pkg/database, pkg/models (#3022)
* pkg/models: Source.String()

* pkg/models: Alert.FormatAsStrings()

* cscli alerts list: sort remediation keys

avoid printing
"ban: ... captcha: ..."
in one line, and
"captcha: ... ban: ..."
in another

* remove unused methods; drop else branch

* lint
2024-06-05 12:01:13 +02:00
mmetc
73e03ef556
lint: enable revive/if-return, revive/error-strings (#3057)
* lint: enable revive/if-return, revive/error-strings

* lint
2024-06-05 11:37:57 +02:00
mmetc
9823ed61b6
cscli: log.Fatal -> return err (#3049)
* cscli: log.Fatal -> return err

* lint
2024-06-03 12:21:00 +02:00
mmetc
c1e858cbca
cscli: refactor alerts/console/decisions/setup (#3003)
* cscli alerts: extract list(), inspect()

* cscli console: extract enroll()

* cscli decisions: extract list()

* support dump: don't use global

* cscli setup: split command constructors

* lint
2024-05-31 19:15:05 +02:00
mmetc
7d6514c7cc
update user agent with version and platform information (#3035)
* update user agent with version and platform information

* remove unused import

* user agent: omit tag correctly if git is dirty
2024-05-30 09:45:43 +02:00
blotus
f3341c1382
Appsec: properly populate event (#2943) 2024-05-27 10:15:38 +02:00
mmetc
816608daf4
cscli: faster table rendering (#3027)
* cscli: use go-pretty for tables

* lint
2024-05-24 11:17:52 +02:00
mmetc
cc63729b2c
version: write to stdout, add missing newline (#3012)
* pkg/cwversion cleanup

 - add missing newline between version and codename
 - add more information to "support dump"
 - write "cscli version" and "crowdsec -version" to stdout, not stderr

* fix func test

* lint
2024-05-15 10:52:43 +02:00
mmetc
41ec90ae8c
make: remove unused targets (#2998) 2024-05-15 10:37:25 +02:00
Laurence Jones
11893b2915
[cscli] Add tab completion to notifications [test, inspect] (#2765)
* Add cscli notifications test ValidArgsFunction for tab completion

* Split function to reusable and pass to inspect since both rely on a valid plugin name, fix short/long of list command

* Short should be short

* Removed redundant prerune since Args with validate it for us

* Make english more english

* fix: bad merge now fixed

---------

Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
2024-05-14 14:55:08 +01:00
mmetc
0d9e000543
use go-cs-lib/downloader for data files, hub index, item YAML (#2926) 2024-05-07 13:44:17 +02:00
mmetc
11da728b51
cscli support: collect profiling data and logs (#2987)
* extract methods, avoid globals
* collect logs to file dump.log
* include pprof data
* include latest logs
2024-05-07 12:59:38 +02:00
mmetc
a2dcc0ef9a
cscli: remove global dbClient (#2985)
* cscli: remove global dbClient

* lint (whitespace, errors)
2024-05-06 12:33:54 +02:00
mmetc
659feec496
cscli: don't print timestamps (#2984)
* cscli: don't print timestamps

* lint (whitespace, errors)
2024-05-06 10:43:54 +02:00
mmetc
3788610aff
cscli: avoid global vars (#2977)
* cscli: avoid global usage

This is required to make it possible to split the package

* lint (fmt.Errorf)
2024-05-02 10:25:04 +02:00
Laurence Jones
05b54687b6
feat: support stdout in cscli support dump (#2939)
* feat: support stdout in cscli support dump

* fix: skip log.info if stdout

* fix: handle errors by returning to runE instead
2024-04-26 15:56:15 +01:00
mmetc
845d4542bb
cscli: use yaml.v3 (#2965)
* cscli: use yaml.v3

* lint
2024-04-25 14:41:02 +02:00
mmetc
0f942a95f1
pkg/cwhub - rename methods for clarity (#2961)
* pkg/cwhub - rename methods for clarity

* lint
2024-04-24 11:09:37 +02:00