Skip to content

Commit 05f95e5

Browse files
authored
Upgrade certificate 0.26.0 | fix linter warnings (#1140)
* Update certificates to 0.26.0 * Fix linter warnings
1 parent ea6ffb3 commit 05f95e5

File tree

33 files changed

+81
-81
lines changed

33 files changed

+81
-81
lines changed

command/ca/admin/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func listAction(ctx *cli.Context) (err error) {
9797
if isNotSuperAdmin && a.Type == linkedca.Admin_SUPER_ADMIN {
9898
return false
9999
}
100-
if len(provName) > 0 && a.ProvisionerName != provName {
100+
if provName != "" && a.ProvisionerName != provName {
101101
return false
102102
}
103103
return true

command/ca/init.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ func initCommand() cli.Command {
3939
UsageText: `**step ca init**
4040
[**--root**=<file>] [**--key**=<file>] [**--key-password-file**=<file>] [**--pki**] [**--ssh**]
4141
[**--helm**] [**--deployment-type**=<name>] [**--name**=<name>]
42-
[**--dns**=<dns>] [**--address**=<address>] [**--provisioner**=<name>]
43-
[**--admin-subject**=<string>] [**--provisioner-password-file**=<file>]
44-
[**--password-file**=<file>] [**--ra**=<type>] [**--kms**=<type>]
45-
[**--with-ca-url**=<url>] [**--no-db**] [**--remote-management**]
42+
[**--dns**=<dns>] [**--address**=<address>] [**--provisioner**=<name>]
43+
[**--admin-subject**=<string>] [**--provisioner-password-file**=<file>]
44+
[**--password-file**=<file>] [**--ra**=<type>] [**--kms**=<type>]
45+
[**--with-ca-url**=<url>] [**--no-db**] [**--remote-management**]
4646
[**--acme**] [**--context**=<name>] [**--profile**=<name>] [**--authority**=<name>]`,
4747
Description: `**step ca init** command initializes a public key infrastructure (PKI) to be
4848
used by the Certificate Authority.`,
@@ -476,7 +476,7 @@ func initAction(ctx *cli.Context) (err error) {
476476
if v, ok := keyManager.(interface{ ValidateName(s string) error }); ok {
477477
validateFunc = v.ValidateName
478478
} else {
479-
validateFunc = func(s string) error {
479+
validateFunc = func(_ string) error {
480480
return nil
481481
}
482482
}

command/ca/provisioner/add.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ SCEP
9999
**step ca provisioner add** <name> **--type**=SCEP [**--force-cn**] [**--challenge**=<challenge>]
100100
[**--capabilities**=<capabilities>] [**--include-root**] [**--exclude-intermediate**]
101101
[**--min-public-key-length**=<length>] [**--encryption-algorithm-identifier**=<id>]
102-
[**--scep-decrypter-certificate-file**=<file>] [**--scep-decrypter-key-file**=<file>]
102+
[**--scep-decrypter-certificate-file**=<file>] [**--scep-decrypter-key-file**=<file>]
103103
[**--scep-decrypter-key-uri**=<uri>] [**--scep-decrypter-key-password-file**=<file>]
104-
[**--admin-cert**=<file>] [**--admin-key**=<file>] [**--admin-subject**=<subject>]
104+
[**--admin-cert**=<file>] [**--admin-key**=<file>] [**--admin-subject**=<subject>]
105105
[**--admin-provisioner**=<name>] [**--admin-password-file**=<file>]
106106
[**--ca-url**=<uri>] [**--root**=<file>] [**--context**=<name>] [**--ca-config**=<file>]`,
107107
Flags: []cli.Flag{
@@ -449,7 +449,7 @@ func createJWKDetails(ctx *cli.Context) (*linkedca.ProvisionerDetails, error) {
449449
password string
450450
)
451451

452-
if passwordFile := ctx.String("password-file"); len(passwordFile) > 0 {
452+
if passwordFile := ctx.String("password-file"); passwordFile != "" {
453453
password, err = utils.ReadStringPasswordFromFile(passwordFile)
454454
if err != nil {
455455
return nil, err

command/ca/provisioner/update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ SCEP
9090
[**--minimum-public-key-length**=<length>] [**--encryption-algorithm-identifier**=<id>]
9191
[**--scep-decrypter-certificate-file**=<file>] [**--scep-decrypter-key-file**=<file>]
9292
[**--scep-decrypter-key-uri**=<uri>] [**--scep-decrypter-key-password-file**=<file>]
93-
[**--admin-cert**=<file>] [**--admin-key**=<file>] [**--admin-subject**=<subject>]
93+
[**--admin-cert**=<file>] [**--admin-key**=<file>] [**--admin-subject**=<subject>]
9494
[**--admin-provisioner**=<name>] [**--admin-password-file**=<file>]
9595
[**--ca-url**=<uri>] [**--root**=<file>] [**--context**=<name>] [**--ca-config**=<file>]`,
9696
Flags: []cli.Flag{
@@ -486,7 +486,7 @@ func updateJWKDetails(ctx *cli.Context, p *linkedca.Provisioner) error {
486486
err error
487487
password string
488488
)
489-
if passwordFile := ctx.String("password-file"); len(passwordFile) > 0 {
489+
if passwordFile := ctx.String("password-file"); passwordFile != "" {
490490
password, err = utils.ReadStringPasswordFromFile(passwordFile)
491491
if err != nil {
492492
return err

command/ca/rekey.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ func rekeyCertificateAction(ctx *cli.Context) error {
239239
}
240240

241241
var expiresIn, rekeyPeriod time.Duration
242-
if s := ctx.String("expires-in"); len(s) > 0 {
242+
if s := ctx.String("expires-in"); s != "" {
243243
if expiresIn, err = time.ParseDuration(s); err != nil {
244244
return errs.InvalidFlagValue(ctx, "expires-in", s, "")
245245
}
246246
}
247-
if s := ctx.String("rekey-period"); len(s) > 0 {
247+
if s := ctx.String("rekey-period"); s != "" {
248248
if rekeyPeriod, err = time.ParseDuration(s); err != nil {
249249
return errs.InvalidFlagValue(ctx, "rekey-period", s, "")
250250
}
@@ -265,7 +265,7 @@ func rekeyCertificateAction(ctx *cli.Context) error {
265265
}
266266

267267
pidFile := ctx.String("pid-file")
268-
if len(pidFile) > 0 {
268+
if pidFile != "" {
269269
pidB, err := os.ReadFile(pidFile)
270270
if err != nil {
271271
return errs.FileError(err, pidFile)

command/ca/renew.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ func renewCertificateAction(ctx *cli.Context) error {
243243
}
244244

245245
var expiresIn, renewPeriod time.Duration
246-
if s := ctx.String("expires-in"); len(s) > 0 {
246+
if s := ctx.String("expires-in"); s != "" {
247247
if expiresIn, err = time.ParseDuration(s); err != nil {
248248
return errs.InvalidFlagValue(ctx, "expires-in", s, "")
249249
}
250250
}
251-
if s := ctx.String("renew-period"); len(s) > 0 {
251+
if s := ctx.String("renew-period"); s != "" {
252252
if renewPeriod, err = time.ParseDuration(s); err != nil {
253253
return errs.InvalidFlagValue(ctx, "renew-period", s, "")
254254
}
@@ -269,7 +269,7 @@ func renewCertificateAction(ctx *cli.Context) error {
269269
}
270270

271271
pidFile := ctx.String("pid-file")
272-
if len(pidFile) > 0 {
272+
if pidFile != "" {
273273
pidB, err := os.ReadFile(pidFile)
274274
if err != nil {
275275
return errs.FileError(err, pidFile)

command/ca/revoke.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func revokeCertificateAction(ctx *cli.Context) error {
231231

232232
// If cert and key are passed then infer the serial number and certificate
233233
// that should be revoked.
234-
if len(certFile) > 0 || len(keyFile) > 0 {
234+
if certFile != "" || keyFile != "" {
235235
// Must be using cert/key flags for mTLS revoke so should be 0 cmd line args.
236236
if ctx.NArg() > 0 {
237237
return errors.Errorf("'%s %s --cert <certificate> --key <key>' expects no additional positional arguments", ctx.App.Name, ctx.Command.Name)
@@ -242,10 +242,10 @@ func revokeCertificateAction(ctx *cli.Context) error {
242242
if keyFile == "" {
243243
return errs.RequiredWithFlag(ctx, "cert", "key")
244244
}
245-
if len(token) > 0 {
245+
if token != "" {
246246
errs.IncompatibleFlagWithFlag(ctx, "cert", "token")
247247
}
248-
if len(serial) > 0 {
248+
if serial != "" {
249249
errs.IncompatibleFlagWithFlag(ctx, "cert", "serial")
250250
}
251251
var cert []*x509.Certificate
@@ -306,7 +306,7 @@ func newRevokeFlow(ctx *cli.Context, certFile, keyFile string) (*revokeFlow, err
306306
if err != nil {
307307
return nil, err
308308
}
309-
if len(certFile) > 0 || len(keyFile) > 0 {
309+
if certFile != "" || keyFile != "" {
310310
if err := offlineClient.VerifyClientCert(certFile, keyFile); err != nil {
311311
return nil, err
312312
}
@@ -332,7 +332,7 @@ func (f *revokeFlow) getClient(ctx *cli.Context, serial, token string) (cautils.
332332
rootFile := ctx.String("root")
333333
var options []ca.ClientOption
334334

335-
if len(token) > 0 {
335+
if token != "" {
336336
tok, err := jose.ParseSigned(token)
337337
if err != nil {
338338
return nil, errors.Wrap(err, "error parsing flag '--token'")
@@ -346,7 +346,7 @@ func (f *revokeFlow) getClient(ctx *cli.Context, serial, token string) (cautils.
346346
}
347347

348348
// Prepare client for bootstrap or provisioning tokens
349-
if len(claims.SHA) > 0 && len(claims.Audience) > 0 && strings.HasPrefix(strings.ToLower(claims.Audience[0]), "http") {
349+
if claims.SHA != "" && len(claims.Audience) > 0 && strings.HasPrefix(strings.ToLower(claims.Audience[0]), "http") {
350350
if caURL == "" {
351351
caURL = claims.Audience[0]
352352
}

command/ca/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func tokenAction(ctx *cli.Context) error {
332332
return err
333333
}
334334
}
335-
if len(outputFile) > 0 {
335+
if outputFile != "" {
336336
return utils.WriteFile(outputFile, []byte(token), 0600)
337337
}
338338
fmt.Println(token)

command/certificate/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func getTruststoreOptions(ctx *cli.Context) ([]truststore.Option, error) {
227227

228228
prefix := ctx.String("prefix")
229229
if prefix == "" {
230-
if len(cert.Subject.CommonName) > 0 {
230+
if cert.Subject.CommonName != "" {
231231
prefix = cert.Subject.CommonName + " "
232232
} else {
233233
prefix = "Smallstep Development CA "

command/certificate/key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func keyAction(ctx *cli.Context) error {
7777
return err
7878
}
7979

80-
if outputFile := ctx.String("output-file"); len(outputFile) > 0 {
80+
if outputFile := ctx.String("output-file"); outputFile != "" {
8181
if err := utils.WriteFile(outputFile, pem.EncodeToMemory(block), 0600); err != nil {
8282
return err
8383
}

0 commit comments

Comments
 (0)