Skip to content

Commit 0a08b8c

Browse files
committed
fix(filter): Allow interpolation for fields with underscore
1 parent a367399 commit 0a08b8c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pkg/filter/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func (f *filter) GetSequence() *ql.Sequence { return f.seq }
350350
// which refers to the event in particular sequence stage. Otherwise, the modifier is
351351
// a well-known field name prepended with the `%` symbol.
352352
func InterpolateFields(s string, evts []*kevent.Kevent) string {
353-
var fieldsReplRegexp = regexp.MustCompile(`%([1-9]?)\.?([a-z0-9A-Z\[\].]+)`)
353+
var fieldsReplRegexp = regexp.MustCompile(`%([1-9]?)\.?([a-z0-9A-Z\[\]._]+)`)
354354
matches := fieldsReplRegexp.FindAllStringSubmatch(s, -1)
355355
r := s
356356
if len(matches) == 0 {

pkg/filter/filter_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,21 @@ func TestInterpolateFields(t *testing.T) {
13251325
},
13261326
},
13271327
},
1328+
{
1329+
original: "Suspicious thread start module %thread.start_address.module",
1330+
interpolated: "Suspicious thread start module C:\\Windows\\System32\\vault.dll",
1331+
evts: []*kevent.Kevent{
1332+
{
1333+
Type: ktypes.CreateThread,
1334+
Category: ktypes.Thread,
1335+
Name: "CreateThread",
1336+
PID: 1023,
1337+
Kparams: kevent.Kparams{
1338+
kparams.StartAddressModule: {Name: kparams.StartAddressModule, Type: kparams.UnicodeString, Value: "C:\\Windows\\System32\\vault.dll"},
1339+
},
1340+
},
1341+
},
1342+
},
13281343
{
13291344
original: `Detected an attempt by <code>%1.ps.name</code> process to access
13301345
and read the memory of the <b>Local Security And Authority Subsystem Service</b>

0 commit comments

Comments
 (0)