commit for version used in evaluation of thesis
This commit is contained in:
commit
72635dc7b9
27 changed files with 6084 additions and 0 deletions
32
internal/drain3/masking.go
Normal file
32
internal/drain3/masking.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Package drain3 provides log stripping via regex-based masking templates which
|
||||
// sits in front of Drain3 template mining.
|
||||
package drain3
|
||||
|
||||
import (
|
||||
"codeberg.org/pata1704/guenther/internal/config"
|
||||
)
|
||||
|
||||
// ApplyMasking applies all MaskingPatterns sequentially to line.
|
||||
//
|
||||
// For each pattern with a non-empty Name, capture group 1 of the regex is
|
||||
// stored in params before the match is replaced with mp.Replace.
|
||||
// Patterns without a Name only mask; they never write to params.
|
||||
//
|
||||
// All patterns are pre-compiled via config.Compile at startup;
|
||||
// no compilation happens in this hot-path function.
|
||||
func ApplyMasking(line string, patterns []config.MaskingPattern) (masked string, params map[string]string) {
|
||||
params = make(map[string]string, len(patterns))
|
||||
masked = line
|
||||
for _, mp := range patterns {
|
||||
if mp.Re == nil {
|
||||
continue
|
||||
}
|
||||
if mp.Name != "" {
|
||||
if m := mp.Re.FindStringSubmatch(masked); len(m) > 1 {
|
||||
params[mp.Name] = m[1]
|
||||
}
|
||||
}
|
||||
masked = mp.Re.ReplaceAllString(masked, mp.Replace)
|
||||
}
|
||||
return masked, params
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue