Skip to content

Commit ba4ff47

Browse files
authored
Merge pull request #130 from BishopFox/fix/network-ports-map-race
Fix concurrent map access race in network-ports module and bump version to 2.0.5
2 parents 1b09258 + 81be56e commit ba4ff47

102 files changed

Lines changed: 1212 additions & 1125 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/autorelease.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515

1616
steps:
1717

18-
- name: Go 1.21
19-
uses: actions/setup-go@v4
18+
- name: Go 1.25
19+
uses: actions/setup-go@v5
2020
with:
21-
go-version: ^1.20
21+
go-version: ^1.25
2222
id: go
2323

2424
- id: install-secret-key
@@ -28,7 +28,7 @@ jobs:
2828
gpg --list-secret-keys --keyid-format LONG
2929
3030
- name: Check Out Code
31-
uses: actions/checkout@v4
31+
uses: actions/checkout@v6
3232

3333
- name: Git Fetch Tags
3434
run: git fetch --prune --unshallow --tags -f
@@ -39,9 +39,6 @@ jobs:
3939

4040

4141
- name: Release binaries
42-
uses: "marvinpinto/action-automatic-releases@latest"
42+
uses: softprops/action-gh-release@v2
4343
with:
44-
repo_token: "${{ secrets.GITHUB_TOKEN }}"
45-
prerelease: false
46-
files: |
47-
./cloudfox/*
44+
files: ./cloudfox/*

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
codespell:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v6
1515
- run: pip install --user codespell
1616
- run: codespell --ignore-words-list="aks,referers,invokable" --skip="*.sum"

aws/access-keys.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (m *AccessKeysModule) getAccessKeysForAllUsers() {
161161
ListUsers, err := sdk.CachedIamListUsers(m.IAMClient, aws.ToString(m.Caller.Account))
162162
if err != nil {
163163
m.modLog.Error(err.Error())
164-
m.CommandCounter.Error++
164+
m.CommandCounter.IncrError()
165165
}
166166

167167
// added this to break out if there no users
@@ -171,7 +171,7 @@ func (m *AccessKeysModule) getAccessKeysForAllUsers() {
171171
results, err := sdk.CachedIamListAccessKeys(m.IAMClient, aws.ToString(m.Caller.Account), aws.ToString(user.UserName))
172172
if err != nil {
173173
m.modLog.Error(err.Error())
174-
m.CommandCounter.Error++
174+
m.CommandCounter.IncrError()
175175
break
176176
}
177177

aws/api-gws.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,19 @@ func (m *ApiGwModule) executeChecks(r string, wg *sync.WaitGroup, semaphore chan
191191
m.modLog.Error(err)
192192
}
193193
if res {
194-
m.CommandCounter.Total++
194+
m.CommandCounter.IncrTotal()
195195
wg.Add(1)
196196
go m.getAPIGatewayAPIsPerRegion(r, wg, semaphore, dataReceiver)
197197

198-
m.CommandCounter.Total++
198+
m.CommandCounter.IncrTotal()
199199
wg.Add(1)
200200
go m.getAPIGatewayVIPsPerRegion(r, wg, semaphore, dataReceiver)
201201

202-
m.CommandCounter.Total++
202+
m.CommandCounter.IncrTotal()
203203
wg.Add(1)
204204
go m.getAPIGatewayv2APIsPerRegion(r, wg, semaphore, dataReceiver)
205205

206-
m.CommandCounter.Total++
206+
m.CommandCounter.IncrTotal()
207207
wg.Add(1)
208208
go m.getAPIGatewayv2VIPsPerRegion(r, wg, semaphore, dataReceiver)
209209
}
@@ -244,7 +244,7 @@ func (m *ApiGwModule) writeLoot(outputDirectory string, verbosity int) string {
244244
// err = os.WriteFile(f, []byte(out), 0644)
245245
// if err != nil {
246246
// m.modLog.Error(err.Error())
247-
// m.CommandCounter.Error++
247+
// m.CommandCounter.IncrError()
248248
// panic(err.Error())
249249
// }
250250

@@ -263,30 +263,30 @@ func (m *ApiGwModule) writeLoot(outputDirectory string, verbosity int) string {
263263

264264
func (m *ApiGwModule) getAPIGatewayAPIsPerRegion(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan ApiGateway) {
265265
defer func() {
266-
m.CommandCounter.Executing--
267-
m.CommandCounter.Complete++
266+
m.CommandCounter.DecrExecuting()
267+
m.CommandCounter.IncrComplete()
268268
wg.Done()
269269

270270
}()
271271
semaphore <- struct{}{}
272272
defer func() {
273273
<-semaphore
274274
}()
275-
// m.CommandCounter.Total++
276-
m.CommandCounter.Pending--
277-
m.CommandCounter.Executing++
275+
// m.CommandCounter.IncrTotal()
276+
m.CommandCounter.DecrPending()
277+
m.CommandCounter.IncrExecuting()
278278
// "PaginationMarker" is a control variable used for output continuity, as AWS return the output in pages.
279279

280280
Items, err := sdk.CachedApiGatewayGetRestAPIs(m.APIGatewayClient, aws.ToString(m.Caller.Account), r)
281281

282282
if err != nil {
283283
m.modLog.Error(err.Error())
284-
m.CommandCounter.Error++
284+
m.CommandCounter.IncrError()
285285
return
286286
}
287287

288288
for _, api := range Items {
289-
m.CommandCounter.Total++
289+
m.CommandCounter.IncrTotal()
290290
for _, endpoint := range m.getEndpointsPerAPIGateway(r, api) {
291291
dataReceiver <- endpoint
292292
}
@@ -295,25 +295,25 @@ func (m *ApiGwModule) getAPIGatewayAPIsPerRegion(r string, wg *sync.WaitGroup, s
295295

296296
func (m *ApiGwModule) getAPIGatewayVIPsPerRegion(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan ApiGateway) {
297297
defer func() {
298-
m.CommandCounter.Executing--
299-
m.CommandCounter.Complete++
298+
m.CommandCounter.DecrExecuting()
299+
m.CommandCounter.IncrComplete()
300300
wg.Done()
301301

302302
}()
303303
semaphore <- struct{}{}
304304
defer func() {
305305
<-semaphore
306306
}()
307-
// m.CommandCounter.Total++
308-
m.CommandCounter.Pending--
309-
m.CommandCounter.Executing++
307+
// m.CommandCounter.IncrTotal()
308+
m.CommandCounter.DecrPending()
309+
m.CommandCounter.IncrExecuting()
310310
// "PaginationMarker" is a control variable used for output continuity, as AWS return the output in pages.
311311

312312
Items, err := sdk.CachedApiGatewayGetRestAPIs(m.APIGatewayClient, aws.ToString(m.Caller.Account), r)
313313

314314
if err != nil {
315315
m.modLog.Error(err.Error())
316-
m.CommandCounter.Error++
316+
m.CommandCounter.IncrError()
317317
return
318318
}
319319

@@ -322,7 +322,7 @@ func (m *ApiGwModule) getAPIGatewayVIPsPerRegion(r string, wg *sync.WaitGroup, s
322322
if err != nil {
323323
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
324324
m.modLog.Error(err.Error())
325-
m.CommandCounter.Error++
325+
m.CommandCounter.IncrError()
326326
return
327327
}
328328

@@ -334,7 +334,7 @@ func (m *ApiGwModule) getAPIGatewayVIPsPerRegion(r string, wg *sync.WaitGroup, s
334334
if err != nil {
335335
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
336336
m.modLog.Error(err.Error())
337-
m.CommandCounter.Error++
337+
m.CommandCounter.IncrError()
338338
break
339339
}
340340

@@ -347,7 +347,7 @@ func (m *ApiGwModule) getAPIGatewayVIPsPerRegion(r string, wg *sync.WaitGroup, s
347347

348348
for _, api := range Items {
349349
if api.Id != nil && aws.ToString(api.Id) == aws.ToString(mapping.RestApiId) {
350-
m.CommandCounter.Total++
350+
m.CommandCounter.IncrTotal()
351351

352352
endpoints := m.getEndpointsPerAPIGateway(r, api)
353353
for _, endpoint := range endpoints {
@@ -376,8 +376,8 @@ func (m *ApiGwModule) getAPIGatewayVIPsPerRegion(r string, wg *sync.WaitGroup, s
376376

377377
func (m *ApiGwModule) getEndpointsPerAPIGateway(r string, api apigatewayTypes.RestApi) []ApiGateway {
378378
defer func() {
379-
m.CommandCounter.Executing--
380-
m.CommandCounter.Complete++
379+
m.CommandCounter.DecrExecuting()
380+
m.CommandCounter.IncrComplete()
381381
}()
382382
var gateways []ApiGateway
383383

@@ -402,7 +402,7 @@ func (m *ApiGwModule) getEndpointsPerAPIGateway(r string, api apigatewayTypes.Re
402402
if err != nil {
403403
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
404404
m.modLog.Error(err.Error())
405-
m.CommandCounter.Error++
405+
m.CommandCounter.IncrError()
406406
return gateways
407407
}
408408

@@ -411,7 +411,7 @@ func (m *ApiGwModule) getEndpointsPerAPIGateway(r string, api apigatewayTypes.Re
411411
if err != nil {
412412
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
413413
m.modLog.Error(err.Error())
414-
m.CommandCounter.Error++
414+
m.CommandCounter.IncrError()
415415
}
416416

417417
for _, stage := range GetStages.Item {
@@ -427,7 +427,7 @@ func (m *ApiGwModule) getEndpointsPerAPIGateway(r string, api apigatewayTypes.Re
427427
if err != nil {
428428
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
429429
m.modLog.Error(err.Error())
430-
m.CommandCounter.Error++
430+
m.CommandCounter.IncrError()
431431
}
432432
}
433433

@@ -454,29 +454,29 @@ func (m *ApiGwModule) getEndpointsPerAPIGateway(r string, api apigatewayTypes.Re
454454

455455
func (m *ApiGwModule) getAPIGatewayv2APIsPerRegion(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan ApiGateway) {
456456
defer func() {
457-
m.CommandCounter.Executing--
458-
m.CommandCounter.Complete++
457+
m.CommandCounter.DecrExecuting()
458+
m.CommandCounter.IncrComplete()
459459
wg.Done()
460460

461461
}()
462462
semaphore <- struct{}{}
463463
defer func() {
464464
<-semaphore
465465
}()
466-
// m.CommandCounter.Total++
467-
m.CommandCounter.Pending--
468-
m.CommandCounter.Executing++
466+
// m.CommandCounter.IncrTotal()
467+
m.CommandCounter.DecrPending()
468+
m.CommandCounter.IncrExecuting()
469469
// "PaginationMarker" is a control variable used for output continuity, as AWS return the output in pages.
470470

471471
Items, err := sdk.CachedAPIGatewayv2GetAPIs(m.APIGatewayv2Client, aws.ToString(m.Caller.Account), r)
472472

473473
if err != nil {
474474
m.modLog.Error(err.Error())
475-
m.CommandCounter.Error++
475+
m.CommandCounter.IncrError()
476476
return
477477
}
478478
for _, api := range Items {
479-
m.CommandCounter.Total++
479+
m.CommandCounter.IncrTotal()
480480
for _, endpoint := range m.getEndpointsPerAPIGatewayv2(r, api) {
481481
dataReceiver <- endpoint
482482
}
@@ -486,25 +486,25 @@ func (m *ApiGwModule) getAPIGatewayv2APIsPerRegion(r string, wg *sync.WaitGroup,
486486

487487
func (m *ApiGwModule) getAPIGatewayv2VIPsPerRegion(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan ApiGateway) {
488488
defer func() {
489-
m.CommandCounter.Executing--
490-
m.CommandCounter.Complete++
489+
m.CommandCounter.DecrExecuting()
490+
m.CommandCounter.IncrComplete()
491491
wg.Done()
492492

493493
}()
494494
semaphore <- struct{}{}
495495
defer func() {
496496
<-semaphore
497497
}()
498-
// m.CommandCounter.Total++
499-
m.CommandCounter.Pending--
500-
m.CommandCounter.Executing++
498+
// m.CommandCounter.IncrTotal()
499+
m.CommandCounter.DecrPending()
500+
m.CommandCounter.IncrExecuting()
501501
// "PaginationMarker" is a control variable used for output continuity, as AWS return the output in pages.
502502

503503
Items, err := sdk.CachedAPIGatewayv2GetAPIs(m.APIGatewayv2Client, aws.ToString(m.Caller.Account), r)
504504

505505
if err != nil {
506506
m.modLog.Error(err.Error())
507-
m.CommandCounter.Error++
507+
m.CommandCounter.IncrError()
508508
return
509509
}
510510

@@ -513,7 +513,7 @@ func (m *ApiGwModule) getAPIGatewayv2VIPsPerRegion(r string, wg *sync.WaitGroup,
513513
if err != nil {
514514
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
515515
m.modLog.Error(err.Error())
516-
m.CommandCounter.Error++
516+
m.CommandCounter.IncrError()
517517
}
518518

519519
for _, item := range GetDomainNames {
@@ -524,7 +524,7 @@ func (m *ApiGwModule) getAPIGatewayv2VIPsPerRegion(r string, wg *sync.WaitGroup,
524524
if err != nil {
525525
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
526526
m.modLog.Error(err.Error())
527-
m.CommandCounter.Error++
527+
m.CommandCounter.IncrError()
528528
break
529529
}
530530

@@ -537,7 +537,7 @@ func (m *ApiGwModule) getAPIGatewayv2VIPsPerRegion(r string, wg *sync.WaitGroup,
537537

538538
for _, api := range Items {
539539
if api.ApiId != nil && aws.ToString(api.ApiId) == aws.ToString(mapping.ApiId) {
540-
m.CommandCounter.Total++
540+
m.CommandCounter.IncrTotal()
541541
endpoints := m.getEndpointsPerAPIGatewayv2(r, api)
542542
for _, endpoint := range endpoints {
543543
var old string
@@ -568,8 +568,8 @@ func (m *ApiGwModule) getAPIGatewayv2VIPsPerRegion(r string, wg *sync.WaitGroup,
568568

569569
func (m *ApiGwModule) getEndpointsPerAPIGatewayv2(r string, api apigatewayV2Types.Api) []ApiGateway {
570570
defer func() {
571-
m.CommandCounter.Executing--
572-
m.CommandCounter.Complete++
571+
m.CommandCounter.DecrExecuting()
572+
m.CommandCounter.IncrComplete()
573573
}()
574574

575575
var gateways []ApiGateway
@@ -588,7 +588,7 @@ func (m *ApiGwModule) getEndpointsPerAPIGatewayv2(r string, api apigatewayV2Type
588588
if err != nil {
589589
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
590590
m.modLog.Error(err.Error())
591-
m.CommandCounter.Error++
591+
m.CommandCounter.IncrError()
592592
}
593593

594594
for _, stage := range GetStages {
@@ -603,7 +603,7 @@ func (m *ApiGwModule) getEndpointsPerAPIGatewayv2(r string, api apigatewayV2Type
603603
if err != nil {
604604
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
605605
m.modLog.Error(err.Error())
606-
m.CommandCounter.Error++
606+
m.CommandCounter.IncrError()
607607
}
608608

609609
for _, stage := range stages {
@@ -643,7 +643,7 @@ func (m *ApiGwModule) ApiGatewayApiKeyRequired(r string, ApiId *string, Resource
643643
if err != nil {
644644
m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s", r))
645645
m.modLog.Error(err.Error())
646-
m.CommandCounter.Error++
646+
m.CommandCounter.IncrError()
647647
} else {
648648
return aws.ToBool(GetMethod.ApiKeyRequired)
649649
}

0 commit comments

Comments
 (0)