Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address linter issues coming from govet #4138

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/controlplane/handlers_authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func (s *Server) AssignRole(ctx context.Context, req *minder.AssignRoleRequest)
// Parse role (this also validates)
authzRole, err := authz.ParseRole(role)
if err != nil {
return nil, util.UserVisibleError(codes.InvalidArgument, err.Error())
return nil, util.UserVisibleError(codes.InvalidArgument, "%s", err.Error())
}

// Ensure the target project exists
Expand Down Expand Up @@ -377,7 +377,7 @@ func (s *Server) RemoveRole(ctx context.Context, req *minder.RemoveRoleRequest)
// Parse role (this also validates)
authzRole, err := authz.ParseRole(role)
if err != nil {
return nil, util.UserVisibleError(codes.InvalidArgument, err.Error())
return nil, util.UserVisibleError(codes.InvalidArgument, "%s", err.Error())
}

// Validate the subject and email - decide if it's about removing an invitation or a role assignment
Expand Down Expand Up @@ -433,7 +433,7 @@ func (s *Server) UpdateRole(ctx context.Context, req *minder.UpdateRoleRequest)
// Parse role (this also validates)
authzRole, err := authz.ParseRole(role)
if err != nil {
return nil, util.UserVisibleError(codes.InvalidArgument, err.Error())
return nil, util.UserVisibleError(codes.InvalidArgument, "%s", err.Error())
}

// Validate the subject and email - decide if it's about updating an invitation or a role assignment
Expand Down
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func TestProjectAuthorizationInterceptor(t *testing.T) {
},
rpcErr: util.UserVisibleError(
codes.PermissionDenied,
fmt.Sprintf("user %q is not authorized to perform this operation on project %q", "subject1", projectID)),
"user %q is not authorized to perform this operation on project %q", "subject1", projectID),
},
{
name: "authorized on project",
Expand Down
4 changes: 2 additions & 2 deletions internal/controlplane/handlers_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (s *Server) processOAuthCallback(ctx context.Context, w http.ResponseWriter
zerolog.Ctx(ctx).Info().Str("provider", provider).Msg("Provider already exists")
} else if errors.As(err, &errConfig) {
return newHttpError(http.StatusBadRequest, "Invalid provider config").SetContents(
"The provider configuration is invalid: " + errConfig.Details)
"The provider configuration is invalid: %s", errConfig.Details)
} else if err != nil {
return fmt.Errorf("error creating provider: %w", err)
}
Expand Down Expand Up @@ -376,7 +376,7 @@ func (s *Server) processAppCallback(ctx context.Context, w http.ResponseWriter,
if err != nil {
if errors.As(err, &confErr) {
return newHttpError(http.StatusBadRequest, "Invalid provider config").SetContents(
"The provider configuration is invalid: " + confErr.Details)
"The provider configuration is invalid: %s", confErr.Details)
}
if errors.Is(err, service.ErrInvalidTokenIdentity) {
return newHttpError(http.StatusForbidden, "User token mismatch").SetContents(
Expand Down
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *Server) CreateProvider(
return nil, util.UserVisibleError(codes.AlreadyExists, "provider already exists")
} else if errors.As(err, &configErr) {
zerolog.Ctx(ctx).Error().Err(err).Msg("provider config does not validate")
return nil, util.UserVisibleError(codes.InvalidArgument, "invalid provider config: "+configErr.Details)
return nil, util.UserVisibleError(codes.InvalidArgument, "invalid provider config: %s", configErr.Details)
} else if err != nil {
return nil, status.Errorf(codes.Internal, "error creating provider: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controlplane/handlers_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *Server) RegisterRepository(
newRepo, err := s.repos.CreateRepository(ctx, provider, projectID, githubRepo.GetOwner(), githubRepo.GetName())
if err != nil {
if errors.Is(err, ghrepo.ErrPrivateRepoForbidden) || errors.Is(err, ghrepo.ErrArchivedRepoForbidden) {
return nil, util.UserVisibleError(codes.InvalidArgument, err.Error())
return nil, util.UserVisibleError(codes.InvalidArgument, "%s", err.Error())
}
return nil, util.UserVisibleError(codes.Internal, "unable to register repository: %v", err)
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func (s *Server) ListRepositories(ctx context.Context,

reqRepoCursor, err := cursorutil.NewRepoCursor(in.GetCursor())
if err != nil {
return nil, util.UserVisibleError(codes.InvalidArgument, err.Error())
return nil, util.UserVisibleError(codes.InvalidArgument, "%s", err.Error())
}

repoId := sql.NullInt64{}
Expand Down
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_ruletype.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (s *Server) DeleteRuleType(
if err == nil {
if len(profiles) > 0 {
return nil, util.UserVisibleError(codes.FailedPrecondition,
fmt.Sprintf("cannot delete: rule type %s is used by profiles %s", in.GetId(), strings.Join(profiles, ", ")))
"cannot delete: rule type %s is used by profiles %s", in.GetId(), strings.Join(profiles, ", "))
}
} else if !errors.Is(err, sql.ErrNoRows) {
// If we failed for another reason, return an error
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/eval/jq/jq.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (jqe *Evaluator) Eval(ctx context.Context, pol map[string]any, res *engif.R
msg = fmt.Sprintf("%s\nassertion: %s", msg, string(marshalledAssertion))
}

return evalerrors.NewErrEvaluationFailed(msg)
return evalerrors.NewErrEvaluationFailed("%s", msg)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/engine/eval/rego/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,5 @@ func (jrb *jsonResultBuilder) formatResults() error {
return fmt.Errorf("failed to marshal violations: %w", err)
}

return engerrors.NewErrEvaluationFailed(string(jsonArray))
return engerrors.NewErrEvaluationFailed("%s", string(jsonArray))
}
2 changes: 1 addition & 1 deletion internal/engine/eval/trusty/trusty.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func buildEvalResult(prSummary *summaryPrHandler) error {
}

if failedEvalMsg != "" {
return evalerrors.NewErrEvaluationFailed(failedEvalMsg)
return evalerrors.NewErrEvaluationFailed("%s", failedEvalMsg)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/eval/vulncheck/vulncheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (e *Evaluator) Eval(ctx context.Context, pol map[string]any, res *engif.Res
}

if len(vulnerablePackages) > 0 {
return evalerrors.NewErrEvaluationFailed(fmt.Sprintf("vulnerable packages: %s", strings.Join(vulnerablePackages, ",")))
return evalerrors.NewErrEvaluationFailed("vulnerable packages: %s", strings.Join(vulnerablePackages, ","))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/roles/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (_ *roleService) UpdateRoleAssignment(ctx context.Context, qtx db.Querier,
if a.Subject == identity.String() {
roleToDelete, err := authz.ParseRole(a.Role)
if err != nil {
return nil, util.UserVisibleError(codes.Internal, err.Error())
return nil, util.UserVisibleError(codes.Internal, "%s", err.Error())
}
if err := authzClient.Delete(ctx, identity.String(), roleToDelete, targetProject); err != nil {
return nil, status.Errorf(codes.Internal, "error deleting previous role assignment: %v", err)
Expand Down
Loading