Skip to content

Commit

Permalink
fix(report): don't mark misconfig passed tests as failed in junit.tpl (
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Dec 12, 2023
1 parent 01edbda commit be5a550
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contrib/junit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
</testcase>
{{- end }}
</testsuite>
{{- $failures := len .Misconfigurations }}
<testsuite tests="{{ $failures }}" failures="{{ $failures }}" name="{{ .Target }}" errors="0" skipped="0" time="">
<testsuite tests="{{ add .MisconfSummary.Successes .MisconfSummary.Failures }}" failures="{{ .MisconfSummary.Failures }}" name="{{ .Target }}" errors="0" skipped="{{ .MisconfSummary.Exceptions}}" time="">
{{- if not (eq .Type "") }}
<properties>
<property name="type" value="{{ .Type }}"></property>
</properties>
{{- end -}}
{{ range .Misconfigurations }}
<testcase classname="{{ .Type }}" name="[{{ .Severity }}] {{ .ID }}" time="">
{{- if (eq .Status "FAIL") }}
<failure message="{{ escapeXML .Title }}" type="description">{{ escapeXML .Description }}</failure>
{{- end }}
</testcase>
{{- end }}
</testsuite>
Expand Down

3 comments on commit be5a550

@d4kverma
Copy link

@d4kverma d4kverma commented on be5a550 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DmitriyLewen Earlier it was working . not showing me this error.
report error: unable to write results: failed to write results: failed to write with template: template: output template:17:44: executing "output template" at <.MisconfSummary.Successes>: nil pointer evaluating *types.MisconfSummary.Successes

@d4kverma
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command was working for before.
trivy image --format template --template "@contrib/junit.tpl" -o ../junit-report.xml app:latest

@DmitriyLewen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @d4kverma
Thanks a lot!

I created #5782.

Please sign in to comment.