Skip to content

feat(notification-http): add dynamic URL query params support#4295

Open
TO19 wants to merge 1 commit intocrowdsecurity:masterfrom
TO19:master
Open

feat(notification-http): add dynamic URL query params support#4295
TO19 wants to merge 1 commit intocrowdsecurity:masterfrom
TO19:master

Conversation

@TO19
Copy link

@TO19 TO19 commented Feb 9, 2026

Hello,

In the http notification plugin I needed query params to be dynamic for an API that only uses query parameters.

So I implemented it this way :
If the rendered format output is a JSON object containing a url_query_params field, those key-value pairs are URL-encoded and appended to the configured URL. An optional request_body field controls the HTTP body; if omitted, the body is sent empty.

If the format output is not JSON or lacks url_query_params, existing behavior is unchanged

A cleaner implementation could use a dedicated config key like query_params, but since templating happens in the broker, that would require deeper changes.

How to test :

  • Run bats tests
  • Build the notification-http binary and replace it on a running crowdsec setup

Example of a format in the configuration notifications/http.yaml

format: |
  {"url_query_params": {"message": "{{range $i, $v := .}}{{if $i}},{{end}}{{$v.Source.Value}} banned for {{$v.Scenario}}{{end}}"}}

It will produce https://www.example.com/?message=19.19.19.19+banned+for+scenario

Tested on version: v1.7.6-debian-pragmatic-amd64-eacc8192

Allow the format template to output a JSON object with "url_query_params"
and optional "request_body" fields. Query params are URL-encoded and
appended to the configured URL. If "request_body" is omitted, the HTTP
request body is sent empty.

Includes bats integration tests for both variants (with and without
request body) and updates the mock HTTP server to handle empty bodies.
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

@TO19: 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.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

@TO19: 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.

@TO19
Copy link
Author

TO19 commented Feb 9, 2026

/kind feature

@TO19
Copy link
Author

TO19 commented Feb 9, 2026

/area configuration

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