Skip to content

Commit f1092e1

Browse files
committed
Fix govet non-constant error format string issues
1 parent 02c3998 commit f1092e1

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

acme/api/revoke.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func isAccountAuthorized(_ context.Context, dbCert *acme.Certificate, certToBeRe
180180
func wrapRevokeErr(err error) *acme.Error {
181181
t := err.Error()
182182
if strings.Contains(t, "is already revoked") {
183-
return acme.NewError(acme.ErrorAlreadyRevokedType, t)
183+
return acme.NewError(acme.ErrorAlreadyRevokedType, "%s", t)
184184
}
185185
return acme.WrapErrorISE(err, "error when revoking certificate")
186186
}
@@ -190,9 +190,9 @@ func wrapRevokeErr(err error) *acme.Error {
190190
func wrapUnauthorizedError(cert *x509.Certificate, unauthorizedIdentifiers []acme.Identifier, msg string, err error) *acme.Error {
191191
var acmeErr *acme.Error
192192
if err == nil {
193-
acmeErr = acme.NewError(acme.ErrorUnauthorizedType, msg)
193+
acmeErr = acme.NewError(acme.ErrorUnauthorizedType, "%s", msg)
194194
} else {
195-
acmeErr = acme.WrapError(acme.ErrorUnauthorizedType, err, msg)
195+
acmeErr = acme.WrapError(acme.ErrorUnauthorizedType, err, "%s", msg)
196196
}
197197
acmeErr.Status = http.StatusForbidden // RFC8555 7.6 shows example with 403
198198

acme/order.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (o *Order) Finalize(ctx context.Context, db DB, csr *x509.CertificateReques
309309
// Add subproblem for webhook errors, others can be added later.
310310
var webhookErr *webhook.Error
311311
if errors.As(err, &webhookErr) {
312-
acmeError := NewDetailedError(ErrorUnauthorizedType, webhookErr.Error())
312+
acmeError := NewDetailedError(ErrorUnauthorizedType, "%s", webhookErr.Error())
313313
acmeError.AddSubproblems(Subproblem{
314314
Type: fmt.Sprintf("urn:smallstep:acme:error:%s", webhookErr.Code),
315315
Detail: webhookErr.Message,

authority/admin/api/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (war *webhookAdminResponder) UpdateProvisionerWebhook(w http.ResponseWriter
202202
}
203203
if !found {
204204
msg := fmt.Sprintf("provisioner %q has no webhook with the name %q", prov.Name, newWebhook.Name)
205-
err := admin.NewError(admin.ErrorNotFoundType, msg)
205+
err := admin.NewError(admin.ErrorNotFoundType, "%s", msg)
206206
render.Error(w, r, err)
207207
return
208208
}

authority/provisioner/jwk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (p *JWK) AuthorizeSSHSign(_ context.Context, token string) ([]SignOption, e
250250
// Use options in the token.
251251
if opts.CertType != "" {
252252
if certType, err = sshutil.CertTypeFromString(opts.CertType); err != nil {
253-
return nil, errs.BadRequestErr(err, err.Error())
253+
return nil, errs.BadRequestErr(err, "%s", err.Error())
254254
}
255255
}
256256
if opts.KeyID != "" {

authority/provisioner/ssh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func signSSHCertificate(key crypto.PublicKey, opts SignSSHOptions, signOpts []Si
9393
var templErr *sshutil.TemplateError
9494
if errors.As(err, &templErr) {
9595
return nil, errs.NewErr(http.StatusBadRequest, templErr,
96-
errs.WithMessage(templErr.Error()),
96+
errs.WithMessage("%s", templErr.Error()),
9797
errs.WithKeyVal("signOptions", signOpts),
9898
)
9999
}

authority/provisioner/x5c.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func (p *X5C) AuthorizeSSHSign(_ context.Context, token string) ([]SignOption, e
302302
// Use options in the token.
303303
if opts.CertType != "" {
304304
if certType, err = sshutil.CertTypeFromString(opts.CertType); err != nil {
305-
return nil, errs.BadRequestErr(err, err.Error())
305+
return nil, errs.BadRequestErr(err, "%s", err.Error())
306306
}
307307
}
308308
if opts.KeyID != "" {

authority/ssh.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (a *Authority) signSSH(ctx context.Context, key ssh.PublicKey, opts provisi
215215
for _, v := range keyValidators {
216216
if err := v.Valid(key); err != nil {
217217
return nil, nil, errs.ApplyOptions(
218-
errs.ForbiddenErr(err, err.Error()),
218+
errs.ForbiddenErr(err, "%s", err.Error()),
219219
errs.WithKeyVal("signOptions", signOpts),
220220
)
221221
}
@@ -232,7 +232,7 @@ func (a *Authority) signSSH(ctx context.Context, key ssh.PublicKey, opts provisi
232232
// Call enriching webhooks
233233
if err := a.callEnrichingWebhooksSSH(ctx, prov, webhookCtl, cr); err != nil {
234234
return nil, prov, errs.ApplyOptions(
235-
errs.ForbiddenErr(err, err.Error()),
235+
errs.ForbiddenErr(err, "%s", err.Error()),
236236
errs.WithKeyVal("signOptions", signOpts),
237237
)
238238
}
@@ -244,7 +244,7 @@ func (a *Authority) signSSH(ctx context.Context, key ssh.PublicKey, opts provisi
244244
switch {
245245
case errors.As(err, &te):
246246
return nil, prov, errs.ApplyOptions(
247-
errs.BadRequestErr(err, err.Error()),
247+
errs.BadRequestErr(err, "%s", err.Error()),
248248
errs.WithKeyVal("signOptions", signOpts),
249249
)
250250
case strings.HasPrefix(err.Error(), "error unmarshaling certificate"):
@@ -264,7 +264,7 @@ func (a *Authority) signSSH(ctx context.Context, key ssh.PublicKey, opts provisi
264264
// Use SignSSHOptions to modify the certificate validity. It will be later
265265
// checked or set if not defined.
266266
if err := opts.ModifyValidity(certTpl); err != nil {
267-
return nil, prov, errs.BadRequestErr(err, err.Error())
267+
return nil, prov, errs.BadRequestErr(err, "%s", err.Error())
268268
}
269269

270270
// Use provisioner modifiers.

authority/tls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (a *Authority) signX509(ctx context.Context, csr *x509.CertificateRequest,
197197

198198
if err := a.callEnrichingWebhooksX509(ctx, prov, webhookCtl, attData, csr); err != nil {
199199
return nil, prov, errs.ApplyOptions(
200-
errs.ForbiddenErr(err, err.Error()),
200+
errs.ForbiddenErr(err, "%s", err.Error()),
201201
errs.WithKeyVal("csr", csr),
202202
errs.WithKeyVal("signOptions", signOpts),
203203
)
@@ -209,7 +209,7 @@ func (a *Authority) signX509(ctx context.Context, csr *x509.CertificateRequest,
209209
switch {
210210
case errors.As(err, &te):
211211
return nil, prov, errs.ApplyOptions(
212-
errs.BadRequestErr(err, err.Error()),
212+
errs.BadRequestErr(err, "%s", err.Error()),
213213
errs.WithKeyVal("csr", csr),
214214
errs.WithKeyVal("signOptions", signOpts),
215215
)

0 commit comments

Comments
 (0)