Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix issue where asff output was always missing the first row #249

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading