-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bc1852
commit 88d9a3a
Showing
4 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
internal/adapters/cloudformation/aws/accessanalyzer/accessanalyzer.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package accessanalyzer | ||
|
||
import ( | ||
"github.com/aquasecurity/defsec/pkg/providers/aws/accessanalyzer" | ||
"github.com/aquasecurity/defsec/pkg/scanners/cloudformation/parser" | ||
) | ||
|
||
// Adapt ... | ||
func Adapt(cfFile parser.FileContext) accessanalyzer.AccessAnalyzer { | ||
return accessanalyzer.AccessAnalyzer{ | ||
Analyzers: getAccessAnalyzer(cfFile), | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
internal/adapters/cloudformation/aws/accessanalyzer/analyzer.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package accessanalyzer | ||
|
||
import ( | ||
"github.com/aquasecurity/defsec/pkg/providers/aws/accessanalyzer" | ||
"github.com/aquasecurity/defsec/pkg/scanners/cloudformation/parser" | ||
) | ||
|
||
func getAccessAnalyzer(ctx parser.FileContext) (analyzers []accessanalyzer.Analyzer) { | ||
|
||
analyzersList := ctx.GetResourcesByType("AWS::AccessAnalyzer::Analyzer") | ||
|
||
for _, r := range analyzersList { | ||
aa := accessanalyzer.Analyzer{ | ||
Metadata: r.Metadata(), | ||
Name: r.GetStringProperty("AnalyzerName"), | ||
} | ||
|
||
analyzers = append(analyzers, aa) | ||
} | ||
return analyzers | ||
} |
38 changes: 38 additions & 0 deletions
38
internal/adapters/terraform/aws/accessanalyzer/accessanalyzer.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package accessanalyzer | ||
|
||
import ( | ||
"github.com/aquasecurity/defsec/pkg/providers/aws/accessanalyzer" | ||
"github.com/aquasecurity/defsec/pkg/terraform" | ||
) | ||
|
||
func Adapt(modules terraform.Modules) accessanalyzer.AccessAnalyzer { | ||
return accessanalyzer.AccessAnalyzer{ | ||
Analyzers: adaptTrails(modules), | ||
} | ||
} | ||
|
||
func adaptTrails(modules terraform.Modules) []accessanalyzer.Analyzer { | ||
var analyzer []accessanalyzer.Analyzer | ||
|
||
for _, module := range modules { | ||
for _, resource := range module.GetResourcesByType("aws_accessanalyzer_analyzer") { | ||
analyzer = append(analyzer, adaptAnalyzers(resource)) | ||
} | ||
} | ||
return analyzer | ||
} | ||
|
||
func adaptAnalyzers(resource *terraform.Block) accessanalyzer.Analyzer { | ||
|
||
analyzerName := resource.GetAttribute("analyzer_name") | ||
analyzerNameAttr := analyzerName.AsStringValueOrDefault("", resource) | ||
|
||
arnAnalyzer := resource.GetAttribute("arn") | ||
arnAnalyzerAttr := arnAnalyzer.AsStringValueOrDefault("", resource) | ||
|
||
return accessanalyzer.Analyzer{ | ||
Metadata: resource.GetMetadata(), | ||
Name: analyzerNameAttr, | ||
ARN: arnAnalyzerAttr, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters