8000 Adds common and uniform http headers to tests by fzipi · Pull Request #2362 · coreruleset/coreruleset · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adds common and uniform http headers to tests #2362

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

Merged
merged 13 commits into from
Feb 3, 2022

Conversation

fzipi
Copy link
Member
@fzipi fzipi commented Jan 24, 2022

This is a heavy to review patch. Fixes #2344

  • I've tried to split commits one per directory, so they can be reviewed independently.
  • There are lots of formatting changes, but I think they will be good afterwards.

@airween
Copy link
Contributor
airween commented Jan 25, 2022

There were some failed test, so I have collected the reasons.

The list of the errors:
https://github.com/coreruleset/coreruleset/runs/4929701146?check_suite_focus=true#step:4:2837

The cases:

913100

I'm not sure we can change the User-Agent header, because that's the meaning of the rule, eg:

https://github.com/coreruleset/coreruleset/pull/2362/files#diff-70624f5dbe4122947942480691f9b72512dd30dabd9166dc05e0db5ec5e72800R22

but the original was:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-70624f5dbe4122947942480691f9b72512dd30dabd9166dc05e0db5ec5e72800L24-L25

List of patterns of User-Agent here:
https://github.com/coreruleset/coreruleset/blob/v3.4/dev/rules/scanners-user-agents.data#L86

913101

same issue, the new one wants to "attack" with "ModSecurity CRS 3 Tests"
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-2922dcf98b8f8dee3d675929e442f95d33b2d0e63ed71adda8628ea7ba72b59bR17

the old one:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-2922dcf98b8f8dee3d675929e442f95d33b2d0e63ed71adda8628ea7ba72b59bL19

920280

rule triggered if Host header is missing. The new test contains the Host header, therefore the test will failed
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-c96cb52bca62ee17f2b134623c8a56f1eac4b54224d21417f335c9b6b78f7241R17

920290

similar, but rule checks that Host is empty or not. The new test contains a non-empty header:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-e49afdd6a642183ac7dc12d3abba290e9ebe8b13124dfa30fe77715ae5963500R19

920300

rule triggered if Accept header is missing, but the new test contains it:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-ee6875766a99f60dfa20e64b019683b48975cc4b8988c97ea49fb77aeaae7696R22

920310

rule checks that Accept is missing or not; the new test contains it:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-01122e22d5867c9262e294bc166a3f0ce84b9882b612ebf28d581a62579b1c65R16
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-01122e22d5867c9262e294bc166a3f0ce84b9882b612ebf28d581a62579b1c65R53

920311

rule is sibling of 920310, but test contains the header:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-f763e4c512d9f5a8c6ac46811fb2d76053ed9fd54fdc542b3045d9a26a24b96eR16

920320

rule checks that User-Agent is missing, but new test contains it:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-9e2096d0b529994db5084342b0caa92508c6e65e3db07a50770d38487ab7bdb9R16

920330

rule checks that User-Agent is empty, but new test contains a non-empty value:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-7c30048b0bf1a8c7f564f3bc2f5ebde0b7871fcd04938571176a2703721da84dR15

920350

this rule checks Host header contins an IP address or not, we can't change that header for positive checks:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-96990e7711d7b6a503e66afefac09b8d60cd308a10ea20c45954ee8ca9413356R17
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-96990e7711d7b6a503e66afefac09b8d60cd308a10ea20c45954ee8ca9413356R47
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-96990e7711d7b6a503e66afefac09b8d60cd308a10ea20c45954ee8ca9413356R62
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-96990e7711d7b6a503e66afefac09b8d60cd308a10ea20c45954ee8ca9413356R77
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-96990e7711d7b6a503e66afefac09b8d60cd308a10ea20c45954ee8ca9413356R92

920490

rule checks x-up-devcap-post-charset; if it exists, then checks the User-Agent, which has to contains string 'up'. The new one doesn't contains.
the old one:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-e46cb93e7c78522861930602c6c6e6f5b67c7fc835bd805847e667479081cd93L46

the new:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-e46cb93e7c78522861930602c6c6e6f5b67c7fc835bd805847e667479081cd93R16

931130

this rules checks the arguments with an URI-like schema; if it matches, checks compares the Host header with a transaction variable, so I think we can't change it

the old tests:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-baf121d9cfd54321b35a246c96295de823021919a0892fa144e01ea95026a657L154
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-baf121d9cfd54321b35a246c96295de823021919a0892fa144e01ea95026a657L188

the new ones:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-baf121d9cfd54321b35a246c96295de823021919a0892fa144e01ea95026a657R144
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-baf121d9cfd54321b35a246c96295de823021919a0892fa144e01ea95026a657R176

941100

this is an XSS rule, some part of the request must have contains the attack
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-e27ff48fe39e5d0486a366f191daac5352729810270ee84ef44e6024df474e11L52
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-e27ff48fe39e5d0486a366f191daac5352729810270ee84ef44e6024df474e11R48

941110

same as 941100
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-481b31a2307b10c6a65c37181b76163eab6cc559b6e1195d13129611dfa48a31L53
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-481b31a2307b10c6a65c37181b76163eab6cc559b6e1195d13129611dfa48a31R49

941160-8

this is a "NoScript InjectionChecker" rule, the affected header is the User-Agent - we can't change the old one:
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-fdbcc26676eab1de35a89bc6a3e0e930bdbf6c976396570d61c883543b095f48L132
https://github.com/coreruleset/coreruleset/pull/2362/files#diff-fdbcc26676eab1de35a89bc6a3e0e930bdbf6c976396570d61c883543b095f48R123

If you need any other help, just let me know.

Btw: why do we want to use ModSecurity CRS 3 Tests as User-Agent? Would be enough that just CRS 3 Tests?

@fzipi
Copy link
Member Author
fzipi commented Jan 25, 2022

Hey @airween , thanks for the review. Was doing it now, it was taking a bit because I'm rebasing on old commits.

@fzipi
Copy link
Member Author
fzipi commented Jan 25, 2022

I second the CRS tests user agent change, but also, will it depend on major version? E.g. when CRS 4.x is out, are we changing that?

@airween
Copy link
Contributor
airween commented Jan 25, 2022

I second the CRS tests user agent change, but also, will it depend on major version? E.g. when CRS 4.x is out, are we changing that?

Hmmm... good question.

A crazy idea, but can we detach the test set from the rule set? I mean now you've started to add/modify the headers for the better consistency, so we can say this is a new version of our test set.

May be we can use some new format, like:

CRS Test v1.1, for version 3.4.0-dev

And if we release the 4.0, the we replace the version at the end.

@fzipi fzipi force-pushed the add-common-http-headers-2344 branch 2 times, most recently from d9e86dc to 7b385bc Compare January 25, 2022 18:11
@fzipi
Copy link
Member Author
fzipi commented Jan 25, 2022

All tests passing now.

@airween
Copy link
Contributor
airween commented Jan 25, 2022

All tests passing now.

Let me check this PR in next few days.

10000

@dune73
Copy link
Member
dune73 commented Jan 26, 2022

I'd hate to do separate versioning for the tests. This is making things so complicated. In fact I do not think we need any version in the test UA. Tests are always run in a controlled environment so when something needs debugging you can easily find out the test that triggered. Having the test-ID submitted as part of the test would be more interested (unless we have that already :)

What I would suggest, though, would be to add the CRS test suite user agent string to any existing attacking test string we have already. Thus libwww-perl; OWASP ModSecurity Core Rule Set Test.

@airween
Copy link
Contributor
airween commented Jan 31, 2022

I've reviewed the modified tests, and most of them are done.

There you have all the converted tests and no new tests.

These issues are what I've found:

920171-1

  • this test contains an encoded_request in base64 format, which includes the necessary headers. I think we should left the headers from here and change those values in the base64 encoded string.

920171-2

  • this test contains an encoded_request in base64 format, which includes the necessary headers. I think we should left the headers from here and change those values in the base64 encoded string.

920171-3

  • this test contains an encoded_request in base64 format, which includes the necessary headers. I think we should left the headers from here and change those values in the base64 encoded string.

920300-1

  • wrong comment, the correct should be "test needs a missing 'Accept' header"

920300-2

  • wrong comment, the correct should be "test needs a missing 'Accept' header"

920300-3

  • wrong comment, the correct should be "test needs a missing 'Accept' header"

920300-4

  • 'User-Agent' not uniform, should be "ModSecurity CRS 3 Tests AppleWebKit/537.36"
  • wrong comment, the correct should be "test needs a missing 'Accept' header"

920310-5

  • 'User-Agent' not uniform, should be "ModSecurity CRS 3 Tests Business/6.6.1.2"

920310-6

  • 'User-Agent' not uniform, should be "ModSecurity CRS 3 Tests Entreprise/6.5.0.177"

944200-1

  • this test contains an encoded_request in base64 format, which includes the necessary headers in right form. I think we can remove the necessary headers from here.

fzipi added 13 commits February 3, 2022 12:24
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
@fzipi fzipi force-pushed the add-common-http-headers-2344 branch from 7b385bc to 78fdff8 Compare February 3, 2022 12:31
@fzipi
Copy link
Member Author
fzipi commented Feb 3, 2022

Thanks @airween for the thorough review!

Included all your comments. This should be ready now.... unless you want to change all user agents to OWASP ModSecurity Core Rule Set Test and that is a PITN.

@airween
Copy link
Contributor
airween commented Feb 3, 2022

Included all your comments.

great, thanks!

This should be ready now.... unless you want to change all user agents to OWASP ModSecurity Core Rule Set Test and that is a PITN.

I don't know, what would be the best solution - I wrote my suggestions above based on @dune73 's comment:

What I would suggest, though, would be to add the CRS test suite user agent string to any existing attacking test string we have already. Thus libwww-perl; OWASP ModSecurity Core Rule Set Test.

More thoughts about tests: I think it would be good to extend the list of skeleton tests, eg. add skeleton for encoding_request. Also we should fix these uniform headers in those skeletons. A small documentation also is missing now.

(I can add these after the merge, if you want to apply this patch.)

Ideas?

@fzipi
Copy link
Member Author
fzipi commented Feb 3, 2022

To be honest, I think this is massive and don't want to hold it too much. Drift is happening on every merge, and I was careful to create commits separated, so it is a pain to update.

@dune73 @airween I would do this:

  1. merge this one.
  2. if we want to change the user agent (which I think makes sense), let's go for a new issue and PR
  3. new issue and PR for the skeleton tests

@airween
Copy link
Contributor
airween commented Feb 3, 2022

LGTM!

@fzipi fzipi merged commit 5c4684d into coreruleset:v3.4/dev Feb 3, 2022
@fzipi fzipi deleted the add-common-http-headers-2344 branch February 3, 2022 14:13
@dune73
Copy link
Member
dune73 commented Feb 7, 2022

Agreed on the plan.

And thank you for this huge PR @fzipi and the timely review @airween.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add common HTTP headers to tests so logs get cleaner
3 participants
0