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

feat(transaction): data type prediction for lazy predictions #1194

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Merge branch 'main' into datatype_prediction
  • Loading branch information
piyushroshan authored Nov 7, 2024
commit acbd6716e7bd7954c7dc04305d081d829b773881
10 changes: 6 additions & 4 deletions internal/corazawaf/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@
}

// in the most common scenario filteredMatches length will be
// the same as matches length, so we avoid allocating per result
filteredMatches := make([]experimentalTypes.MatchData, 0, len(matches))

// the same as matches length, so we avoid allocating per result.
// We reuse the matches slice to store filtered results avoiding extra allocation.
filteredCount := 0
for _, c := range matches {
isException := false
lkey := strings.ToLower(c.Key())
Expand All @@ -601,13 +601,15 @@
}
}
if !isException {
filteredMatches = append(filteredMatches, c.(experimentalTypes.MatchData))
matches[filteredCount] = c
filteredCount++
}
}
matches = matches[:filteredCount]

if rv.Count {
count := len(filteredMatches)

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / lint

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / lint

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 611 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: filteredMatches
filteredMatches = []experimentalTypes.MatchData{

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / lint

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / lint

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 612 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: filteredMatches
&corazarules.MatchData{
Variable_: rv.Variable,
Key_: rv.KeyStr,
Expand All @@ -615,7 +617,7 @@
},
}
}
return filteredMatches

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / lint

undefined: filteredMatches) (typecheck)

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / lint

undefined: filteredMatches) (typecheck)

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, 0.33.0, ubuntu-latest)

undefined: filteredMatches

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: filteredMatches

Check failure on line 620 in internal/corazawaf/transaction.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: filteredMatches
}

// RemoveRuleTargetByID Removes the VARIABLE:KEY from the rule ID
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.