-
Notifications
You must be signed in to change notification settings - Fork 1
/
result.go
37 lines (29 loc) · 1.02 KB
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package report
import (
"fmt"
"io"
"github.com/aquasecurity/tml"
renderer "github.com/zhanglimao/trivy/pkg/report/table"
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"github.com/zhanglimao/trivy/pkg/types"
)
func writeResultsForARN(report *Report, results types.Results, output io.Writer, service, arn string, severities []dbTypes.Severity) error {
// render scan title
_ = tml.Fprintf(output, "\n<bold>Results for '%s' (%s Account %s)</bold>\n\n", arn, report.Provider, report.AccountID)
for _, result := range results {
var filtered []types.DetectedMisconfiguration
for _, misconfiguration := range result.Misconfigurations {
if arn != "" && misconfiguration.CauseMetadata.Resource != arn {
continue
}
if service != "" && misconfiguration.CauseMetadata.Service != service {
continue
}
filtered = append(filtered, misconfiguration)
}
if len(filtered) > 0 {
_, _ = fmt.Fprint(output, renderer.NewMisconfigRenderer(result, severities, false, false, true).Render())
}
}
return nil
}