From 215510e57c2d6e2add186714cbb7051a1178d358 Mon Sep 17 00:00:00 2001 From: hunt3rkillerz <32833534+hunt3rkillerz@users.noreply.github.com> Date: Thu, 31 Aug 2023 18:30:39 +1000 Subject: [PATCH] Fixing bugs in legacy style checks Signed-off-by: hunt3rkillerz <32833534+hunt3rkillerz@users.noreply.github.com> --- pkg/policies/scorecard/scorecard.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/policies/scorecard/scorecard.go b/pkg/policies/scorecard/scorecard.go index 5ee69593..2decf619 100644 --- a/pkg/policies/scorecard/scorecard.go +++ b/pkg/policies/scorecard/scorecard.go @@ -226,10 +226,14 @@ func listJoin(list []string) string { func convertLogs(logs []checker.CheckDetail) []string { var s []string for _, l := range logs { - if l.Msg.Finding.Location == nil { - s = append(s, fmt.Sprintf("%v", l.Msg.Finding.Message)) + if l.Msg.Finding != nil { + if l.Msg.Finding.Location == nil { + s = append(s, fmt.Sprintf("%v", l.Msg.Finding.Message)) + } else { + s = append(s, fmt.Sprintf("%v[%v]:%v", l.Msg.Finding.Location.Value, *l.Msg.Finding.Location.LineStart, l.Msg.Finding.Message)) + } } else { - s = append(s, fmt.Sprintf("%v[%v]:%v", l.Msg.Finding.Location.Value, *l.Msg.Finding.Location.LineStart, l.Msg.Finding.Message)) + s = append(s, fmt.Sprintf("%v[%v]:%v", l.Msg.Path, l.Msg.Offset, l.Msg.Text)) } } return s