zaproxy icon indicating copy to clipboard operation
zaproxy copied to clipboard

Filtering a rule does not work on ZAP

Open Manmathkulkarni opened this issue 4 months ago • 3 comments

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:

  1. 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"
  1. 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]
  1. Merge the alertFilter YAML into the main automation plan so filters run before the spider and scan jobs.

  2. Pass the merged automation plan to ZAP using -autorun.

  3. Inspect the generated zap-scan-report.json.

  4. 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 url with urlRegex: 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

Manmathkulkarni avatar Jul 10 '26 10:07 Manmathkulkarni

In step one you're generating the config every run.

Step one also isn't using an af plan.

kingthorin avatar Jul 10 '26 11:07 kingthorin

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).

kingthorin avatar Jul 10 '26 11:07 kingthorin

No feedback in 3mo. Plus there's been additional Alert Filter fixes in the meantime.

Closing.

kingthorin avatar Oct 09 '26 17:10 kingthorin