Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/nullify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ attack_surface:
hosts: [example.com, prod.hosting.com, 10.11.12.13, 10.0.0.*]
include_only:
- hosts: [live.prod.hosting.com]
transport_protocols: [tcp]
ports: [80, 443]
http:
methods: [GET, POST]
paths: [/main, /api/**/create]
Expand Down
28 changes: 16 additions & 12 deletions pkg/merger/merger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,18 +373,20 @@ func TestMergeConfigFiles(t *testing.T) {
Enable: true,
EnableDNSEnumeration: true,
Hosts: []string{"example.com", "prod.hosting.com", "10.11.12.13", "10.0.0.*"},
IncludeOnly: []models.AttackSurfaceIncludeOnly{
IncludeOnly: []models.AttackSurfaceScopingRule{
{
Hosts: []string{"live.prod.hosting.com"},
HTTP: &models.HTTPAttackSurfaceIncludeOnly{
Hosts: []string{"live.prod.hosting.com"},
TransportProtocols: []string{"tcp"},
Ports: []string{"80", "443"},
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Methods: []string{"GET", "POST"},
Paths: []string{"/main", "/api/**/create"},
},
},
},
Ignore: []models.AttackSurfaceIgnore{
Ignore: []models.AttackSurfaceScopingRule{
{
HTTP: &models.HTTPAttackSurfaceIgnore{
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Methods: []string{"DELETE"},
},
},
Expand All @@ -398,7 +400,7 @@ func TestMergeConfigFiles(t *testing.T) {
},
{
Hosts: []string{"dev.*", "staging.*"},
HTTP: &models.HTTPAttackSurfaceIgnore{
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Paths: []string{"/auth"},
Methods: []string{"POST"},
},
Expand All @@ -416,18 +418,20 @@ func TestMergeConfigFiles(t *testing.T) {
Enable: true,
EnableDNSEnumeration: true,
Hosts: []string{"example.com", "prod.hosting.com", "10.11.12.13", "10.0.0.*"},
IncludeOnly: []models.AttackSurfaceIncludeOnly{
IncludeOnly: []models.AttackSurfaceScopingRule{
{
Hosts: []string{"live.prod.hosting.com"},
HTTP: &models.HTTPAttackSurfaceIncludeOnly{
Hosts: []string{"live.prod.hosting.com"},
TransportProtocols: []string{"tcp"},
Ports: []string{"80", "443"},
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Methods: []string{"GET", "POST"},
Paths: []string{"/main", "/api/**/create"},
},
},
},
Ignore: []models.AttackSurfaceIgnore{
Ignore: []models.AttackSurfaceScopingRule{
{
HTTP: &models.HTTPAttackSurfaceIgnore{
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Methods: []string{"DELETE"},
},
},
Expand All @@ -441,7 +445,7 @@ func TestMergeConfigFiles(t *testing.T) {
},
{
Hosts: []string{"dev.*", "staging.*"},
HTTP: &models.HTTPAttackSurfaceIgnore{
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Paths: []string{"/auth"},
Methods: []string{"POST"},
},
Expand Down
27 changes: 8 additions & 19 deletions pkg/models/attack_surface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,18 @@ type AttackSurface struct {
Enable bool `yaml:"enable"`
EnableDNSEnumeration bool `yaml:"enable_dns_enumeration"`
Hosts []string `yaml:"hosts,omitempty"`
IncludeOnly []AttackSurfaceIncludeOnly `yaml:"include_only,omitempty"`
Ignore []AttackSurfaceIgnore `yaml:"ignore,omitempty"`
IncludeOnly []AttackSurfaceScopingRule `yaml:"include_only,omitempty"`
Ignore []AttackSurfaceScopingRule `yaml:"ignore,omitempty"`
}

type AttackSurfaceIncludeOnly struct {
Hosts []string `yaml:"hosts,omitempty"`
HTTP *HTTPAttackSurfaceIncludeOnly `yaml:"http,omitempty"`
type AttackSurfaceScopingRule struct {
Hosts []string `yaml:"hosts,omitempty"`
TransportProtocols []string `yaml:"transport_protocols,omitempty"`
Ports []string `yaml:"ports,omitempty"`
HTTP *HTTPAttackSurfaceScopingRuleHTTP `yaml:"http,omitempty"`
}

type HTTPAttackSurfaceIncludeOnly struct {
Methods []string `yaml:"methods,omitempty"`
Paths []string `yaml:"paths,omitempty"`
}

type AttackSurfaceIgnore struct {
// empty fields are equivalent to *
Hosts []string `yaml:"hosts,omitempty"`
TransportProtocols []string `yaml:"transport_protocols,omitempty"`
Ports []string `yaml:"ports,omitempty"`
HTTP *HTTPAttackSurfaceIgnore `yaml:"http,omitempty"`
}

type HTTPAttackSurfaceIgnore struct {
type HTTPAttackSurfaceScopingRuleHTTP struct {
Methods []string `yaml:"methods,omitempty"`
Paths []string `yaml:"paths,omitempty"`
}
14 changes: 8 additions & 6 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,20 @@ func TestIntegration(t *testing.T) {
Enable: true,
EnableDNSEnumeration: true,
Hosts: []string{"example.com", "prod.hosting.com", "10.11.12.13", "10.0.0.*"},
IncludeOnly: []models.AttackSurfaceIncludeOnly{
IncludeOnly: []models.AttackSurfaceScopingRule{
{
Hosts: []string{"live.prod.hosting.com"},
HTTP: &models.HTTPAttackSurfaceIncludeOnly{
Hosts: []string{"live.prod.hosting.com"},
TransportProtocols: []string{"tcp"},
Ports: []string{"80", "443"},
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Methods: []string{"GET", "POST"},
Paths: []string{"/main", "/api/**/create"},
},
},
},
Ignore: []models.AttackSurfaceIgnore{
Ignore: []models.AttackSurfaceScopingRule{
{
HTTP: &models.HTTPAttackSurfaceIgnore{
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Methods: []string{"DELETE"},
},
},
Expand All @@ -190,7 +192,7 @@ func TestIntegration(t *testing.T) {
},
{
Hosts: []string{"dev.*", "staging.*"},
HTTP: &models.HTTPAttackSurfaceIgnore{
HTTP: &models.HTTPAttackSurfaceScopingRuleHTTP{
Paths: []string{"/auth"},
Methods: []string{"POST"},
},
Expand Down
2 changes: 2 additions & 0 deletions tests/nullify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ attack_surface:
hosts: [example.com, prod.hosting.com, 10.11.12.13, 10.0.0.*]
include_only:
- hosts: [live.prod.hosting.com]
transport_protocols: [tcp]
ports: [80, 443]
http:
methods: [GET, POST]
paths: [/main, /api/**/create]
Expand Down