zaproxy / zaproxy/zaproxy

Filtering a rule does not work on ZAP

Open
#9,385 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
15.8k
Forks
2.6k
Avg merge
13h 16m
Merged PRs (30d)
17

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue through the -autorun entry point using the alertFilter job in zap-automation.yaml. Compare zap-scan-report.json with the expected rule IDs, URL, method, context, risk, and finding counts. Done means matching alerts are reclassified as False Positive and excluded from the report counts; no source file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
devops, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.