Skip to content

Commit

Permalink
test: check that XOR key is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
secDre4mer authored and hillu committed Dec 12, 2023
1 parent 68e8499 commit 07fb25c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,23 @@ func TestTooManyMatches(t *testing.T) {
t.Errorf("too many matches does not contain regularly matching string: %v", cb.tooManyMatches)
}
}

func TestXorKey(t *testing.T) {
var m MatchRules
r := makeRules(t, `
rule t { strings: $s1 = "\x00\x01\x02\x03" xor condition: all of them }
`)

if err := r.ScanMem([]byte{0x10, 0x11, 0x12, 0x13}, 0, 0, &m); err != nil {
t.Error(err)
}
if len(m) != 1 {
t.Fatalf("expected 1 match, got %d", len(m))
}
if len(m[0].Strings) != 1 {
t.Fatalf("expected 1 string, got %d", len(m[0].Strings))
}
if m[0].Strings[0].XorKey != 0x10 {
t.Fatalf("expected xor key 0x10, got 0x%x", m[0].Strings[0].XorKey)
}
}

0 comments on commit 07fb25c

Please sign in to comment.