feat(notification-http): add dynamic URL query params support#4295
feat(notification-http): add dynamic URL query params support#4295TO19 wants to merge 1 commit intocrowdsecurity:masterfrom
Conversation
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.
|
@TO19: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.
DetailsI 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: There are no area labels on this PR. You can add as many areas as you see fit.
DetailsI 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. |
|
/kind feature |
|
/area configuration |
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 :
Example of a format in the configuration notifications/http.yaml
It will produce
https://www.example.com/?message=19.19.19.19+banned+for+scenarioTested on
version: v1.7.6-debian-pragmatic-amd64-eacc8192