forked from saferwall/pe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanomaly_test.go
53 lines (45 loc) · 1.24 KB
/
anomaly_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2021 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
package pe
import (
"testing"
)
func TestGetAnomalies(t *testing.T) {
tests := []struct {
in string
out []string
}{
{
getAbsoluteFilePath(
"test/050708404553416d103652a7ca1f887ab81f533a019a0eeff0e6bb460a202cde"),
[]string{AnoReservedDataDirectoryEntry},
},
{
getAbsoluteFilePath(
"test/0585495341e0ffaae1734acb78708ff55cd3612d844672d37226ef63d12652d0"),
[]string{AnoAddressOfEntryPointNull, AnoMajorSubsystemVersion},
},
}
for _, tt := range tests {
t.Run(tt.in, func(t *testing.T) {
file, err := New(tt.in, &Options{})
if err != nil {
t.Fatalf("New(%s) failed, reason: %v", tt.in, err)
}
err = file.Parse()
if err != nil {
t.Fatalf("Parse(%s) failed, reason: %v", tt.in, err)
}
err = file.GetAnomalies()
if err != nil {
t.Fatalf("GetAnomalies(%s) failed, reason: %v", tt.in, err)
}
for _, ano := range tt.out {
if !stringInSlice(ano, file.Anomalies) {
t.Errorf("anomaly(%s) not found in anomalies, got: %v", ano, file.Anomalies)
}
}
})
}
}