Skip to content

Commit cfdcecf

Browse files
authored
Merge pull request #8 from akobir-arc/work-with-defaults
conditionally fall back to using tag, title
2 parents 87243a6 + 488085d commit cfdcecf

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

main.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ func getConfigAuditReportFindings(body []byte) ([]types.AwsSecurityFinding, erro
145145

146146
// Truncate description if too long
147147
description := check.Description
148-
if len(description) > 512 {
149-
description = description[:512] + "..."
148+
if len(description) > 1024 {
149+
description = description[:1021] + "..."
150150
}
151151

152152
findings = append(findings, types.AwsSecurityFinding{
@@ -266,7 +266,13 @@ func getVulnerabilityReportFindings(body []byte) ([]types.AwsSecurityFinding, er
266266
Registry := vulnerabilityReport.Report.Registry.Server
267267
Repository := vulnerabilityReport.Report.Artifact.Repository
268268
Digest := vulnerabilityReport.Report.Artifact.Digest
269-
FullImageName := fmt.Sprintf("%s/%s:%s", Registry, Repository, Digest)
269+
FullImageName := fmt.Sprintf("%s/%s@%s", Registry, Repository, Digest)
270+
Tag := vulnerabilityReport.Report.Artifact.Tag
271+
// use tag if digest is empty
272+
if Digest == "" {
273+
FullImageName = fmt.Sprintf("%s/%s:%s", Registry, Repository, Tag)
274+
}
275+
270276
ImageName := fmt.Sprintf("%s/%s", Registry, Repository)
271277

272278
// Prepare findings for AWS Security Hub BatchImportFindings API
@@ -279,10 +285,14 @@ func getVulnerabilityReportFindings(body []byte) ([]types.AwsSecurityFinding, er
279285
severity = "INFORMATIONAL"
280286
}
281287

282-
// Truncate description if too long
283288
description := vulnerabilities.Description
284-
if len(description) > 512 {
285-
description = description[:512] + "..."
289+
// check if description is empty, replace with title
290+
if vulnerabilities.Description == "" {
291+
description = vulnerabilities.Title
292+
}
293+
// Truncate description if too long
294+
if len(description) > 1024 {
295+
description = description[:1021] + "..."
286296
}
287297

288298
findings = append(findings, types.AwsSecurityFinding{

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This application processes vulnerability reports from Trivy, a vulnerability sca
2222
- **AWS Account**: This application uses AWS Security Hub to store and manage security findings, so you must have an active AWS account and the necessary permissions.
2323
- **Trivy**: You must set up Trivy to scan container images and send reports to the webhook endpoint.
2424
- **Go**: The application is written in Go, so you'll need Go installed to build and run it.
25+
- **Security Hub Integration**: You must accept findings from `Aqua Security: Aqua Security` in AWS Security Hub. This allows the application to import findings into Security Hub.
2526

2627
## Setup and Installation
2728

0 commit comments

Comments
 (0)