Skip to content

Commit

Permalink
adds regex description
Browse files Browse the repository at this point in the history
  • Loading branch information
M4tteoP committed Dec 9, 2024
1 parent 2a7779a commit 9ae74a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions waflog/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ func (ll *FTWLogLines) TriggeredRules() []uint {
ll.triggeredRulesInitialized = true

lines := ll.getMarkedLines()

// This regex provides flexibility in parsing how the rule ID is logged.
// `\[id \\?"(\d+)\\?"\]` supports:
// - [id "999999"]
// - [id \"999999\"] (escaped quotes)
// `"id":\s*"?(\d+)"?` supports:
// - ["id":"999999"]
// - {"id":4}
regex := regexp.MustCompile(`\[id \\?"(\d+)\\?"\]|"id":\s*"?(\d+)"?`)
for _, line := range lines {
log.Trace().Msgf("ftw/waflog: Looking for any rule in '%s'", line)
Expand Down

0 comments on commit 9ae74a2

Please sign in to comment.