Skip to content
This repository has been archived by the owner on May 14, 2020. It is now read-only.

Rule 942360: Small bug in the regex cause FP #1580

Closed
Taiki-San opened this issue Oct 3, 2019 · 10 comments
Closed

Rule 942360: Small bug in the regex cause FP #1580

Taiki-San opened this issue Oct 3, 2019 · 10 comments

Comments

@Taiki-San
Copy link
Contributor

Type of Issue

False positive.

Description

The rule trigger a false positive for the following pattern: \W asbla from.
More specifically, patterns similar to , aside from will trigger.

This is likely due to the following construct [\W]\s+as\s*?[\\"'`\w]+\s*?from being used instead [\W]\s+as\s+?[\\"'`\w]+\s*?from.
Specifically \s*? instead of \s+?.

Confirmation

[X] I have removed any personal data (email addresses, IP addresses,
passwords, domain names) from any logs posted.

@dune73
Copy link
Contributor

dune73 commented Oct 3, 2019

Sorry for the inconvenience and thank you for reporting.

@franbuehler : You reassembled this rule in your regex archaeology project, I think. Anything comment?

@Taiki-San
Copy link
Contributor Author

No problem, thanks for the quick response.
Do you want me to open a PR implementing this change?

@dune73
Copy link
Contributor

dune73 commented Oct 3, 2019

The 184 open issues does not mean we don't care. It just means we're not enough people in the project. :)

In the light of this, a PR would be most welcome. Can't guarantee immediate merge though, we'll need to take a closer look first.

@Taiki-San
Copy link
Contributor Author

Didn't meant to imply so :)
Created the PR!

@fgsch
Copy link
Contributor

fgsch commented Oct 4, 2019

Changing the \s* to \s+ will break e.g. 1 as' from.

I think a better fix would be to add a word boundary:

[\W]\s+as\b\s*?[\\"'`\w]+\s*?from

This still matches the case above and doesn't match , aside from.

Using pcretest:

"[\d\W]\s+as\s+?[\"'`\w]+\s*?from"
, aside from
No match
1 as' from
No match

"[\d\W]\s+as\b\s*?[\"'`\w]+\s*?from"
, aside from
No match
1 as' from
 0: 1 as' from

What do you think?

@Taiki-San
Copy link
Contributor Author

Yeah, your solution is better, updated the PR.

@emphazer
Copy link
Contributor

emphazer commented Oct 8, 2019

@fgsch good solution with \b instead of +.
okay, i could change the regression test to 6 As" from for example

@fgsch
Copy link
Contributor

fgsch commented Oct 8, 2019

@emphazer thanks. should we have a separate PR or include it in #1580?

@fgsch fgsch added the PR available this issue is referenced by an active pull request label Oct 8, 2019
@emphazer
Copy link
Contributor

emphazer commented Oct 8, 2019

@fgsch no problemo, i will make a seperate PR today

@fgsch
Copy link
Contributor

fgsch commented Oct 28, 2019

Sorry for the delay. The fix is merged now.

@fgsch fgsch closed this as completed Oct 28, 2019
@fgsch fgsch removed the PR available this issue is referenced by an active pull request label Oct 28, 2019
fgsch added a commit to fgsch/coreruleset-old that referenced this issue Oct 28, 2019
fgsch added a commit to fgsch/coreruleset-old that referenced this issue Oct 28, 2019
csanders-git pushed a commit that referenced this issue Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants