-
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.
* add: accessanalyzer adapter * add(cloud): listfinding call added * add: schema added * modify: initialized active field in accessanalyzer cloudformation and terraform
- Loading branch information
1 parent
160a9d6
commit 0fd1fd0
Showing
6 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
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
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), | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
package accessanalyzer | ||
|
||
import ( | ||
"github.com/aquasecurity/defsec/pkg/providers/aws/accessanalyzer" | ||
"github.com/aquasecurity/defsec/pkg/scanners/cloudformation/parser" | ||
"github.com/aquasecurity/defsec/pkg/types" | ||
) | ||
|
||
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"), | ||
ARN: r.StringDefault(""), | ||
Active: types.BoolDefault(false, r.Metadata()), | ||
} | ||
|
||
analyzers = append(analyzers, aa) | ||
} | ||
return analyzers | ||
} |
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
package accessanalyzer | ||
|
||
import ( | ||
"github.com/aquasecurity/defsec/pkg/providers/aws/accessanalyzer" | ||
"github.com/aquasecurity/defsec/pkg/terraform" | ||
"github.com/aquasecurity/defsec/pkg/types" | ||
) | ||
|
||
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, | ||
Active: types.BoolDefault(false, resource.GetMetadata()), | ||
} | ||
} |
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
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