Skip to content

Commit 7d20957

Browse files
add tests for attack surface monitoring
1 parent ed6e15e commit 7d20957

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

examples/nullify.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ integrations:
110110
assignee:
111111
id: 123456:abcd1234-abcd-1234-abcd-abcde12345666
112112
name: John Smith
113+
attack_surface:
114+
enable: true
115+
enable_dns_traversal: false
116+
domain_names: [172.36.255.7,example.com]
117+
ignore_domain_names: []

pkg/merger/merger_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,30 @@ func TestMergeJira(t *testing.T) {
692692
},
693693
},
694694
},
695+
{
696+
name: "only global config for attack surface monitoring",
697+
globalConfig: &models.Configuration{
698+
AttackSurface: models.AttackSurface{
699+
Enable: true,
700+
EnableDNSTraversal: true,
701+
DomainNames: []string{"example.com"},
702+
IgnoreDomainNames: []string{"example2.com"},
703+
},
704+
},
705+
repoConfig: nil,
706+
expected: &models.Configuration{
707+
EnablePullRequestReviews: models.Bool(true),
708+
EnableIssueDashboards: models.Bool(true),
709+
SeverityThreshold: parser.DefaultSeverityThreshold,
710+
PriorityThreshold: parser.DefaultPriorityThreshold,
711+
AttackSurface: models.AttackSurface{
712+
Enable: true,
713+
EnableDNSTraversal: true,
714+
DomainNames: []string{"example.com"},
715+
IgnoreDomainNames: []string{"example2.com"},
716+
},
717+
},
718+
},
695719
} {
696720
t.Run(scenario.name, func(t *testing.T) {
697721
config := MergeConfigFiles(parser.NewDefaultConfig(), scenario.globalConfig, scenario.repoConfig)

pkg/models/attack_surface.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package models
22

33
type AttackSurface struct {
44
// global only
5-
Enable bool `yaml:"enable,omitempty"`
6-
EnableDNSTraversal bool `yaml:"enable_dns_traversal,omitempty"`
5+
Enable bool `yaml:"enable"`
6+
EnableDNSTraversal bool `yaml:"enable_dns_traversal"`
77
DomainNames []string `yaml:"domain_names,omitempty"`
88
IgnoreDomainNames []string `yaml:"ignore_domain_names,omitempty"`
99
}

pkg/models/models.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ type Configuration struct {
1818
Integrations Integrations `yaml:"integrations,omitempty"`
1919

2020
// features
21-
Code Code `yaml:"code,omitempty"`
22-
Dependencies Dependencies `yaml:"dependencies,omitempty"`
23-
Secrets Secrets `yaml:"secrets,omitempty"`
24-
AttackSurface AttackSurface `yaml:"attack_surface,omitempty"`
21+
Code Code `yaml:"code"`
22+
Dependencies Dependencies `yaml:"dependencies"`
23+
Secrets Secrets `yaml:"secrets"`
24+
AttackSurface AttackSurface `yaml:"attack_surface"`
2525

2626
// TODO deprecate
2727
SecretsWhitelist []string `yaml:"secrets_whitelist,omitempty"`

tests/integration_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ func TestIntegration(t *testing.T) {
153153
OnFixTransition: "Done",
154154
},
155155
},
156+
AttackSurface: models.AttackSurface{
157+
Enable: true,
158+
EnableDNSTraversal: true,
159+
DomainNames: []string{"172.36.255.7", "example.com"},
160+
IgnoreDomainNames: []string{"jira.example.com"},
161+
},
156162
}
157163

158164
config, err := parser.LoadFromFile("nullify.yaml")

tests/nullify.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,8 @@ integrations:
9494
severity_threshold: HIGH
9595
priority_threshold: IMPORTANT
9696
on_fix_transition: Done
97+
attack_surface:
98+
enable: true
99+
enable_dns_traversal: true
100+
domain_names: [172.36.255.7,example.com]
101+
ignore_domain_names: [jira.example.com]

0 commit comments

Comments
 (0)