From 9ae74a23122c50f735553b7df57e76ba65cf1332 Mon Sep 17 00:00:00 2001 From: Matteo Pace Date: Mon, 9 Dec 2024 22:12:24 +0100 Subject: [PATCH] adds regex description --- waflog/read.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/waflog/read.go b/waflog/read.go index 1191476..dc07569 100644 --- a/waflog/read.go +++ b/waflog/read.go @@ -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)