From 63433c506fd0de1f3f245ceb8d1deed24d5e1b1e Mon Sep 17 00:00:00 2001 From: Samuel Burgos <34037255+sbldevnet@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:44:00 +0100 Subject: [PATCH] Fix issue where asff output was always missing the first row (#249) --- .../templates/asff.json/output.tmpl | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/internal/controldisplay/templates/asff.json/output.tmpl b/internal/controldisplay/templates/asff.json/output.tmpl index 9f09aa6b..14d60c6e 100644 --- a/internal/controldisplay/templates/asff.json/output.tmpl +++ b/internal/controldisplay/templates/asff.json/output.tmpl @@ -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 }}", @@ -41,7 +39,7 @@ "Label": "INFORMATIONAL" },{{ end }} "Resources": [ - { + { "Type": "Other", "Id": "{{ .Resource }}" } @@ -49,7 +47,7 @@ "Compliance": { "Status": "{{ template "statusmap" .Status -}}" } -} {{ end -}} +}{{ end -}} {{/* mapping steampipe statuses with ASFF status values */}} {{ define "statusmap" }}