-
-
Notifications
You must be signed in to change notification settings - Fork 748
ascanrules: Address External Redirect False Positives #6677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a3c7e33 to
a252c5b
Compare
|
Fixed Issues (1)Great job! The following issues were fixed in this Pull Request
Use @Checkmarx to reach out to us for assistance. Just send a PR comment with Examples: |
10ed03c to
6b120f2
Compare
...les/src/test/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRuleUnitTest.java
Outdated
Show resolved
Hide resolved
3c91fd7 to
436c2b7
Compare
|
Deconflicted |
...les/src/test/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRuleUnitTest.java
Outdated
Show resolved
Hide resolved
0d6d8cb to
6c9a24c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
The External Redirect scan rule has been updated to reduce false positives by excluding JavaScript code that appears within comments from triggering redirect vulnerability alerts.
- Added JavaScript comment parsing logic to filter out commented code before pattern matching
- Enhanced test coverage with comprehensive comment scenarios including various escape sequences and edge cases
- Updated changelog to document the false positive improvement
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ExternalRedirectScanRule.java | Added JavaScript comment extraction logic and state machine parser to filter out commented code |
| ExternalRedirectScanRuleUnitTest.java | Added comprehensive test cases covering various JavaScript comment scenarios and edge cases |
| CHANGELOG.md | Documented the false positive fix for JavaScript comments |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
6c9a24c to
ff39efb
Compare
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
ff39efb to
40fd2ef
Compare
|
Got all those I believe |
40fd2ef to
89de190
Compare
cb0c82e to
2d3fd86
Compare
|
I think this is ready for review now. I believe I've addressed everything discussed. |
|
Maybe this is a preferable solution (using Rhino), it handles all the existing test cases added here except "Inline incomplete block", which is kind of understandable. I doubt that browsers would be able to handle JavaScript in that case either. Let me know what you think, not a full review just a gutt feel: "Ya that's better" "naw let's stick with the state machine" kinda thing. |
|
As said before any proven parser is preferable to manual parsing, the question is more which one. I don't have a preference as long it's being actively maintained (though using the engine we already bundle by default would be even better but that assumes it's possible). |
2d3fd86 to
7b9242b
Compare
|
Okay I've switched this over. Mainly I wanted to make sure that people were okay with using Rhino. It's maintained, its JS feature support is a bit behind but for the purpose here it should be totally fine. |
|
Checking the failure. |
7b9242b to
ad16997
Compare
|
Fixed |
ad16997 to
0ba6416
Compare
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
|
Thank you! |
e05fa64 to
23ca185
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Show resolved
Hide resolved
.../ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java
Outdated
Show resolved
Hide resolved
...les/src/test/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRuleUnitTest.java
Outdated
Show resolved
Hide resolved
23ca185 to
9115ac2
Compare
| // Rhino drops a character when the snippet ends with a single line comment so add a newline | ||
| AstRoot ast = parser.parse(jsSource + "\n", null, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be seen by leveraging debugPrint() on the ast or comment, the length of the comment is always reported one character short 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reported upstream: mozilla/rhino#2151
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without a doubt when others read this on Monday you'll wonder why this wasn't relevant before. But you can see from the simple example in the linked issue that it is a Rhino issue. I'm not sure, I didn't get to dig into that yet.
I can but I don't want it to derail this. Let me know if you prefer that I roll back to the previous state.
9115ac2 to
9f0b6d3
Compare
Signed-off-by: kingthorin <[email protected]>
9f0b6d3 to
0562383
Compare


Overview
The External Redirect scan rules has been updated to account for potential false positives involving JavaScript comments.