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

Use lookup table for byte range validation #490

Merged
merged 4 commits into from
Nov 2, 2022

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Nov 2, 2022

I realized this can be optimized further since we only validate bytes, so a small 256-byte array is enough to validate quickly.

After

goos: darwin
goarch: arm64
pkg: github.com/corazawaf/coraza/v3/operators
BenchmarkValidateByteRange
BenchmarkValidateByteRange-10    	100000000	        10.36 ns/op
PASS

Before

goos: darwin
goarch: arm64
pkg: github.com/corazawaf/coraza/v3/operators
BenchmarkValidateByteRange
BenchmarkValidateByteRange-10    	15429932	        70.64 ns/op
PASS

@anuraaga anuraaga requested a review from a team as a code owner November 2, 2022 01:25
@codecov-commenter
Copy link

Codecov Report

Base: 72.60% // Head: 72.58% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (5593d40) compared to base (9329b1d).
Patch coverage: 53.84% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           v3/dev     #490      +/-   ##
==========================================
- Coverage   72.60%   72.58%   -0.02%     
==========================================
  Files         146      146              
  Lines        6851     6843       -8     
==========================================
- Hits         4974     4967       -7     
+ Misses       1608     1606       -2     
- Partials      269      270       +1     
Flag Coverage Δ
default 72.50% <53.84%> (-0.02%) ⬇️
tinygo 71.18% <53.84%> (-0.03%) ⬇️

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

Impacted Files Coverage Δ
operators/validate_byte_range.go 47.27% <53.84%> (-5.11%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@anuraaga anuraaga merged commit ca9cb38 into corazawaf:v3/dev Nov 2, 2022
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.

3 participants