Commit graph

169 commits

Author SHA1 Message Date
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
blotus
16d0677938
Add support for centralized allowlists (#3355) 2025-02-19 15:04:47 +01:00
mmetc
efbb42bf9e
deps: use ent 0.14.2 (#3259) 2025-02-18 17:08:58 +01:00
srkoster
62308f535c
Removed last_heartbeat update in MachineUpdateBaseMetrics (#3425) 2025-01-23 18:50:31 +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
6529215775
CI: golangci-lint 1.63 (#3396) 2025-01-16 13:22:08 +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
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
blotus
fb733ee43a
Allow bouncers to share API keys (#3323) 2024-11-19 14:47:59 +01:00
mmetc
897613e837
CI: check generated code in test workflow (#3261) 2024-09-25 09:02:53 +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
519693270e
refact: alerts query (#3216)
* refact alerts: log messages

* refact: AlertPredicatesFromFilter
2024-09-18 15:00:19 +02:00
mmetc
b93b240bd4
lint: enable (some) gocritic checks (#3238)
* lint: gocritic configuration
* lint: octal literals
* lint: gocritic (filepath.Join)
* ling: gocritic (badRegexp, regexpSimplify)
* lint: gocritic (preferStringWriter)
* lint: gocritic (emtpyStringTest)
* filepath.Clean(a+b) -> filepath.Join(a, b)
* gofumpt
2024-09-17 17:07:30 +02:00
mmetc
ce085dc4cd
logs and user messages: use "parse" and "serialize" instead of marshal/unmarshal (#3240) 2024-09-17 13:19:14 +02:00
mmetc
6810b41dd8
refact pkg/database: context propagation (start) (#3226)
* refact pkg/database: context propagation (part)

* more context propagation (usagemetrics)

* propagate errors when updating metrics
2024-09-12 17:28:16 +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
24bd8bb92c
perf: retrieve unsorted metrics (#3148) 2024-07-24 10:50:19 +02:00
mmetc
64e4ecde90
LAPI: detailed metrics endpoint (#2858) 2024-07-24 10:29:18 +02:00
blotus
c4bfdf1991
Store alert remediations status in DB (#3115) 2024-07-16 10:08:00 +02:00
mmetc
5390b8ea4b
remove warning "maxopenconns is 0, default to 100" (#3129)
* remove warning "maxopenconns is 0, default to 100"

also don't store as pointer since value 0 is not useful

* lint
2024-07-15 11:05:40 +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
9cebcf96b4
command cscli [machines|bouncers] inspect (#3103)
* command cscli [machines|bouncers] inspect

* lint
2024-07-03 17:20:20 +02:00
mmetc
4635d04b22
lapi detailed metrics: API spec + models (#3100)
* lapi detailed metrics: API spec + models

* models+db: split hubstate by item type
2024-07-02 22:49:47 +02:00
mmetc
b1cf83975e
db refact: drop column machines.status (#3102) 2024-07-02 16:08:41 +02:00
mmetc
1acc35442c
lapi detailed metrics: db schema (#3099) 2024-07-01 12:14:55 +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
a529e66cd8
Typos (#3084)
* comment fix

* redundancy

* typo nill -> nil

* remove extra newline from log
2024-06-13 11:07:44 +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
mmetc
6ef2396c91
enable linter: revive (blank-imports) (#3062)
* lint: revive (blank-imports) require a comment to justify blank imports

* typo
2024-06-06 16:03:32 +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
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
b8ee31ade2
pkg/database: simplify flush agents/bouncers (#3026)
* pkg/database: simplify flush agents/bouncers

* lint
2024-05-31 15:44:30 +02:00
mmetc
6dbc5fd522
db: mark immutable columns / remove unused (#3024)
* db: mark immutable columns

* db: drop unused column

* lint
2024-05-31 15:19:48 +02:00
mmetc
02e2c8aed7
deps: use ent 0.13.1 (#3023) 2024-05-31 15:00:38 +02:00
blotus
1b894a292b
GetActiveDecisionsCount()and GetActiveDecisionsTimeLeft()expr helpers (#3013) 2024-05-15 15:33:43 +02:00
mmetc
11da728b51
cscli support: collect profiling data and logs (#2987)
* extract methods, avoid globals
* collect logs to file dump.log
* include pprof data
* include latest logs
2024-05-07 12:59:38 +02:00
mmetc
a2dcc0ef9a
cscli: remove global dbClient (#2985)
* cscli: remove global dbClient

* lint (whitespace, errors)
2024-05-06 12:33:54 +02:00
mmetc
659feec496
cscli: don't print timestamps (#2984)
* cscli: don't print timestamps

* lint (whitespace, errors)
2024-05-06 10:43:54 +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
mmetc
91fbc63533
db: review update timestamps, immutable columns (#2981)
* orm: correct behavior of created_at, updated_at, define immutable fields

* remove updatedefault for last_push, last_heartbeat

* re-generate db schema

* update last_push in CreateAlert()

* lint
2024-05-02 12:56:41 +02:00