Skip to content

Commit 1fd663c

Browse files
parity between includeOnly and ignore
1 parent 25a5430 commit 1fd663c

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

examples/nullify.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ attack_surface:
122122
hosts: [example.com, prod.hosting.com, 10.11.12.13, 10.0.0.*]
123123
include_only:
124124
- hosts: [live.prod.hosting.com]
125+
transport_protocols: [tcp]
126+
ports: [80, 443]
125127
http:
126128
methods: [GET, POST]
127129
paths: [/main, /api/**/create]

pkg/merger/merger_test.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,20 @@ func TestMergeConfigFiles(t *testing.T) {
373373
Enable: true,
374374
EnableDNSEnumeration: true,
375375
Hosts: []string{"example.com", "prod.hosting.com", "10.11.12.13", "10.0.0.*"},
376-
IncludeOnly: []models.AttackSurfaceIncludeOnly{
376+
IncludeOnly: []models.AttackSurfaceScopingRule{
377377
{
378-
Hosts: []string{"live.prod.hosting.com"},
379-
HTTP: &models.HTTPAttackSurfaceIncludeOnly{
378+
Hosts: []string{"live.prod.hosting.com"},
379+
TransportProtocols: []string{"tcp"},
380+
Ports: []string{"80", "443"},
381+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
380382
Methods: []string{"GET", "POST"},
381383
Paths: []string{"/main", "/api/**/create"},
382384
},
383385
},
384386
},
385-
Ignore: []models.AttackSurfaceIgnore{
387+
Ignore: []models.AttackSurfaceScopingRule{
386388
{
387-
HTTP: &models.HTTPAttackSurfaceIgnore{
389+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
388390
Methods: []string{"DELETE"},
389391
},
390392
},
@@ -398,7 +400,7 @@ func TestMergeConfigFiles(t *testing.T) {
398400
},
399401
{
400402
Hosts: []string{"dev.*", "staging.*"},
401-
HTTP: &models.HTTPAttackSurfaceIgnore{
403+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
402404
Paths: []string{"/auth"},
403405
Methods: []string{"POST"},
404406
},
@@ -416,18 +418,20 @@ func TestMergeConfigFiles(t *testing.T) {
416418
Enable: true,
417419
EnableDNSEnumeration: true,
418420
Hosts: []string{"example.com", "prod.hosting.com", "10.11.12.13", "10.0.0.*"},
419-
IncludeOnly: []models.AttackSurfaceIncludeOnly{
421+
IncludeOnly: []models.AttackSurfaceScopingRule{
420422
{
421-
Hosts: []string{"live.prod.hosting.com"},
422-
HTTP: &models.HTTPAttackSurfaceIncludeOnly{
423+
Hosts: []string{"live.prod.hosting.com"},
424+
TransportProtocols: []string{"tcp"},
425+
Ports: []string{"80", "443"},
426+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
423427
Methods: []string{"GET", "POST"},
424428
Paths: []string{"/main", "/api/**/create"},
425429
},
426430
},
427431
},
428-
Ignore: []models.AttackSurfaceIgnore{
432+
Ignore: []models.AttackSurfaceScopingRule{
429433
{
430-
HTTP: &models.HTTPAttackSurfaceIgnore{
434+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
431435
Methods: []string{"DELETE"},
432436
},
433437
},
@@ -441,7 +445,7 @@ func TestMergeConfigFiles(t *testing.T) {
441445
},
442446
{
443447
Hosts: []string{"dev.*", "staging.*"},
444-
HTTP: &models.HTTPAttackSurfaceIgnore{
448+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
445449
Paths: []string{"/auth"},
446450
Methods: []string{"POST"},
447451
},

pkg/models/attack_surface.go

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,18 @@ type AttackSurface struct {
55
Enable bool `yaml:"enable"`
66
EnableDNSEnumeration bool `yaml:"enable_dns_enumeration"`
77
Hosts []string `yaml:"hosts,omitempty"`
8-
IncludeOnly []AttackSurfaceIncludeOnly `yaml:"include_only,omitempty"`
9-
Ignore []AttackSurfaceIgnore `yaml:"ignore,omitempty"`
8+
IncludeOnly []AttackSurfaceScopingRule `yaml:"include_only,omitempty"`
9+
Ignore []AttackSurfaceScopingRule `yaml:"ignore,omitempty"`
1010
}
1111

12-
type AttackSurfaceIncludeOnly struct {
13-
Hosts []string `yaml:"hosts,omitempty"`
14-
HTTP *HTTPAttackSurfaceIncludeOnly `yaml:"http,omitempty"`
12+
type AttackSurfaceScopingRule struct {
13+
Hosts []string `yaml:"hosts,omitempty"`
14+
TransportProtocols []string `yaml:"transport_protocols,omitempty"`
15+
Ports []string `yaml:"ports,omitempty"`
16+
HTTP *HTTPAttackSurfaceScopingRuleHTTP `yaml:"http,omitempty"`
1517
}
1618

17-
type HTTPAttackSurfaceIncludeOnly struct {
18-
Methods []string `yaml:"methods,omitempty"`
19-
Paths []string `yaml:"paths,omitempty"`
20-
}
21-
22-
type AttackSurfaceIgnore struct {
23-
// empty fields are equivalent to *
24-
Hosts []string `yaml:"hosts,omitempty"`
25-
TransportProtocols []string `yaml:"transport_protocols,omitempty"`
26-
Ports []string `yaml:"ports,omitempty"`
27-
HTTP *HTTPAttackSurfaceIgnore `yaml:"http,omitempty"`
28-
}
29-
30-
type HTTPAttackSurfaceIgnore struct {
19+
type HTTPAttackSurfaceScopingRuleHTTP struct {
3120
Methods []string `yaml:"methods,omitempty"`
3221
Paths []string `yaml:"paths,omitempty"`
3322
}

tests/integration_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,20 @@ func TestIntegration(t *testing.T) {
165165
Enable: true,
166166
EnableDNSEnumeration: true,
167167
Hosts: []string{"example.com", "prod.hosting.com", "10.11.12.13", "10.0.0.*"},
168-
IncludeOnly: []models.AttackSurfaceIncludeOnly{
168+
IncludeOnly: []models.AttackSurfaceScopingRule{
169169
{
170-
Hosts: []string{"live.prod.hosting.com"},
171-
HTTP: &models.HTTPAttackSurfaceIncludeOnly{
170+
Hosts: []string{"live.prod.hosting.com"},
171+
TransportProtocols: []string{"tcp"},
172+
Ports: []string{"80", "443"},
173+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
172174
Methods: []string{"GET", "POST"},
173175
Paths: []string{"/main", "/api/**/create"},
174176
},
175177
},
176178
},
177-
Ignore: []models.AttackSurfaceIgnore{
179+
Ignore: []models.AttackSurfaceScopingRule{
178180
{
179-
HTTP: &models.HTTPAttackSurfaceIgnore{
181+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
180182
Methods: []string{"DELETE"},
181183
},
182184
},
@@ -190,7 +192,7 @@ func TestIntegration(t *testing.T) {
190192
},
191193
{
192194
Hosts: []string{"dev.*", "staging.*"},
193-
HTTP: &models.HTTPAttackSurfaceIgnore{
195+
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
194196
Paths: []string{"/auth"},
195197
Methods: []string{"POST"},
196198
},

tests/nullify.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ attack_surface:
107107
hosts: [example.com, prod.hosting.com, 10.11.12.13, 10.0.0.*]
108108
include_only:
109109
- hosts: [live.prod.hosting.com]
110+
transport_protocols: [tcp]
111+
ports: [80, 443]
110112
http:
111113
methods: [GET, POST]
112114
paths: [/main, /api/**/create]

0 commit comments

Comments
 (0)