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 string type for current token and fingerprint #10

Merged
merged 7 commits into from
Sep 13, 2022

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Sep 13, 2022

  • string for current token avoids copying, it is always just a slice into the input
  • Most logic use string operations so using a string for both reduces intermediate conversions to string

After

goos: darwin
goarch: arm64
pkg: github.com/corazawaf/libinjection-go
BenchmarkSQLiDriver
BenchmarkSQLiDriver/sqli
BenchmarkSQLiDriver/sqli-10         	   32025	     35962 ns/op	   49568 B/op	     297 allocs/op
BenchmarkSQLiDriver/folding
BenchmarkSQLiDriver/folding-10      	   12946	     93955 ns/op	   69889 B/op	    1718 allocs/op
BenchmarkSQLiDriver/tokens
BenchmarkSQLiDriver/tokens-10       	    6902	    165803 ns/op	  149562 B/op	    3689 allocs/op
PASS

Before

goos: darwin
goarch: arm64
pkg: github.com/corazawaf/libinjection-go
BenchmarkSQLiDriver
BenchmarkSQLiDriver/sqli
BenchmarkSQLiDriver/sqli-10         	   29260	     40245 ns/op	   65665 B/op	     320 allocs/op
BenchmarkSQLiDriver/folding
BenchmarkSQLiDriver/folding-10      	   12258	     98190 ns/op	   89521 B/op	    1841 allocs/op
BenchmarkSQLiDriver/tokens
BenchmarkSQLiDriver/tokens-10       	    6506	    179106 ns/op	  191738 B/op	    4136 allocs/op
PASS

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2022

Codecov Report

Base: 89.33% // Head: 89.28% // Decreases project coverage by -0.04% ⚠️

Coverage data is based on head (39b01fb) compared to base (05da3bd).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #10      +/-   ##
==========================================
- Coverage   89.33%   89.28%   -0.05%     
==========================================
  Files           8        8              
  Lines        1528     1521       -7     
==========================================
- Hits         1365     1358       -7     
  Misses        142      142              
  Partials       21       21              
Impacted Files Coverage Δ
sqli.go 96.52% <100.00%> (-0.01%) ⬇️
sqli_helpers.go 95.74% <100.00%> (ø)
sqli_parse.go 99.25% <100.00%> (ø)
sqli_token.go 100.00% <100.00%> (ø)

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.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jcchavezs
Copy link
Member

jcchavezs commented Sep 13, 2022

Merging this as:
0. no API changes

  1. changes look great
  2. performance improved
  3. Repo has good coverage level

If anything should change we can take care in a next PR.

@jcchavezs jcchavezs merged commit 6df74d7 into corazawaf:master Sep 13, 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