logic_test.go 1.2 KB
Newer Older
1
2
3
package logic

import (
4
	"os"
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
	"strings"
	"testing"
	"time"
)

const (
	Output = `----------- SCAN SUMMARY -----------
Infected files: 0
Time: 0.981 sec (0 m 0 s)
Start Date: 2026:02:14 09:39:02
End Date:   2026:02:14 09:39:03`
)

func TestRegext(t *testing.T) {
	lines := strings.Split(Output, "\n")
	for _, i := range lines {
		if ReInfectedFile.MatchString(i) {
			f := ReInfectedFile.FindStringSubmatch(i)
			for _, ff := range f {
				t.Log(ff)
			}
		}
	}
}

func TestScanFile(t *testing.T) {
	target := "./hycusmutool"
	start := time.Now()
	have, err := ScanFile(target)
	dua := time.Since(start)

	if have {
		t.Logf("%s is bd", target)
	}

	t.Logf("used time: %dms", dua.Milliseconds())
	if err != nil {
		t.Error(err)
	}
}

func TestParseInt(t *testing.T) {
	i, err := ParseInt("abc")
	if err != nil {
		t.Error(err)
	}
	t.Logf("%d", i)
}
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

func TestPids(t *testing.T) {
	content, err := os.ReadFile("../../../asset/sftp.log")
	if err != nil {
		t.Error(err)
	}
	lines := strings.Split(string(content), "\n")
	start := time.Now()
	for _, v := range lines {
		if len(v) > 0 {
			_, err := ParseSftpLog(v)
			if err != nil {
				t.Error(err)
			}
		}
	}
	tt := time.Since(start)
	t.Logf("%d ms", tt.Milliseconds())
}