Commit graph

534 commits

Author SHA1 Message Date
marco
89efed68b0 replace syscall with unix/windows packages where possible
from the 1.22 release notes:

The syscall package has been frozen since Go 1.4 and was marked as deprecated in Go 1.11 [...]
However, some non-deprecated functionality requires use of the syscall package [...]
To avoid unnecessary complaints[...] no longer marked as deprecated.
The package remains frozen to most new functionality, and new code remains encouraged
to use golang.org/x/sys/unix or golang.org/x/sys/windows where possible.
2024-08-22 09:38:48 +02:00
mmetc
429418ffc6
cscli refact: package 'cliexplain' (#3151) 2024-08-21 10:24:18 +02:00
mmetc
3d27e83bf5
pkg/cwhub: improve support for k8s config maps with custom items (#3154)
* pkg/cwhub: improve support for k8s config maps as custom items

 - allow links to links
 - ignore hidden ..data directories, but allow links to their content

* allow any number of subdirectories in /etc/crowdsec/{hubtype}

* item name as subdir/file.yaml

* improve func test

* lint
2024-08-20 17:36:07 +02:00
mmetc
08fdfc4fb0
cscli refact: package 'cliconsole' (#3149)
* cscli refact: package 'cliconsole'

* dry

* lint

* lint
2024-08-20 16:20:40 +02:00
mmetc
6b9b19b8c1
CI: use golangci-lint 1.60 (#3180)
* use golangci-lint 1.60

* lint (gosimple/S1009) -> len(nil) == 0

* nerf govet for now
2024-08-19 14:09:17 +02:00
mmetc
48e3f51954
cscli: add option --ignore-missing to "bouncers delete", "machines delete" (#3177)
* cscli: add option --ignore-missing to "bouncers delete", "machines delete"

* lint
2024-08-13 16:49:27 +02:00
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