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

Bug Fix: The value in the setvar should be able to start with - or +. #1125

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

soujanyanmbri
Copy link
Contributor

@soujanyanmbri soujanyanmbri commented Aug 5, 2024

Thank you for contributing to Coraza WAF, your effort is greatly appreciated
Before submitting check if what you want to add to coraza list meets quality standards before sending pull request. Thanks!

Make sure that you've checked the boxes below before you submit PR:

Thanks for your contribution ❤️

@soujanyanmbri soujanyanmbri marked this pull request as ready for review August 5, 2024 08:08
@soujanyanmbri soujanyanmbri requested a review from a team as a code owner August 5, 2024 08:08
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.14%. Comparing base (4ff1f76) to head (e0e3a5f).
Report is 86 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1125      +/-   ##
==========================================
+ Coverage   82.72%   83.14%   +0.42%     
==========================================
  Files         162      164       +2     
  Lines        9080     7691    -1389     
==========================================
- Hits         7511     6395    -1116     
+ Misses       1319     1042     -277     
- Partials      250      254       +4     
Flag Coverage Δ
default 83.14% <100.00%> (+5.31%) ⬆️
examples 83.14% <100.00%> (+56.71%) ⬆️
ftw 83.14% <100.00%> (+35.78%) ⬆️
ftw-multiphase 83.14% <100.00%> (+33.60%) ⬆️
tinygo 83.14% <100.00%> (+7.74%) ⬆️

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.

Err(err).
Msg("Invalid value")
// If the variable doesn't exist, we would need to raise an error. Otherwise, it should be the same value.
if strings.HasPrefix(value[1:], "tx.") {
Copy link
Member

@jcchavezs jcchavezs Aug 5, 2024

Choose a reason for hiding this comment

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

shouldn't this be %{tx. instead of tx. I don't see any of the tests having tx. as prefix removing the first byte.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is either resolve to the value or stays as tx.missingValue.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's the value: Screenshot 2024-08-05 at 2 38 24 PM

Copy link
Member

Choose a reason for hiding this comment

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

I see. It is still not clear to me how we should deal with the interpolation error in this code path. Let me check it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @jcchavezs ,
Any update on how this error could be handled?

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Ok I found the issue, when we compile a macro e.g. %{tx.var}, the text for the macro becomes tx.var and not %{tx.var} and when the key does not exist we return the text which in this case is tx.var. I will discuss that over another PR.

@jcchavezs
Copy link
Member

thanks, please update this line https://github.com/corazawaf/coraza/pull/1125/files#diff-4f480854f968ff92545ff3bc611fb34a15a657f6caf11dc203c64b76c0861827R148 with the appropriate comment.

name: "Non Numerical Operation - If the value starts with -",
init: "TX.newvar=----expected_value",
expectInvalidSyntaxError: false,
},
Copy link
Member

Choose a reason for hiding this comment

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

should we include expectNewVarValue in the test swell?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@jcchavezs
Copy link
Member

Sorry for the delay. Prioritizing this for now.

@jcchavezs jcchavezs merged commit 3904ccc into corazawaf:main Sep 27, 2024
8 checks passed
@jcchavezs jcchavezs mentioned this pull request Sep 27, 2024
4 tasks
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