feat(filters): add SCENARIOS_CONTAINING and SCENARIOS_NOT_CONTAINING options#143
Open
tommy-ng0 wants to merge 1 commit into
Open
feat(filters): add SCENARIOS_CONTAINING and SCENARIOS_NOT_CONTAINING options#143tommy-ng0 wants to merge 1 commit into
tommy-ng0 wants to merge 1 commit into
Conversation
…options Expose the LAPI scenarios_containing / scenarios_not_containing decision filters as bouncer configuration. The values are comma-separated substrings, matched server-side by the LAPI, and are appended (URL-encoded) to both the stream pull (/v1/decisions/stream) and live query (/v1/decisions) URLs, for both API-key and TLS authentication paths. Both options default to empty, leaving existing behavior unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two configuration options that flow through to the LAPI decision queries:
SCENARIOS_CONTAINING— only enforce decisions whose scenario contains one of the comma-separated substringsSCENARIOS_NOT_CONTAINING— ignore decisions whose scenario contains one of the comma-separated substringsThese map directly to the
scenarios_containing/scenarios_not_containingfilters the LAPI already supports on both/v1/decisions/streamand/v1/decisions(matching is done server-side, case-insensitive substring per comma-separated value — seepkg/database/decisionfilter.goin crowdsecurity/crowdsec).Why
The bouncer currently pulls every decision the LAPI streams. When running several remediation components against one LAPI, it's useful for a given nginx bouncer to only enforce a subset of scenarios (e.g. only
http-scenarios at a web edge, or excludingssh-bfbans that another component handles). Other remediation components (e.g. the blocklist mirror) already expose decision filtering; this brings the nginx/openresty bouncer in line.How
config.lua: two new string options, both defaulting to""(no behaviour change when unset)utils.lua:M.scenario_filters()builds the query-string fragment, URL-encoding the values (ngx.escape_uri); returns""when both options are emptystream.lua/live.lua: the fragment is appended to the stream pull and live query URLs, in both the API-key and TLS-auth pathsconfig_example.conf: documentedExample:
SCENARIOS_CONTAINING=crowdsecurity/http-,wordpressproducesTesting
luajit -bl)scenario_filters()verified for both-set / one-set / none-set inputs (empty string when unset, so existing URLs are byte-identical)