Skip to content

Commit 955e992

Browse files
author
Vikranth Subramanian
committed
more finetuning and modifications for aws integration
1 parent b410152 commit 955e992

File tree

6 files changed

+80
-39
lines changed

6 files changed

+80
-39
lines changed

pkg/merger/merger.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,28 @@ func MergeConfigFiles(
7979
}
8080
}
8181

82+
if extraConfig.Integrations.AWS != nil {
83+
if config.Integrations.AWS == nil {
84+
config.Integrations.AWS = extraConfig.Integrations.AWS
85+
} else {
86+
config.Integrations.AWS.Enable = extraConfig.Integrations.AWS.Enable
87+
88+
config.Integrations.AWS.RoleNameToAssume = extraConfig.Integrations.AWS.RoleNameToAssume
89+
config.Integrations.AWS.PrimaryAccountID = extraConfig.Integrations.AWS.PrimaryAccountID
90+
config.Integrations.AWS.PrimaryRegion = extraConfig.Integrations.AWS.PrimaryRegion
91+
92+
if extraConfig.Integrations.AWS.PrimaryRegion != "" {
93+
config.Integrations.AWS.PrimaryRegion = extraConfig.Integrations.AWS.PrimaryRegion
94+
}
95+
if extraConfig.Integrations.AWS.TargetRegions != nil {
96+
config.Integrations.AWS.TargetRegions = extraConfig.Integrations.AWS.TargetRegions
97+
}
98+
if extraConfig.Integrations.AWS.TargetAccounts != nil {
99+
config.Integrations.AWS.TargetAccounts = extraConfig.Integrations.AWS.TargetAccounts
100+
}
101+
}
102+
}
103+
82104
if len(extraConfig.IgnoreDirs) > 0 {
83105
config.IgnoreDirs = extraConfig.IgnoreDirs
84106
}

pkg/merger/merger_test.go

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ func TestMergeConfigFiles(t *testing.T) {
8282
SeverityThreshold: models.SeverityHigh,
8383
PriorityThreshold: models.PriorityImportant,
8484
},
85+
AWS: &models.AWS{
86+
Enable: true,
87+
RoleNameToAssume: "nullify-role",
88+
PrimaryAccountID: "123456789012",
89+
PrimaryRegion: "ap-southeast-2",
90+
TargetRegions: &[]string{"ap-southeast-2", "us-east-2"},
91+
TargetAccounts: &[]string{"123456789012", "123456789013"},
92+
},
8593
},
8694
},
8795
expected: &models.Configuration{
@@ -140,6 +148,14 @@ func TestMergeConfigFiles(t *testing.T) {
140148
SeverityThreshold: models.SeverityHigh,
141149
PriorityThreshold: models.PriorityImportant,
142150
},
151+
AWS: &models.AWS{
152+
Enable: true,
153+
RoleNameToAssume: "nullify-role",
154+
PrimaryAccountID: "123456789012",
155+
PrimaryRegion: "ap-southeast-2",
156+
TargetRegions: &[]string{"ap-southeast-2", "us-east-2"},
157+
TargetAccounts: &[]string{"123456789012", "123456789013"},
158+
},
143159
},
144160
},
145161
},
@@ -204,6 +220,14 @@ func TestMergeConfigFiles(t *testing.T) {
204220
Low: "low",
205221
},
206222
},
223+
AWS: &models.AWS{
224+
Enable: true,
225+
RoleNameToAssume: "nullify-role",
226+
PrimaryAccountID: "123456789012",
227+
PrimaryRegion: "ap-southeast-2",
228+
TargetRegions: &[]string{"ap-southeast-2", "us-east-2"},
229+
TargetAccounts: &[]string{"123456789012", "123456789013"},
230+
},
207231
},
208232
},
209233
repoConfig: nil,
@@ -269,6 +293,14 @@ func TestMergeConfigFiles(t *testing.T) {
269293
Low: "low",
270294
},
271295
},
296+
AWS: &models.AWS{
297+
Enable: true,
298+
RoleNameToAssume: "nullify-role",
299+
PrimaryAccountID: "123456789012",
300+
PrimaryRegion: "ap-southeast-2",
301+
TargetRegions: &[]string{"ap-southeast-2", "us-east-2"},
302+
TargetAccounts: &[]string{"123456789012", "123456789013"},
303+
},
272304
},
273305
},
274306
},
@@ -423,13 +455,6 @@ func TestMergeConfigFiles(t *testing.T) {
423455
globalConfig: &models.Configuration{
424456
AttackSurface: &models.AttackSurface{
425457
Enable: true,
426-
AWSIntegration: &models.AWSIntegration{
427-
Enable: true,
428-
PrimaryAccountID: "111111111111",
429-
PrimaryRegion: "ap-southeast-2",
430-
TargetRegions: &[]string{"ap-southeast-1", "us-east-2"},
431-
TargetAccounts: &[]string{"222222222222", "333333333333"},
432-
},
433458
},
434459
},
435460
repoConfig: nil,
@@ -440,13 +465,6 @@ func TestMergeConfigFiles(t *testing.T) {
440465
PriorityThreshold: parser.DefaultPriorityThreshold,
441466
AttackSurface: &models.AttackSurface{
442467
Enable: true,
443-
AWSIntegration: &models.AWSIntegration{
444-
Enable: true,
445-
PrimaryAccountID: "111111111111",
446-
PrimaryRegion: "ap-southeast-2",
447-
TargetRegions: &[]string{"ap-southeast-1", "us-east-2"},
448-
TargetAccounts: &[]string{"222222222222", "333333333333"},
449-
},
450468
},
451469
},
452470
},

pkg/models/attack_surface.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,11 @@ type AttackSurface struct {
44
// global only
55
Enable bool `yaml:"enable"`
66
EnableDNSEnumeration bool `yaml:"enable_dns_enumeration"`
7-
AWSIntegration *AWSIntegration `yaml:"aws_integration"`
87
Hosts []string `yaml:"hosts,omitempty"`
98
IncludeOnly []AttackSurfaceIncludeOnly `yaml:"include_only,omitempty"`
109
Ignore []AttackSurfaceIgnore `yaml:"ignore,omitempty"`
1110
}
1211

13-
type AWSIntegration struct {
14-
Enable bool `yaml:"enable"`
15-
RoleNameToAssume string `yaml:"role_name_to_assume"`
16-
PrimaryAccountID string `yaml:"primary_account_id,omitempty"`
17-
PrimaryRegion string `yaml:"primary_region,omitempty"`
18-
TargetRegions *[]string `yaml:"target_regions,omitempty"`
19-
TargetAccounts *[]string `yaml:"target_accounts,omitempty"`
20-
}
21-
2212
type AttackSurfaceIncludeOnly struct {
2313
Hosts []string `yaml:"hosts,omitempty"`
2414
HTTP *HTTPAttackSurfaceIncludeOnly `yaml:"http,omitempty"`

pkg/models/integrations.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package models
22

33
type Integrations struct {
44
Jira *Jira `yaml:"jira,omitempty"`
5+
AWS *AWS `yaml:"aws,omitempty"`
56
}
67

78
type Jira struct {
@@ -31,3 +32,12 @@ type Assignee struct {
3132
Name string `yaml:"name,omitempty"`
3233
ID string `yaml:"id,omitempty"`
3334
}
35+
36+
type AWS struct {
37+
Enable bool `yaml:"enable"`
38+
RoleNameToAssume string `yaml:"role_name_to_assume"`
39+
PrimaryAccountID string `yaml:"primary_account_id"`
40+
PrimaryRegion string `yaml:"primary_region"`
41+
TargetRegions *[]string `yaml:"target_regions,omitempty"`
42+
TargetAccounts *[]string `yaml:"target_accounts,omitempty"`
43+
}

tests/integration_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ func TestIntegration(t *testing.T) {
152152
PriorityThreshold: models.PriorityImportant,
153153
OnFixTransition: "Done",
154154
},
155+
AWS: &models.AWS{
156+
Enable: true,
157+
RoleNameToAssume: "nullify-role",
158+
PrimaryAccountID: "123456789012",
159+
PrimaryRegion: "ap-southeast-2",
160+
TargetRegions: &[]string{"ap-southeast-2", "us-east-2"},
161+
TargetAccounts: &[]string{"123456789012", "123456789013"},
162+
},
155163
},
156164
AttackSurface: &models.AttackSurface{
157165
Enable: true,
@@ -188,14 +196,6 @@ func TestIntegration(t *testing.T) {
188196
},
189197
},
190198
},
191-
AWSIntegration: &models.AWSIntegration{
192-
Enable: true,
193-
PrimaryAccountID: "123456789012",
194-
PrimaryRegion: "ap-southeast-2",
195-
TargetRegions: &[]string{"ap-southeast-2", "us-east-2"},
196-
TargetAccounts: &[]string{"123456789012", "123456789013"},
197-
RoleNameToAssume: "nullify-role",
198-
},
199199
},
200200
}
201201

tests/nullify.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ integrations:
9494
severity_threshold: HIGH
9595
priority_threshold: IMPORTANT
9696
on_fix_transition: Done
97+
aws:
98+
enable: true
99+
role_name_to_assume: nullify-role
100+
primary_account_id: 123456789012
101+
primary_region: ap-southeast-2
102+
target_regions: [ap-southeast-2, us-east-2]
103+
target_accounts: [123456789012, 123456789013]
97104
attack_surface:
98105
enable: true
99106
enable_dns_enumeration: true
@@ -114,10 +121,4 @@ attack_surface:
114121
http:
115122
paths: [/auth]
116123
methods: [POST]
117-
aws_integration:
118-
enable: true
119-
role_name_to_assume: nullify-role
120-
primary_account_id: 123456789012
121-
primary_region: ap-southeast-2
122-
target_regions: [ap-southeast-2, us-east-2]
123-
target_accounts: [123456789012, 123456789013]
124+

0 commit comments

Comments
 (0)