Commit graph

628 commits

Author SHA1 Message Date
mmetc
31b914512a
refact pkg/database: unnecessary pointers (#3611)
* refact pkg/database: unnecessary pointers

* lint
2025-05-07 11:12:27 +02:00
mmetc
0e8b557402
refact alert, decision filters: remove unnecessary pointers (#3607) 2025-05-06 15:34:50 +02:00
blotus
959b872118
allowlists: automatically expire current matching decisions on update (#3601) 2025-05-06 14:10:30 +02:00
mmetc
f8f0b2a211
improve support for parsing time durations with 'day' units (#3599)
* custom duration type for "cscli decisions list", "cscli alerts list"
* custom duration type for "cscli allowlist add"
* custom duration type for "cscli machines prune"
* custom duration type for "cscli bouncers prune"
* replace old function ParseDuration
* use custom duration type in expr helpers
* update dependency
* lint
* test fix
* support days in 'metrics_max_age'
* DurationWithDays for 'max_age'
2025-05-05 15:12:29 +02:00
mmetc
201aebaac2
cscli inspect: don't show metrics or converted rules if an item is not installed (#3602) 2025-05-02 00:12:55 +02:00
mmetc
54571d1688
refact cscli: hub item - pointer receiver for consistency (#3595) 2025-05-01 23:04:42 +02:00
blotus
a79b92f280
make CTI client available in cscli notifications (#3591) 2025-04-28 18:13:53 +02:00
mmetc
5bc2b49387
allowlists: check during bulk decision import (#3588) 2025-04-28 17:11:17 +02:00
mmetc
418a27596e
lint/gocritic: enable importShadow, typeUnparen, unnecessaryDefer (#3583) 2025-04-24 11:12:38 +02:00
mmetc
d46cef1bcb
refact parser Init: argument types (#3578)
* refact parser Init: argument types
* lint
* tests
* rename struct field; drop redundant nil check
2025-04-23 21:30:03 +02:00
mmetc
faa5b482f6
lint/refactor: defer, reflectvaluecompare, stylecheck (#3544)
* lint: enable reflectvaluecompare
* lint: remove exception
* lint: stylecheck ST016 - methods on the same type should have the same receiver name
* lint: enable revive[time-equal]
2025-04-04 14:52:45 +02:00
mmetc
2dcc3ae0df
CI: pin hub branch during functional tests (#3526) 2025-03-20 11:28:37 +01:00
mmetc
0459a9a880
update appsec test runner (#3518) 2025-03-18 11:45:06 +01:00
mmetc
cab99643d1
Parallel hubtest (#3509)
Hubtests are now much faster and have a --max-jobs option which defaults to the number of cpu cores.
2025-03-17 11:27:09 +01:00
blotus
cce41a1e6c
do not attempt to set db log level if no db config (#3510) 2025-03-13 17:38:07 +01:00
Laurence Jones
bcce4afe5e
enhance: Flags now superceed all log levels (#3496)
* enhance: Flags now superceed all log levels

* enhance: remove global var for local scope

* test

---------

Co-authored-by: marco <marco@crowdsec.net>
2025-03-07 13:42:08 +00:00
mmetc
12a3c70860
lint: gocritic/httpNoBody (#3493)
* lint: gocritic/httpNoBody
2025-03-07 14:35:25 +01:00
mmetc
b12ade27f4
cscli: review/update argument number checking (#3490)
* cscsli: remove unused Command.Args setting

* cscli: review/update argument number checking

cscli will consistently print the help text if the number of arguments is
wrong for the command, but not for other types of errors.

* fix func tests

* lint
2025-03-04 12:21:27 +01:00
Thibault "bui" Koechlin
61c7de1331
enable/disable options for console enroll - make alert context a default (#3487)
* enable/disable options for console enroll - make alert context a default

* extract method and refact

---------

Co-authored-by: marco <marco@crowdsec.net>
2025-03-03 16:09:09 +01:00
mmetc
c161eb270b
pkg/cwhub: refact Item.State.(Downloaded | Installed) (#3476) 2025-02-25 10:09:29 +01:00
mmetc
2b70dbf3e5
cscli hub/items: always show action plan; fix --interactive in pipes (#3451) 2025-02-21 00:17:01 +01:00
blotus
16d0677938
Add support for centralized allowlists (#3355) 2025-02-19 15:04:47 +01:00
mmetc
8a10e2c61d
refact: avoid use of defer calls in loops (#3466)
* refact apic.Send()
* refact Papi.SendDeletedDecisions()
* refact MetricsProvider.Run()
* refact PluginBroker.pushNotificationsToPlugin()
* refact leakybucket.LoadBuckets()
2025-02-19 14:50:38 +01:00
mmetc
5136d928ed
lint: gocritic/typeDefFirst (ensure type definitions come before methods) (#3404)
* lint: gocritic/typeDefFirst (ensure type definitions come before methods)

* lint
2025-02-17 10:55:18 +01:00
mmetc
a9cc23e446
cscli: exclude removed commands from generated docs (#3449) 2025-02-07 10:52:14 +01:00
mmetc
a001e1d760
cscli: replace '--yes' option with '--interactive' (#3448) 2025-02-06 11:43:29 +01:00
mmetc
bfed861ba7
don't ask user to reload systemd service when running in docker (#3434)
* don't ask user to reload systemd service when running in docker

* refactor + give appropriate message if terminal is attached

* remove explicit filetype
2025-01-31 10:15:28 +00:00
Laurence Jones
5a37161df2
fix: use CreatedAt instead of StartAt (#3427)
* fix: use CreatedAt instead of StartAt

fix: #3321

* not a ptr
2025-01-27 12:05:26 +00:00
mmetc
4935dc536e
cscli hub: handle freebsd pre-release version numbers (#3423) 2025-01-23 09:29:29 +01:00
mmetc
bd7e1b50c3
cscli: cliconfig - remove global variables and gratuitous pointer (#3414) 2025-01-20 10:30:36 +01:00
mmetc
49fb24c3b1
lint: enable errcheck; add allowlist and explicit checks (#3403)
* lint: enable errcheck with explicit allow list
* add explicit error checks
* windows tests
* windows nolint
2025-01-16 16:13:10 +01:00
mmetc
fe931af5ca
lint: gocritic/captLocal (don't capitalize local variables) (#3402)
* lint: gocritic/captLocal (don't capitalize local variables)

* lint (whitespace)
2025-01-16 14:03:53 +01:00
mmetc
b582730d06
remove commands "cscli config backup/restore" (#3158)
* remove "cscli config backup/restore"
* remove backup/restore calls from deb,rpm pre/postinst and wizard
* remove from prerm too
2025-01-16 14:02:39 +01:00
Laurence Jones
cc1196c3ad
fix: #2790 (#3378) 2025-01-14 10:48:05 +00:00
mmetc
5df56844d9
log warning if local items have conflicting names (#3399) 2025-01-13 13:28:48 +01:00
Nathanael Demacon
e9c1ed05d9
feat(cscli): add env variable flag for dashboard setup (#3110)
Signed-off-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
Co-authored-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
Co-authored-by: Laurence Jones <laurence.jones@live.co.uk>
2025-01-13 09:17:18 +01:00
mmetc
866b0ad60c
Hubops tests (#3393) 2025-01-07 16:39:32 +01:00
mmetc
57d7247a43
cscli hub: refact/split files; add some doc/examples (#3394) 2025-01-06 23:55:39 +01:00
mmetc
5c7b957a34
cscli: restyle table titles; autocomplete "cscli metrics show" (#3391)
* cscli: restyle table titles; autocomplete "cscli metrics show"
* lint
2025-01-02 16:58:03 +01:00
Laurence Jones
f938b0c602
enhancement: Hubtest respect patterndir option set via config.yaml (#3386)
* enhancement: Hubtest respect patterndir option set via config.yaml

* pass patternDir to Run()

---------

Co-authored-by: marco <marco@crowdsec.net>
2025-01-02 14:21:03 +00:00
mmetc
4e6e6dec65
lint: explicit error checks (#3388)
* errcheck: tests
* fflag errcheck
* http_test errcheck (avoid duplicate metric registration)
2025-01-02 12:33:54 +01:00
mmetc
78f4b85311
pkg/cwhub - refact Downloader (#3382)
* pkg/cwhub - refact Downloader
* single method interfaces
* lint
2024-12-27 11:49:14 +01:00
mmetc
fc17c0c613
lint: replace type assertions and type switch on errors (#3376)
* errorlint: replace type assertions on errors
* errorlint: replace type switch on errors
* lint
2024-12-27 10:40:50 +01:00
mmetc
a1d26bdc5b
cscli: improved hub management (#3352) 2024-12-26 15:21:52 +01:00
victoredvardsson
466f39b880
Add possibility to configure log format #799 (#2941)
* make it possible to enable json log

* fix

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* Add error handling

* Add log_format to default config

* Fix syntax error in if statement

* Fix typo

* Fix typo

* Fix some typos and change naming from native to text, makes more sense

* Set same timestamp format for json logging

* Fix formatting

* Move in if statement under previous

* Fix some formatting that got messed up

* Default to text formatter, if log_format is not configured.

* defining logFormatter outside if statement so that log.SetFormatter(logFormatter) is not undefined when function is called

* Add variables that were undefined

* Argument were missing when calling SetDefaultLoggerConfig function

* Fix order of arguments passed

* Fix order of arguments passed

* Fix typo

* Implicit log_format = "text"

* functional test

* ignore log_format in FatalHook

* make it possible to enable json log

* fix

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* fix typo

* Add error handling

* Add log_format to default config

* Fix syntax error in if statement

* Fix typo

* Fix typo

* Fix some typos and change naming from native to text, makes more sense

* Set same timestamp format for json logging

* Fix formatting

* Move in if statement under previous

* Fix some formatting that got messed up

* Default to text formatter, if log_format is not configured.

* defining logFormatter outside if statement so that log.SetFormatter(logFormatter) is not undefined when function is called

* Add variables that were undefined

* Argument were missing when calling SetDefaultLoggerConfig function

* Fix order of arguments passed

* Fix order of arguments passed

* Fix typo

* Implicit log_format = "text"

* functional test

* ignore log_format in FatalHook

* lint

* fix func test

* lint

* remove < > characters from log

---------

Co-authored-by: Victor Edvardsson <victor.edvardsson@loopia.se>
Co-authored-by: marco <marco@crowdsec.net>
Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
2024-12-23 11:08:33 +01:00
mmetc
4748720a07
refactor pkg/leakybucket (#3371)
* refact pkg/leakybucket - call LoadBuckets with Item instances
* extract compileScopeFilter()
2024-12-20 14:33:24 +01:00
mmetc
b1e2b9523c
cscli: print errors in plain text with -o json (#2973) 2024-12-13 15:45:07 +01:00
mmetc
082c1dde71
lint/deep-exit: avoid log.Fatal (#3360)
* deep-exit: bubble up error from item_metrics.go
* deep-exit: bubble up error from password.go
2024-12-13 15:44:21 +01:00
blotus
d35d01fd9a
support dump: generate pprof files with debug=1 to avoid generating an unusable heap dump (#3361) 2024-12-11 17:57:07 +01:00
mmetc
dada07b2da
cscli: display expired decisions' expiration time in red (#3357)
* cscli decisions: display negative expiration times in red

* honor color flag
2024-12-11 14:02:22 +01:00