-
-
Notifications
You must be signed in to change notification settings - Fork 422
fix(942550): partial revert - too high risk of false positive #4284
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
for more information, see https://pre-commit.ci
|
📊 Quantitative test results for language: |
|
Well, i'm not really familiar with the .ra format. Here is what i would like : (?i)[\"'`][\[\{][\s\S]*?[\]\}][\"'`][\s\S]*?(?:::(/\*.*?\*/)?jsonb?)?(?:(?:@|->?)>|<@|\?[&\|]|#>>?|[<>]|<-)|(?:(?:@|->?)>|<@|\?[&\|]|#>>?|[<>]|<-)?[\"'`][\[\{][^#\]\}]*[\]\}]+[\"'`]|\bjson_extract\b[^\(]*\([^\)]*\) |
|
@theseion Would you find some time to look at this? You are the best with regex assembly among us. |
|
We haven't seen any FP reports for this rules so far (that I'm aware of). I do agree with your assessment though. According to the Postgres docs, I fail to see how adding I propose to remove |
|
Hi Max. We hadn’t seen any false positives on this rule before the change introduced in PR #3767 (https://github.com/coreruleset/coreruleset/pull/3767/files#diff-ffff196fd301a0b25ec989e607586c033a21de733d88f24c6c31267ea2b8ed24L608). The FP only appeared afterwards, which makes sense: the primary/anchor trigger in the chain was removed, so the remaining operator sequence now evaluates on its own and can fire in cases it previously wouldn’t. That’s not acceptable in my view. It’s not just a < vs > issue. This rule should not trigger on any payload that contains: (?:(?:@|->?)>|<@|\?[&\|]|#>>?|[<>]|<-)IMO, the primary group from the previous regex should be preserved: ["'`][\[\{].*[\]\}]["'`].*Or an optimized version : ["'`][\[\{][\s\S]*?[\]\}]["'`][\s\S]*? |
|
@touchweb-vincent Can you add some tests for the false positives you encountered? I've personally found a few false positives as well with the recent changes to this rule but I didn't end up getting around to fix this one specifically. |
|
Thanks @touchweb-vincent. The problematic change in that PR was the addition of the alternation Adding at least one test for a naked operator would certainly be a good idea. @fzipi Do you recall why you had added that alternation? |
|
I don't remember now, but as long as it covers https://github.com/touchweb-vincent/coreruleset/blob/be985322b26610b24ce40ac810e0bdacdaecfa52/regex-assembly/942550.ra#L7-L22 we are probably good. |
|
I went through the regex to make sure it matches the examples. There are a couple of things that I had to fix. I'll open a PR soon. |
Hello, I have added two unit tests we encountered. |
- extend list of operators and documentation - add additional test to cover all operators - remove the naked operator matching alternation - add alternation to match a JSON path expression from SQLite
|
I've updated the PR with my changes. I've extended the list of operators, added an alternation for matching SQLite JSON path expressions and added tests for all the operators. I've also removed your change to the regex @touchweb-vincent, as I had described above, removing the newly introduced alternation already fixes the issue. Since I've now committed to the branch, I can no longer review. @fzipi, @azurit, could you? |
|
Ping @fzipi |
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.
LGTM
Hello,
We can’t leave this regex as is; it matches any sequence containing < or >, for example:
test -> test
test > test
test < test
This will generate too many false positives.
I propose a partial revert: the first group is necessary, IMO, to limit false positives.
Thank you