Skip to content
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

fixes misspelled build tag coraza.rule.multiphase_evaluation #1338

Merged
merged 3 commits into from
Apr 3, 2025

Conversation

daum3ns
Copy link
Contributor

@daum3ns daum3ns commented Mar 28, 2025

No description provided.

M4tteoP
M4tteoP previously approved these changes Mar 28, 2025
Copy link
Member

@M4tteoP M4tteoP left a comment

Choose a reason for hiding this comment

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

Thanks for spotting it and opening the PR!

@@ -282,7 +282,7 @@ func TagsMatrix() error {
"coraza.rule.case_sensitive_args_keys",
"coraza.rule.no_regex_multiline",
"memoize_builders",
"coraza.rule.multiphase_valuation",
"coraza.rule.multiphase_evaluation",
Copy link
Member

Choose a reason for hiding this comment

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

Ouch, this changes the permutations of build tags generated for the CI, and a permutation is failing now with the correct tag 🫤

Copy link
Contributor Author

@daum3ns daum3ns Mar 28, 2025

Choose a reason for hiding this comment

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

hm, does this mean it only succeeded before because it was incorrectly set?
this would make sense because the rules in the failing test here use ARGS
https://github.com/corazawaf/coraza/blob/main/testing/engine/variables.go#L174
if it was not correctly set before this matched...

Copy link
Member

@M4tteoP M4tteoP Mar 28, 2025

Choose a reason for hiding this comment

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

hm, does this mean it only succeeded before because it was incorrectly set?

Yes, I think so. This is a quite recently added test, and we did not catch that it is not flexible enough to work with multiphase.

Copy link
Member

Choose a reason for hiding this comment

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

I just took a quick look, but I think that:

  • the test is expecting exactly the following line Message from rule 12: ARGS:key2[name], macro expansion: PaYlOaD in the logs
  • multiphase is splitting ARGS into ARGS_GET and ARGS_POST, therefore, I suspect the log line is going to be Message from rule 12: ARGS_POST:key2[name], macro expansion: PaYlOaD.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

somehow I can't test it locally on my side.. when i run go run mage.go coverage
i get the following error:

Running tests with coverage
Tags: memoize_builders,coraza.rule.multiphase_evaluation,no_fs_access
go: downloading github.com/corazawaf/coraza-coreruleset v0.0.0-20240226094324-415b1017abdc
# github.com/corazawaf/coraza/v3/internal/seclang
github.com/corazawaf/coraza-coreruleset@v0.0.0-20240226094324-415b1017abdc: reading https://proxy.golang.org/github.com/corazawaf/coraza-coreruleset/@v/v0.0.0-20240226094324-415b1017abdc.zip: 403 Forbidden
FAIL	github.com/corazawaf/coraza/v3/internal/seclang [setup failed]

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.09%. Comparing base (681afa9) to head (53f2f33).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1338      +/-   ##
==========================================
+ Coverage   81.99%   84.09%   +2.10%     
==========================================
  Files         170      170              
  Lines        9803     9803              
==========================================
+ Hits         8038     8244     +206     
+ Misses       1518     1317     -201     
+ Partials      247      242       -5     
Flag Coverage Δ
coraza.rule.case_sensitive_args_keys 84.05% <ø> (+2.10%) ⬆️
coraza.rule.multiphase_evaluation 83.74% <ø> (?)
coraza.rule.multiphase_valuation ?
coraza.rule.no_regex_multiline 84.03% <ø> (+2.10%) ⬆️
default 84.09% <ø> (+2.10%) ⬆️
examples+ 16.50% <ø> (ø)
examples+coraza.rule.case_sensitive_args_keys 84.05% <ø> (+2.10%) ⬆️
examples+coraza.rule.multiphase_evaluation 83.58% <ø> (?)
examples+coraza.rule.multiphase_valuation ?
examples+coraza.rule.no_regex_multiline 83.95% <ø> (+2.10%) ⬆️
examples+memoize_builders 84.06% <ø> (+2.11%) ⬆️
examples+no_fs_access 81.28% <ø> (ø)
ftw 84.09% <ø> (+2.10%) ⬆️
memoize_builders 84.19% <ø> (+2.11%) ⬆️
no_fs_access 83.54% <ø> (+2.10%) ⬆️
tinygo 84.06% <ø> (+2.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

SecRule TX:macro_exp_var "@contains newValue"
SecRule ARGS:key2[name] "@contains PaYlOaD" "id:12,phase:2,pass,log,logdata:'Message from rule 12: %{MATCHED_VAR_NAME}, macro expansion: %{ARGS.key2[name]}'"
SecRule ARGS_POST:key2[name] "@contains PaYlOaD" "id:12,phase:2,pass,log,logdata:'Message from rule 12: %{MATCHED_VAR_NAME}, macro expansion: %{ARGS_POST.key2[name]}'"
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! We should have dedicated tests (to be checked) with multiphase checking the ARGS -> ARGS_POST conversion, so this test should be good like this.

@M4tteoP M4tteoP merged commit becf833 into corazawaf:main Apr 3, 2025
72 checks passed
@daum3ns daum3ns deleted the fix-misspelled-build-tag branch April 4, 2025 07:07
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.

2 participants