From 609be43faec8fc086cc7ef1788eebb36c696ce54 Mon Sep 17 00:00:00 2001 From: Jeff Mendoza Date: Fri, 1 Mar 2024 08:35:46 -0800 Subject: [PATCH] Catch unknown scorecard check. Signed-off-by: Jeff Mendoza --- pkg/policies/scorecard/scorecard.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/policies/scorecard/scorecard.go b/pkg/policies/scorecard/scorecard.go index 268685f6..b401af57 100644 --- a/pkg/policies/scorecard/scorecard.go +++ b/pkg/policies/scorecard/scorecard.go @@ -161,7 +161,18 @@ func (b Scorecard) Check(ctx context.Context, c *github.Client, owner, Dlogger: l, } - res := checksAllChecks[n].Fn(cr) + check, ok := checksAllChecks[n] + if !ok { + log.Warn(). + Str("org", owner). + Str("repo", repo). + Str("area", polName). + Str("check", n). + Msg("Unknown scorecard check specified.") + break + } + + res := check.Fn(cr) if res.Error != nil { // We are not sure that all checks are safe to run inside Allstar, some // might error, and we don't want to abort a whole org enforcement loop