From a11a9b06c2be678e144e91605092fa1ca184f84b Mon Sep 17 00:00:00 2001 From: Ricardo N Feliciano Date: Wed, 8 Feb 2023 16:31:46 -0500 Subject: [PATCH] Don't let viewing team errors stop the audit (#95) --- warden/cmd/audit.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/warden/cmd/audit.go b/warden/cmd/audit.go index d53ba3e..3501d32 100644 --- a/warden/cmd/audit.go +++ b/warden/cmd/audit.go @@ -205,8 +205,16 @@ var ( // if access permissions are to be checked... if len(policy.Access) > 0 { - teams, _, err := client.Repositories.ListTeams(context.Background(), repo.Owner, repo.Name, nil) - if err != nil { + teams, resp, err := client.Repositories.ListTeams(context.Background(), repo.Owner, repo.Name, nil) + if resp.StatusCode == 404 { + + // considering this repo worked for other audits but not this, this likely + // means we don't have admin access in order to check teams + fmt.Fprintf(os.Stderr, "Error: couldn't pull the teams for %s.\nThis is likely a permission issue with the token being used to run Warden. If\nthe user whose token is being used doesn't have admin access\nto the repo, teams can't be pulled.\n\n", repoDef.URL) + + // skip the rest + policy.Access = nil + } else if err != nil { return err }