Filtering a rule does not work on ZAP
Describe the bug:
Hi,
We have tried all the method explained in the user group for filtering false positive. I raised this in the user groups mentioned below. (https://groups.google.com/g/zaproxy-users/c/Md1T377l3Fs)
Steps to reproduce the behavior:
- Run ZAP via Docker using the automation framework with the following command:
docker run -v $(pwd):/zap/wrk/:rw -t zaproxy/zap-stable \
bash -c "zap.sh -addonupdate -addoninstall pscanrulesBeta \
-cmd -autorun /zap/wrk/zap-automation.yaml"
- Create an Automation Framework alertFilter job in a YAML file with the following structure:
- type: alertFilter
parameters:
deleteGlobalAlerts: false
alertFilters:
- ruleId: 10109
context: "staticapp"
newRisk: "False Positive"
url: "https://example\\.azurestaticapps\\.net/.*"
urlRegex: true
methods: [GET]
- ruleId: 10017
context: "staticapp"
newRisk: "False Positive"
url: "https://example\\.azurestaticapps\\.net/.*"
urlRegex: true
methods: [GET]
- ruleId: 10015
context: "staticapp"
newRisk: "False Positive"
url: "https://example\\.azurestaticapps\\.net/.*"
urlRegex: true
methods: [GET]
-
Merge the alertFilter YAML into the main automation plan so filters run before the spider and scan jobs.
-
Pass the merged automation plan to ZAP using -autorun.
-
Inspect the generated zap-scan-report.json.
-
Observe that alerts for rule IDs 10109, 10017, 10015 (and others declared in the alertFilter job) are still present in the report with their original risk level — they are NOT reclassified as "False Positive".
Expected behavior:
Alerts matching all of the following criteria defined in the alertFilter job should be reclassified as "False Positive" in the scan report and excluded from the findings count:
- ruleId matches a declared alertFilter entry (e.g. 10109, 10017, 10015)
- URL matches the regex pattern declared under
urlwithurlRegex: true - HTTP method matches a method declared under
methods - Context matches the declared context name
The generated report (zap-scan-report.json / .xml / .html) should reflect the reclassified risk level of "False Positive" for all matching alerts, and those alerts should not contribute to the high/medium/low finding counts used to gate the pipeline.
Software Versions:
Docker 29.2.1 Zap latest version
Screenshots:
No response
Errors from the zap.log file:
No response
Additional context:
No response
Would you like to help fix this issue?
- [ ] Yes
In step one you're generating the config every run.
Step one also isn't using an af plan.
Your URL regex aren't escaped properly, the slashes after the scheme should be escaped, as well as the trailing slash (or drop that one).
No feedback in 3mo. Plus there's been additional Alert Filter fixes in the meantime.
Closing.