From 33a32bd86041bf67d3b0efdaad095c481d0da9cc Mon Sep 17 00:00:00 2001 From: realwebdev Date: Wed, 15 Feb 2023 19:31:13 +0500 Subject: [PATCH] add(cloud): listfinding call added --- .../adapters/cloud/aws/accessanalyzer/adapt.go | 18 ++++++++++++++++++ .../aws/accessanalyzer/analyzer.go | 1 + pkg/providers/aws/accessanalyzer/aa.go | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/internal/adapters/cloud/aws/accessanalyzer/adapt.go b/internal/adapters/cloud/aws/accessanalyzer/adapt.go index 440d2b7b4..06c2453bd 100644 --- a/internal/adapters/cloud/aws/accessanalyzer/adapt.go +++ b/internal/adapters/cloud/aws/accessanalyzer/adapt.go @@ -84,10 +84,28 @@ func (a *adapter) adaptAnalyzer(apiAnalyzer aatypes.AnalyzerSummary) (*accessana if apiAnalyzer.Name != nil { name = *apiAnalyzer.Name } + + var findings []accessanalyzer.Findings + output, err := a.api.ListFindings(a.Context(), &api.ListFindingsInput{ + AnalyzerArn: apiAnalyzer.Arn, + }) + if err != nil { + return nil, err + } + if output.Findings != nil { + for _, r := range output.Findings { + findings = append(findings, accessanalyzer.Findings{ + Metadata: metadata, + }) + _ = r + } + } + return &accessanalyzer.Analyzer{ Metadata: metadata, ARN: types.String(*apiAnalyzer.Arn, metadata), Name: types.String(name, metadata), Active: types.Bool(apiAnalyzer.Status == aatypes.AnalyzerStatusActive, metadata), + Findings: findings, }, nil } diff --git a/internal/adapters/cloudformation/aws/accessanalyzer/analyzer.go b/internal/adapters/cloudformation/aws/accessanalyzer/analyzer.go index f5f13c407..a840a7fa5 100644 --- a/internal/adapters/cloudformation/aws/accessanalyzer/analyzer.go +++ b/internal/adapters/cloudformation/aws/accessanalyzer/analyzer.go @@ -13,6 +13,7 @@ func getAccessAnalyzer(ctx parser.FileContext) (analyzers []accessanalyzer.Analy aa := accessanalyzer.Analyzer{ Metadata: r.Metadata(), Name: r.GetStringProperty("AnalyzerName"), + ARN: r.StringDefault(""), } analyzers = append(analyzers, aa) diff --git a/pkg/providers/aws/accessanalyzer/aa.go b/pkg/providers/aws/accessanalyzer/aa.go index 77d235f83..fc23065be 100644 --- a/pkg/providers/aws/accessanalyzer/aa.go +++ b/pkg/providers/aws/accessanalyzer/aa.go @@ -11,4 +11,9 @@ type Analyzer struct { ARN types.StringValue Name types.StringValue Active types.BoolValue + Findings []Findings +} + +type Findings struct { + Metadata types.Metadata }