From 929199bc5cb2dc5db2a89a5fa6dab30aecf6188e Mon Sep 17 00:00:00 2001 From: sg Date: Tue, 15 Oct 2024 10:17:35 +0100 Subject: [PATCH] fix #422, allow consumer templating to also carry information about which annotation contains the code fix --- pkg/templating/template_description.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/templating/template_description.go b/pkg/templating/template_description.go index 5e0491cbe..f7e2cc30c 100644 --- a/pkg/templating/template_description.go +++ b/pkg/templating/template_description.go @@ -38,13 +38,14 @@ func TemplateStringRaw(inputTemplate string, issue *v1.Issue) (*string, error) { type enrichedIssue struct { *v1.EnrichedIssue - ToolName string - ScanStartTime string - ScanID string - ConfidenceText string - SeverityText string - Count uint - FirstFound string + ToolName string + ScanStartTime string + ScanID string + ConfidenceText string + SeverityText string + Count uint + FirstFound string + FixedCodeAnnotation string } type enrichedIssueOption func(*enrichedIssue) error @@ -118,6 +119,13 @@ func EnrichedIssueWithFirstFound(firstFound time.Time) enrichedIssueOption { } } +func EnrichedIssueWithFixedCodeAnnotation(fixedCodeAnnotation string) enrichedIssueOption { + return func(ei *enrichedIssue) error { + ei.FixedCodeAnnotation = fixedCodeAnnotation + return nil + } +} + // TemplateStringEnriched applies the provided go template to the Enriched Issue provided and returns the resulting str func TemplateStringEnriched(inputTemplate string, issue *v1.EnrichedIssue, opts ...enrichedIssueOption) (*string, error) { enrichedIssue := &enrichedIssue{