8000 fix: fixed tests and descriptions by theMiddleBlue · Pull Request #3201 · coreruleset/coreruleset · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: fixed tests and descriptions #3201

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

Closed

Conversation

theMiddleBlue
Copy link
Contributor
@theMiddleBlue theMiddleBlue commented Apr 23, 2023

Regression tests for 933160 seem to be inconsistent (#3198) . I've fixed the following problems:

  • duplicated body from the previous test (maybe a copy and paste issue)
  • test intended as FP test, but the body was dup from other tests and the output was "log_contains"
  • test duplicated with a different description. Tried to create a test from the description.

I've tested all payloads against the sandbox, and after my fixes, we've some test that doesn't pass correctly due to whitespaces in the payload. Maybe the rule regex should consider it.

@theMiddleBlue theMiddleBlue requested a review from a team April 23, 2023 18:32
@theMiddleBlue
Copy link
Contributor Author

Failed tests have the following payloads. Except for the last one, there's no match at PL1

payload: fopen //comment\r\n (blah)

curl -s 'https://sandbox.coreruleset.org/?foo=fopen%20%2f%2fcomment%0d%0a%20%28blah%29' \
-H 'x-crs-paranoia-level: 1' \
-H 'x-format-output: txt-matched-rules' 

payload: fopen #comment\r\n (blah)

curl -s 'https://sandbox.coreruleset.org/?foo=fopen%20%23comment%0d%0a%20%28blah%29' \
-H 'x-crs-paranoia-level: 1' \
-H 'x-format-output: txt-matched-rules' 

payload: fopen \t #\n ()

curl -s 'https://sandbox.coreruleset.org/?foo=fopen%20%09%20%23%0a%20%28%29' \
-H 'x-crs-paranoia-level: 1' \
-H 'x-format-output: txt-matched-rules'

payload: fopen \t/**/\t ()

curl -s 'https://sandbox.coreruleset.org/?foo=fopen%20%09%2f%2a%2a%2f%09%20%28%29' \
-H 'x-crs-paranoia-level: 1' \
-H 'x-format-output: txt-matched-rules'

payload: fopen\t/foo\r\nbar/\t ()

curl -s 'https://sandbox.coreruleset.org/?foo=fopen%09%2f%2afoo%0d%0abar%2a%2f%09%20%28%29' \
-H 'x-crs-paranoia-level: 1' \
-H 'x-format-output: txt-matched-rules'

payload: /eval(base64_decode('JGNoZWNrID...

curl -s 'https://sandbox.coreruleset.org/eval%28base64_decode%28%27JGNoZWNrID...' \
-H 'x-crs-paranoia-level: 1' \
-H 'x-format-output: txt-matched-rules' 

933150 PL1 PHP Injection Attack: High-Risk PHP Function Name Found
934100 PL1 Node.js Injection Attack 1/2
941390 PL1 Javascript method detected
949110 PL1 Inbound Anomaly Score Exceeded (Total Score: 15)
980170 PL1 Anomaly Scores: (Inbound Scores: blocking=15, detection=15, per_pl=15-0-0-0, threshold=5) - (Outbound Scores: blocking=0, detection=0, per_pl=0-0-0-0, threshold=4) - (SQLI=0, XSS=5, RFI=0, LFI=0, RCE=5, PHPI=5, HTTP=0, SESS=0, COMBINED_SCORE=15)

Testing at PL2, all payload are blocked by other rules. Should we accept this and remove the failing tests?

@theseion
Copy link
Contributor

There's an error in the regular expression that you uncovered. Line 13 of 933160.ra should be ##!$ |\s|\")* (note the leading |).

@theseion
Copy link
Contributor

Great work!

Two more things:

  • could you fix the file names here and here, for example, util/regexp-assemble/data/933160.data should be regex-assembly/933160.ra?
  • could you fix the typo here? It should be parentheses

@theMiddleBlue
Copy link
Contributor Author

There's an error in the regular expression that you uncovered. Line 13 of 933160.ra should be ##!$ |\s|\")* (note the leading |).

regex changes fixed almost all failing tests, seems that 933160-23 still failing.

This is the response from sandbox:

curl -s 'https://sandbox.coreruleset.org/get/eval%28base64_decode%28%27JGNoZWNrID...' \
-H 'x-crs-paranoia-level: 1' \
-H 'x-format-output: txt-matched-rules'

933150 PL1 PHP Injection Attack: High-Risk PHP Function Name Found
934100 PL1 Node.js Injection Attack 1/2
941390 PL1 Javascript method detected
949110 PL1 Inbound Anomaly Score Exceeded (Total Score: 15)
980170 PL1 Anomaly Scores: (Inbound Scores: blocking=15, detection=15, per_pl=15-0-0-0, threshold=5) - (Outbound Scores: blocking=0, detection=0, per_pl=0-0-0-0, threshold=4) - (SQLI=0, XSS=5, RFI=0, LFI=0, RCE=5, PHPI=5, HTTP=0, SESS=0, COMBINED_SCORE=15)

@theseion
Copy link
Contributor

The issue appears to be that the parentheses the URL does not include a closing parenthesis: uri: /get/eval%28base64_decode%28%27JGNoZWNrID.... It should be something like uri: /get/eval%28base64_decode%28%27JGNoZWNrID...%29.

@theMiddleBlue
Copy link
Contributor Author

The issue appears to be that the parentheses the URL does not include a closing parenthesis: uri: /get/eval%28base64_decode%28%27JGNoZWNrID.... It should be something like uri: /get/eval%28base64_decode%28%27JGNoZWNrID...%29.

That's true, thanks! Should I change the payload? Idk if setting no_log_contains makes sense here...

@theseion
Copy link
Contributor

That's true, thanks! Should I change the payload? Idk if setting no_log_contains makes sense here...

Yes, I would change the payload.

@theseion
Copy link
Contributor

BTW, do you think it's a mistake that base64_decode is missing from the list of commands?

@theMiddleBlue
Copy link
Contributor Author

BTW, do you think it's a mistake that base64_decode is missing from the list of commands?

I didn't notice it! Yes and maybe base64_decode has more sense here than base64_encode... should I add it in this PR?

@theseion
Copy link
Contributor

I didn't notice it! Yes and maybe base64_decode has more sense here than base64_encode... should I add it in this PR?

Yes, I think that's ok.

@dune73
Copy link
Member
dune73 commented Aug 7, 2023

Do we have a status here? Is this ready to be merged? What is needed here?

@theseion
Copy link
Contributor

Looks good to me. Once my change requests are addressed, this can be merged IMO.

@theseion
Copy link
Contributor

Note that the second test failure (980170) is due to a race condition in go-ftw.

@dune73
Copy link
Member
dune73 commented Aug 31, 2023

@theMiddleBlue I'd like to get this merged. When do you have the time to polish this?

@theMiddleBlue
Copy link
Contributor Author

it should be done

dune73
dune73 previously approved these changes Sep 2, 2023
@dune73
Copy link
Member
dune73 commented Sep 2, 2023

LGTM. Thanks for the update.

@theseion do you agree? If yes, please merge.

theseion
theseion previously approved these changes Sep 6, 2023
@theMiddleBlue
Copy link
Contributor Author

ouch: there're a lot of conflicts

@dune73
Copy link
Member
dune73 commented Sep 8, 2023

Ah, yes, sucks. You were overtaken by the PHP function names generator PR. Maybe better start over from scratch.

@theseion theseion added the v4 Should go into release v4 label Sep 19, 2023
@dune73
Copy link
Member
dune73 commented Nov 9, 2023

Are you still working on this @theMiddleBlue ?

theseion added a commit to theseion/coreruleset that referenced this pull request Dec 19, 2023
A missing alternation in the regular expression for matching characters
after PHP commands caused `#` comments and whitespace to be matched
improperly.

This issue was discovered as part of coreruleset#3201.
@theseion
Copy link
Contributor

The error in the regular expression is fixed with #3432.

@theseion theseion dismissed stale reviews from dune73 and themself via 5c6278b January 21, 2024 09:20
@theseion
Copy link
Contributor

I've rebased and updated / moved tests.

@theseion
Copy link
Contributor

@theMiddleBlue I think I got everything, can you confirm?

@theseion
Copy link
Contributor

Closed in favour of #3462.

@theseion theseion closed this Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v4 Should go into release v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0