Commit graph

82 commits

Author SHA1 Message Date
Manuel Sabban
e6b85b641c
feat(apic): add ApicAuth client and token re-authentication logic (#3522) 2025-05-06 16:23:56 +02:00
mmetc
15dcbdeec9
refact: remove unused metod DeleteDecisionsWithFilter() (#3605) 2025-05-06 16:10:18 +02:00
blotus
959b872118
allowlists: automatically expire current matching decisions on update (#3601) 2025-05-06 14:10:30 +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
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
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
7a1ad8376a
lint: style, autofix (#3354) 2024-12-05 10:40:48 +01:00
blotus
5d414f58e5
Add explicit configuration for signals sharing and blocklists pull (#3277) 2024-11-08 15:11:09 +01:00
mmetc
96d4da76b9
remove unused code: HandleDeletedDecisions() (#3301) 2024-10-29 09:33:44 +01: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
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
fee3debdcc
context propagation: pkg/database/machines (#3248) 2024-09-20 16:00:58 +02:00
mmetc
eeb28014c6
context propagation: pkg/database/config (#3246) 2024-09-19 14:09:35 +02:00
mmetc
be391a3da8
context propagation: pass context to NewAPIC() (#3231) 2024-09-19 11:09:29 +02:00
mmetc
c8750f604c
refact: pkg/apiclient set and use default user agent (#3219)
* default user agent

* DRY default user agent

* useragent.go

* moved to pkg/apiclient/useragent

* lint

* rename useragent.DefaultUserAgent() -> useragent.Default()
2024-09-09 11:27:20 +02:00
mmetc
52995b8fa4
prevent nil deref when loading cti config (#3176)
* correct variable names

* prevent nil deref when loading cti config
2024-08-12 10:15:00 +02:00
mmetc
64e4ecde90
LAPI: detailed metrics endpoint (#2858) 2024-07-24 10:29:18 +02:00
mmetc
9101de95d8
pkg/database: refactor & rename "soft delete" to "expire" (#3025)
* pkg/database: replace parameter with explicit methods

* merge methods with recusion

* rename "soft delete" -> "expire"

* lint
2024-06-04 13:19:46 +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
mmetc
529d3b2079
minor lint/readability (#2976)
* simplify a couple loops

* if/else -> switch

* drop redundant else

* comment + drop var declaration + explicit zero return

* lint (whitespace/fmt.Errorf)
2024-05-02 13:42:47 +02:00
Thibault "bui" Koechlin
b63e64ee9f
Fix locking logic for HA + add list unsubscribe for PAPI (#2904)
* add list unsubscribe operation for papi

* fix the locking logic for HA
2024-03-19 10:29:16 +01:00
mmetc
8da490f593
refact pkg/apiclient (#2846)
* extract resperr.go
* extract method prepareRequest()
* reset token inside mutex
2024-02-22 11:42:33 +01:00
he2ss
97c441dab6
implement highAvailability feature (#2506)
* implement highAvailability feature
---------

Co-authored-by: Marco Mariani <marco@crowdsec.net>
2024-02-14 12:26:42 +01:00
mmetc
48f011dc1c
apiclient/apiserver: lint/2 (#2741) 2024-01-15 12:38:31 +01:00
mmetc
75d8ad9798
apiclient/apiserver: lint (#2739) 2024-01-15 11:44:38 +01:00
mmetc
89f704ef18
light pkg/api{client,server} refact (#2659)
* tests: don't run crowdsec if not necessary
* make listen_uri report the random port number when 0 is requested
* move apiserver.getTLSAuthType() -> csconfig.TLSCfg.GetAuthType()
* move apiserver.isEnrolled() -> apiclient.ApiClient.IsEnrolled()
* extract function apiserver.recoverFromPanic()
* simplify and move APIServer.GetTLSConfig() -> TLSCfg.GetTLSConfig()
* moved TLSCfg type to csconfig/tls.go
* APIServer.InitController(): early return / happy path
* extract function apiserver.newGinLogger()
* lapi tests
* update unit test
* lint (testify)
* lint (whitespace, variable names)
* update docker tests
2023-12-14 14:54:11 +01:00
Cristian Nitescu
7c5cbef51a
manage force_pull message for one blocklist (#2615)
* manage force_pull message for one blocklist

* fix info message on force pull blocklist
2023-11-29 11:37:46 +01:00
mmetc
15542b78fb
refact BulkDeleteDecisions (#2308)
Code cleanup and de-duplication.
2023-11-26 22:30:03 +01:00
mmetc
5cd4406f5e
typos/grammar (#2561) 2023-11-07 15:07:36 +01:00
mmetc
61d4ccbfdd
use go 1.21.1 (#2418)
* use go 1.21.1, require 1.21
* import "slices" from stdlib
* allow codeql to set version number from tags
* codeql: custom WASM build - the automated one can silently fail
2023-10-04 13:01:57 +02:00
Thibault "bui" Koechlin
e4dcdd2572
fix include_capi filter (#2478) 2023-09-20 11:56:00 +02:00
mmetc
afeb541eac
apic: minor refactoring (#2415)
* apic: minor refactoring

* Add whitelist length check

If user configures the file but fails to define and actual whitelist we should check length to save allocs

* Init with length from file

* extract loop method from ApplyApicWhitelists

* pass pointer

* extract loop method updateBlocklist

---------

Co-authored-by: Laurence Jones <laurence.jones@live.co.uk>
2023-08-10 13:03:47 +02:00
mmetc
ffadd42779
update dependency on go-cs-lib; drop the pkg/ part (#2393) 2023-07-28 16:35:08 +02:00
mmetc
9967d60987
errors.Wrap -> fmt.Errorf (#2333) 2023-07-06 10:14:45 +02:00
mmetc
507da49b5a
send metrics immediately if agents are added or removed (#2296) 2023-06-23 14:06:04 +02:00
mmetc
92a9d6c321
types.InSlice() -> slices.Contains() (#2246) 2023-05-31 12:39:22 +02:00
mmetc
9167bd107d
decouple bouncer dependencies: use go-cs-lib/pkg/ptr (#2228) 2023-05-25 15:43:39 +02:00
mmetc
534328ca30
decouple bouncer dependencies: use go-cs-lib/pkg/* (#2216)
* decouple bouncer dependencies: use go-cs-lib/pkg/trace
* decouple bouncer dependencies: use go-cs-lib/pkg/version
* decouple bouncer dependencies: use go-cs-lib/pkg/yamlpatch
* decouple bouncer dependencies: use go-cs-lib/pkg/csstring
* unused import
2023-05-23 10:52:47 +02:00
blotus
91eb39cff6
New PAPI commands: reauth + force_pull (#2129) 2023-03-21 14:06:19 +01:00
Thibault "bui" Koechlin
a74e424d53
support ip and cidr based whitelists for capi and 3rd party blocklists (#2132)
* support ip and cidr based whitelists for capi and 3rd party blocklist
2023-03-21 11:50:10 +01:00
blotus
83c3818504
Do not try to refresh JWT token when doing a login request (#2059) 2023-02-16 16:16:26 +01:00
Cristian Nitescu
ecb32d74c6
optimize blocklist fetch (#2039) 2023-02-13 15:06:14 +01:00
Cristian Nitescu
f280505eaa
omtimization - remove useless login call (#2036) 2023-02-13 15:05:58 +01:00