Commit graph

236 commits

Author SHA1 Message Date
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
7891268486
lapi: return specific error if a unix socket path is too long for the OS (#3593) 2025-04-29 12:42:49 +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
7396a103d0
refact: logrus.GetLevel() -> logrus.IsLevelEnabled() (#3579) 2025-04-17 17:35:09 +02:00
mmetc
49927f79a1
CI: golangci-lint v2 (#3558)
* golangci-lint v2

* CI: reduce parallel jobs for hubtests
2025-04-03 16:57:56 +02:00
blotus
d64f196b3f
Allowlists: fix range check in LAPI endpoint (#3538) 2025-03-25 14:30:18 +01:00
mmetc
c245b1e6f8
CI: enable linter "noctx" (#3528)
* CI: enable linter "noctx"

* rename NewRequestWithContext() -> PrepareRequest()
2025-03-24 15:16:40 +01:00
blotus
2641a6cc07
only warn about capi_whitelists_path being deprecated if actually in use (#3535) 2025-03-24 15:05:53 +01:00
blotus
50a5ef5345
deprecate capi_whitelists_path (#3504) 2025-03-12 10:12:30 +01:00
mmetc
a432a6352d
appsec: support custom CA for lapi (#3503)
* apisever, appsec: refact listenAndServe..()

* RemoveAll() -> Remove()

* configure CA for tls auth request

* ignore error from os.Remove(socket) when there's no file

* appsec functional test

* lint
2025-03-12 09:33:21 +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
a3187d6f2c
refact: context propagation (apiclient, cticlient...) (#3477) 2025-02-21 13:23:39 +01:00
mmetc
45624c6fe5
tests: switch context.Background() -> t.Context() from go 1.24 (#3473) 2025-02-21 00:09:11 +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
c4ff4228be
use go 1.24, enable unencrypted http2 (#3470) 2025-02-19 14:05:17 +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
blotus
303ce8e42c
gin: do not use gin context after returning response (#3398) 2025-01-10 16:00:24 +01: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
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
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
26c15a1267
refact pkg/database: clean up code and error messages (#3263)
* refact pkg/database: extract alertfilter.go
* refact pkg/database: extract function rollbackOnError(); dry error messages
2024-12-19 17:01:16 +01:00
mmetc
118275fd03
lint: enable more gocritic checks (#3363)
* lint: gocritic - avoid unnecessary byte->string conversions
* lint: gocritic - use %q instead of "%s"
* lint: return struct from DataSource constructor, not pointer (ptrToRefParam)
* lint: gocritic - check use of append()
2024-12-13 15:42:55 +01:00
mmetc
7a1ad8376a
lint: style, autofix (#3354) 2024-12-05 10:40:48 +01:00
mmetc
bbe7752967
update golangci-lint to 1.62 (#3332)
- ensure consistent pointer/value receivers
 - testify: json assertions with dedicated methods
2024-11-27 14:14:56 +01:00
blotus
fb733ee43a
Allow bouncers to share API keys (#3323) 2024-11-19 14:47:59 +01:00
blotus
c57dadce27
better handle error when sending usage metrics (#3333) 2024-11-18 11:21:30 +01:00
mmetc
a4497da6b9
context propagation: papi, loki (#3308)
* context propagation: AuthenticatedLAPIClient()

* context propagation: papi

* context propagation: loki
2024-11-15 15:31:10 +01:00
blotus
5d414f58e5
Add explicit configuration for signals sharing and blocklists pull (#3277) 2024-11-08 15:11:09 +01:00
mmetc
57521114bd
update checks for wrapped errors (#3117)
* errors.Is()
* extract function isBrokenConnection()
2024-11-04 11:21:48 +01:00
mmetc
96d4da76b9
remove unused code: HandleDeletedDecisions() (#3301) 2024-10-29 09:33:44 +01:00
Laurence Jones
d00a6a6873
enhance: Check if resp is nil in capi metrics and continue (#3299) 2024-10-25 10:31:08 +01:00
blotus
b2ac65bfb6
avoid deadlock when deleting decisions if PAPI is half configured (#3283) 2024-10-16 16:55:18 +02:00
mmetc
8ff58ee74e
context propagation: pkg/csplugin (#3273) 2024-10-10 17:18:59 +02:00
mmetc
b9bccfa56f
context propagation: pkg/apiserver (#3272)
* context propagation: apic.Push()

* context propagation: NewServer()

* lint
2024-10-09 13:06:03 +02:00
mmetc
06adbe031d
context propagation: apic, unit tests (#3271)
* context propagation: apic

* context propagation: unit tests
2024-10-03 14:51:53 +02:00
mmetc
af3116d1a7
context propagation: don't store ctx in api controller (#3268) 2024-10-03 11:06:39 +02:00
mmetc
27451a5ee6
context propagation: pass ctx to UpdateScenario() (#3258)
* context propagation: pass ctx to UpdateScenario()

* context propagation: SendMetrics, SendUsageMetrics, plugin config
2024-10-02 13:39:07 +02:00
mmetc
3945a991bd
context propagation: pkg/database/alerts (#3252)
* alerts
* drop CTX from dbclient
* lint
* pkg/database/alerts: context.TODO()
* cscli: context.Background() -> cmd.Context()
2024-09-24 14:13:45 +02:00
mmetc
1133afe58d
context propagation: pkg/database/{lock,decision} (#3251)
* context propagation: pkg/database/lock

* QueryAllDecisionsWithFilters(ctx...), QueryExpiredDecisionsWithFilters(ctx...)

* more Query...Decision...(ctx..)

* rest of decisions

* lint
2024-09-23 17:33:46 +02:00
mmetc
4a2a663227
context propagation: pkg/database/bouncers (#3249) 2024-09-20 20:45:21 +02:00
mmetc
fee3debdcc
context propagation: pkg/database/machines (#3248) 2024-09-20 16:00:58 +02:00
mmetc
29f3d2710d
context propagation: pkg/database/metrics (#3247) 2024-09-19 14:27:34 +02:00
mmetc
eeb28014c6
context propagation: pkg/database/config (#3246) 2024-09-19 14:09:35 +02:00
mmetc
b4a2403fdf
context propagation: bouncer list (#3236) 2024-09-19 11:14:33 +02:00
mmetc
2a60c99036
context propagation: pkg/database/flush (#3235) 2024-09-19 11:11:50 +02:00
mmetc
be391a3da8
context propagation: pass context to NewAPIC() (#3231) 2024-09-19 11:09:29 +02:00