/
testing.go
72 lines (62 loc) · 1.63 KB
/
testing.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package config
import (
"github.com/creasty/defaults"
)
const testConfig = `
MongoDB:
ConnectionString: null
AuthenticationMechanism: null
SocketTimeout: 2
TLS:
Enable: false
VerifyCertificate: false
CAFile: null
LogConfig:
LogLevel: 3
RitaLogPath: null
LogToFile: false
LogToDB: true
Bro:
ImportDirectory: null
DBRoot: RITA-TEST
MetaDB: RITA-TEST-MetaDatabase
ImportBuffer: 100000
BlackListed:
myIP.ms: false
MalwareDomains.com: false
MalwareDomainList.com: false
CustomIPBlacklists: []
CustomHostnameBlacklists: []
Beacon:
DefaultConnectionThresh: 24
Strobe:
ConnectionLimit: 250000
Filtering:
AlwaysInclude: ["8.8.8.8/32"]
NeverInclude: ["8.8.4.4/32"]
InternalSubnets: ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"]
`
// LoadTestingConfig loads the hard coded testing config
func LoadTestingConfig(mongoURI string) (*Config, error) {
config := &Config{}
// Initialize table config to the default values
if err := defaults.Set(&config.T); err != nil {
return nil, err
}
// Initialize static config to the default values
if err := defaults.Set(&config.S); err != nil {
return nil, err
}
config.S.MongoDB.ConnectionString = mongoURI
// Deserialize the yaml file contents into the static config
if err := parseStaticConfig([]byte(testConfig), &config.S); err != nil {
return nil, err
}
config.S.Version = "v0.0.0+testing"
config.S.ExactVersion = "v0.0.0+testing"
// Use the static config to initialize the running config
if err := initRunningConfig(&config.S, &config.R); err != nil {
return nil, err
}
return config, nil
}