Skip to content

Java: Add comments about use of sink kind regex-use#17053

Merged
owen-mc merged 2 commits intogithub:mainfrom
owen-mc:java/fix/regex-use-sink-kind
Jul 24, 2024
Merged

Java: Add comments about use of sink kind regex-use#17053
owen-mc merged 2 commits intogithub:mainfrom
owen-mc:java/fix/regex-use-sink-kind

Conversation

@owen-mc
Copy link
Copy Markdown
Contributor

@owen-mc owen-mc commented Jul 23, 2024

The sink kind regex-use doesn't match the code which parses regex-use sink kinds for regex injection. It turns out this is intentional, but not clearly documented. This PR adds comments explaining that.

@owen-mc owen-mc requested a review from a team as a code owner July 23, 2024 15:58
@github-actions github-actions bot added the Java label Jul 23, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 23, 2024

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. A recent commit removed the previously reported differences.

Copy link
Copy Markdown
Contributor

@jcogs33 jcogs33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@owen-mc The regex-use sink kind intentionally does not match the regex-use parsing code in order to avoid excess FPs in the java/regex-injection query. Some prior discussion here. Changing this kind to regex-use[0] will break java/regex-injection test cases.

There is an existing issue about adjusting the regex-use% kind to resolve this situation, which I'll send you a link to. @atorralba and I had previously discussed that the appropriate adjustment would not be simple and that is why we left it as an issue.

Perhaps it would be best to simply add a comment in the org.apache.commons.lang3.model.yml file for now to avoid future confusion?

@owen-mc owen-mc force-pushed the java/fix/regex-use-sink-kind branch from 01f78cd to 3edeb82 Compare July 23, 2024 20:40
@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Jul 23, 2024
@github-actions github-actions bot removed documentation no-change-note-required This PR does not need a change note labels Jul 23, 2024
@owen-mc
Copy link
Copy Markdown
Contributor Author

owen-mc commented Jul 23, 2024

@jcogs33 Thanks for explaining that. I've updated this PR to add comments in the two places that I think would be most useful.

@owen-mc owen-mc changed the title Use valid sink kind which encodes location of matched string Java: Add comments about use of sink kind regex-use Jul 23, 2024
@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Jul 23, 2024
@owen-mc owen-mc merged commit 5a39610 into github:main Jul 24, 2024
@owen-mc owen-mc deleted the java/fix/regex-use-sink-kind branch July 24, 2024 20:08
@joefarebrother
Copy link
Copy Markdown
Contributor

Is it accurate to say that the rexex-use kind is "used for regular expression injection sinks that should not be used
as polynomial ReDoS sinks."?
From my understanding, it would be nice to consider the regex injection sinks to also be redos sinks, but the difficulty in actually doing that would be that there are redos sinks that need to not be considered as injection sinks.

@jcogs33
Copy link
Copy Markdown
Contributor

jcogs33 commented Jul 25, 2024

ah sorry, @owen-mc I misread the comments when I reviewed this. Joe is correct.
Thanks for catching @joefarebrother! 🙏

I'll open a PR to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants