Commit graph

528 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
206211ce53
lint: import statement order (#3085)
* lint: import statement order

* lint
2024-06-26 12:16:17 +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
550d422d23
lint revive(deep-exit): refactor cmd/crowdsec (#3063)
* lint revive(deep-exit): refactor cmd/crowdsec

* lint
2024-06-07 12:01:08 +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
fba4237fbd
lint: revive/useless-break (#3050) 2024-06-04 09:48:21 +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
89d02e9458
CI/lint: enable some "revive" rules (#3041)
argument-limit
Warns when a function receives more parameters than the maximum set by the rule's configuration.

bare-return
Warns on bare (a.k.a. naked) returns

context-as-argument
By convention, context.Context should be the first parameter of a function.

duplicated-imports
It is possible to unintentionally import the same package twice.

modifies-parameter
A function that modifies its parameters can be hard to understand. It can also be misleading if the arguments are passed by value by the caller.

redundant-import-alias
This rule warns on redundant import aliases.

unreachable-code
This rule spots and proposes to remove unreachable code.
2024-05-31 16:45:47 +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
45b403ecd7
fix nil deref w/ malformed cti config (#3028) 2024-05-24 14:37:46 +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
ecd82ecfbd
feat: File notification plugin (#2932)
* wip: basic impl of file notification no log rotate but might now do it 🤷

* wip: ticker to 2 seconds and lower some log levels

* wip: remove redundant logrus formatter

* wip: the plugin should not handle it own data queue since the plugin process may timeout, so instead have a function that uses said context and loop whilst locking the filewriter this may not be the best way 🤷, however, I dont want multiple notifications to attempt to reopen the file if it has been rotated outside of the plugin context

* wip: impl log rotation which checks on check append, however, this may cause some issues in slow systems as the mutex lock doesnt give up until the file is rotated, however, the plugin looks for context and will give up if the plugin broker decides its timeout and will retry once the plugin has pushed again

* wip: update yaml dep

* wip: me no english great

* wip: even if the file has been rotated outside our control we should still compute the file size

* wip: improve context handling with creating a custom io writer struct which checks the context before attempting to write

* wip: used return byte count instead of calling a conversion again

* wip: actually check the enabled flag on log rotate

* wip: changed my mind, we check when we check file size

* wip: use io copy instead for memory alloc

* fix: add notification file to deb/rpm build
2024-05-15 09:21:45 +01: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
Blesswin Samuel
14dc26b128
Add ability to configure channel, username, icon emoji/url in slack notification (#2975)
* Add ability to configure channel, username, icon emoji/url in slack cfg

* Update slack.yaml

---------

Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
Co-authored-by: Thibault "bui" Koechlin <orixxx@gmail.com>
2024-05-10 14:00:34 +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