Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for centralized allowlists #3355

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

blotus
Copy link
Member

@blotus blotus commented Dec 8, 2024

This PR adds a new type of allowlist that is managed by LAPI and applies to alerts, blocklists content and appsec (but not to manual decisions with cscli):

  • alerts are dropped (with a log message)
  • blocklist content matching an allowlist is ignored
  • appsec requests matching an allowlist are not processed

Compared to existing types of allowlists in crowdsec (in parsers, postoverflows, custom profiles or appsec hooks), they only support IPs and ranges (ie, no arbitrary expression), but they can have an optional expiration.

An alert is considered allowlisted in the following situations:

  • The source of the alert is an exact match with a non-expired allowlist item
  • The source of the alert belongs to a non-expired (range) allowlist item
  • The source of the alert contains a non-expired allowlisted item (eg, 1.2.3.4 is allowlisted, and an alert on 1.2.3.0/24 is generated): while this seems counter-intuitive, range alerts are rare and it would be add a lot of complexity to carve out the specific IPs that are allowlisted from the alert source (and generate multiple sub-alerts).

They can be managed with:

  • cscli
  • The console (allowlists created from the console are not editable with cscli to avoid conflict), in which case they are pulled from CAPI or PAPI.

If a local allowlist is created, and another one with the same name is created in the console, the one from the console will replace the local one.

Copy link

github-actions bot commented Dec 8, 2024

@blotus: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copy link

github-actions bot commented Dec 8, 2024

@blotus: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@blotus
Copy link
Member Author

blotus commented Dec 8, 2024

/kind feature
/area local-api

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 22.26488% with 3240 lines in your changes missing coverage. Please review.

Project coverage is 54.40%. Comparing base (411bb48) to head (d7f8d2b).

Files with missing lines Patch % Lines
pkg/database/ent/allowlistitem_query.go 20.19% 313 Missing and 23 partials ⚠️
cmd/crowdsec-cli/cliallowlists/allowlists.go 20.38% 326 Missing and 6 partials ⚠️
pkg/database/ent/allowlist_query.go 22.56% 307 Missing and 19 partials ⚠️
pkg/database/ent/allowlistitem_update.go 0.00% 311 Missing ⚠️
pkg/database/ent/allowlistitem/where.go 14.98% 227 Missing ⚠️
pkg/database/ent/allowlist_update.go 18.18% 219 Missing and 6 partials ⚠️
pkg/database/ent/allowlist/where.go 2.31% 169 Missing ⚠️
pkg/database/ent/allowlistitem_create.go 35.40% 160 Missing and 6 partials ⚠️
pkg/database/ent/allowlist_create.go 27.05% 143 Missing and 8 partials ⚠️
pkg/database/allowlists.go 55.26% 93 Missing and 9 partials ⚠️
... and 22 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3355      +/-   ##
==========================================
- Coverage   58.44%   54.40%   -4.04%     
==========================================
  Files         351      376      +25     
  Lines       37818    41947    +4129     
==========================================
+ Hits        22101    22821     +720     
- Misses      13814    17100    +3286     
- Partials     1903     2026     +123     
Flag Coverage Δ
bats 37.85% <8.82%> (-3.39%) ⬇️
unit-linux 33.85% <11.64%> (-0.58%) ⬇️
unit-windows 26.14% <16.62%> (-3.52%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@blotus blotus force-pushed the centralized-allowlists branch from 3a34d3a to 8385b05 Compare December 9, 2024 00:19
@blotus blotus force-pushed the centralized-allowlists branch from 8385b05 to dbb9adc Compare December 9, 2024 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant