Skip to content

Conversation

@kingthorin
Copy link
Member

Overview

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

@psiinon
Copy link
Member

psiinon commented Aug 20, 2025

Logo
Checkmarx One – Scan Summary & Details2b9816e5-290f-41f3-89fa-e369ec35e7d3

Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
LOW Heap_Inspection /addOns/authhelper/src/test/java/org/zaproxy/addon/authhelper/AuthUtilsUnitTest.java: 1346

Use @Checkmarx to reach out to us for assistance.

Just send a PR comment with @Checkmarx followed by a natural language request.

Examples: @Checkmarx how are you able to help me? @Checkmarx rescan this PR

@kingthorin kingthorin force-pushed the redir-wavsep-fps branch 3 times, most recently from 10ed03c to 6b120f2 Compare August 23, 2025 15:41
@kingthorin kingthorin marked this pull request as ready for review August 24, 2025 22:21
@kingthorin kingthorin requested a review from Copilot August 25, 2025 02:32

This comment was marked as outdated.

This comment was marked as outdated.

@kingthorin kingthorin force-pushed the redir-wavsep-fps branch 6 times, most recently from 3c91fd7 to 436c2b7 Compare August 26, 2025 21:13
@kingthorin
Copy link
Member Author

Deconflicted

@kingthorin kingthorin force-pushed the redir-wavsep-fps branch 5 times, most recently from 0d6d8cb to 6c9a24c Compare September 2, 2025 15:39
@kingthorin kingthorin requested a review from Copilot September 3, 2025 18:05
Copy link

Copilot AI left a 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.

@kingthorin
Copy link
Member Author

Got all those I believe

@kingthorin
Copy link
Member Author

I think this is ready for review now. I believe I've addressed everything discussed.

@kingthorin
Copy link
Member Author

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.

https://github.com/zaproxy/zap-extensions/compare/main...kingthorin:zap-extensions:redir-wavsep-fps-rhino?expand=1

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.

@thc202
Copy link
Member

thc202 commented Oct 31, 2025

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

@kingthorin
Copy link
Member Author

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.

@kingthorin
Copy link
Member Author

Checking the failure.

@kingthorin
Copy link
Member Author

Fixed

@thc202
Copy link
Member

thc202 commented Oct 31, 2025

Thank you!

@kingthorin kingthorin force-pushed the redir-wavsep-fps branch 2 times, most recently from e05fa64 to 23ca185 Compare October 31, 2025 17:17
@kingthorin kingthorin requested review from Copilot and psiinon October 31, 2025 23:24
Copy link

Copilot AI left a 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.

Comment on lines 512 to 513
// 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);
Copy link
Member Author

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 😞

Copy link
Member Author

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

Copy link
Member Author

@kingthorin kingthorin Nov 3, 2025

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.

@kingthorin kingthorin requested a review from Copilot November 1, 2025 15:07

This comment was marked as outdated.

@psiinon psiinon merged commit ab4c945 into zaproxy:main Nov 4, 2025
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2025
@kingthorin kingthorin deleted the redir-wavsep-fps branch November 4, 2025 13:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants