Skip to content

Commit

Permalink
Fix issue where asff output was always missing the first row (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbldevnet authored Mar 7, 2024
1 parent bf08455 commit 63433c5
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions internal/controldisplay/templates/asff.json/output.tmpl
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
{{ define "output" }}
{{- $first_row_rendered := false -}}
[ {{- range $runIdx,$run := .Data.ControlRuns -}}
{{- range $rowIdx,$row := $run.Rows -}}
{{- if gt (add $runIdx $rowIdx) 0 -}}
{{/* check if the control is related to aws */}}
{{- if $row.Run.MatchTag "plugin" "aws" -}}
{{ if $first_row_rendered -}},{{ end }}
{{- template "control_row_template" $row -}}
{{ $first_row_rendered = true }}
{{- end -}}
{{- end -}}
{{- end -}}
[ {{- range $runIdx,$run := .Data.ControlRuns -}}
{{- range $rowIdx,$row := $run.Rows -}}
{{/* check if the control is related to aws */}}
{{- if $row.Run.MatchTag "plugin" "aws" -}}
{{ if $first_row_rendered -}},{{ end }}
{{- template "control_row_template" $row -}}
{{ $first_row_rendered = true }}
{{- end -}}
{{- end -}}
{{- end }}
]
{{ end }}

{{/* sub template for control rows */}}
{{ define "control_row_template" }}
{{ define "control_row_template" }}
{
"SchemaVersion": "2018-10-08",
"Id": "{{ .Run.Control.FullName }}",
Expand All @@ -41,15 +39,15 @@
"Label": "INFORMATIONAL"
},{{ end }}
"Resources": [
{
{
"Type": "Other",
"Id": "{{ .Resource }}"
}
],
"Compliance": {
"Status": "{{ template "statusmap" .Status -}}"
}
} {{ end -}}
}{{ end -}}

{{/* mapping steampipe statuses with ASFF status values */}}
{{ define "statusmap" }}
Expand Down

0 comments on commit 63433c5

Please # to comment.