Skip to content

Commit 00a6fca

Browse files
authored
Merge pull request #599 from 1Password/scoot/fix/fix-linting-errors-and-re-enable-linting
Fix linting errors and re-enable golangci linters
2 parents 41b719b + 1391bd9 commit 00a6fca

7 files changed

Lines changed: 20 additions & 21 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ linters:
33
default: none
44
enable:
55
# Defaults:
6+
- errcheck
67
- govet
78
- ineffassign
89
- unused
910
# Extra:
1011
- asciicheck
1112
- bidichk
12-
disable:
13-
# Scott L: currently these produce errors that need to be fixed in a seprate PR
14-
- errcheck
1513
- depguard
1614
- staticcheck
1715

plugins/aws/sts_provisioner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func (p assumeRoleProvider) Retrieve(ctx context.Context) (aws.Credentials, erro
271271
return aws.Credentials{}, err
272272
}
273273

274-
err = p.stsCacheWriter.Put(credentials)
274+
err = p.Put(credentials)
275275
if err != nil {
276276
return aws.Credentials{}, err
277277
}
@@ -308,7 +308,7 @@ func (p mfaSessionTokenProvider) Retrieve(ctx context.Context) (aws.Credentials,
308308
return aws.Credentials{}, err
309309
}
310310

311-
err = p.stsCacheWriter.Put(credentials)
311+
err = p.Put(credentials)
312312
if err != nil {
313313
return aws.Credentials{}, err
314314
}

plugins/readme/api_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TryReadMeConfigFile() sdk.Importer {
6666
return
6767
}
6868

69-
var website string = "https://dash.readme.com/go/" + config.Subdomain
69+
var website = "https://dash.readme.com/go/" + config.Subdomain
7070

7171
out.AddCandidate(sdk.ImportCandidate{
7272
NameHint: config.Subdomain,

sdk/plugintest/example_secrets.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package plugintest
22

33
import (
4+
"crypto/rand"
45
"fmt"
56
"log"
6-
"math/rand"
7+
"math/big"
78
"strings"
8-
"time"
99

1010
"github.com/1Password/shell-plugins/sdk/schema"
1111
)
@@ -18,9 +18,6 @@ const (
1818
secretExampleSuffix = "EXAMPLE"
1919
)
2020

21-
var seededRand = rand.New(
22-
rand.NewSource(time.Now().UnixNano()))
23-
2421
func ExampleSecretFromComposition(v schema.ValueComposition) string {
2522
prefix := getPrefix(v)
2623
suffix := getSuffix(v)
@@ -65,10 +62,14 @@ func stringFromCharset(length int, charset string) (string, error) {
6562
if charset == "" {
6663
return "", fmt.Errorf("invalid charset provided")
6764
}
68-
65+
max := big.NewInt(int64(len(charset)))
6966
b := make([]byte, length)
7067
for i := range b {
71-
b[i] = charset[seededRand.Intn(len(charset))]
68+
n, err := rand.Int(rand.Reader, max)
69+
if err != nil {
70+
return "", fmt.Errorf("reading random: %w", err)
71+
}
72+
b[i] = charset[n.Int64()]
7273
}
7374
return string(b), nil
7475
}

sdk/plugintest/validation_report.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type ValidationReportPrinter struct {
5959
}
6060

6161
func (p *ValidationReportPrinter) Print() {
62-
if p.Reports == nil || len(p.Reports) == 0 {
62+
if len(p.Reports) == 0 {
6363
color.Cyan("No reports to print")
6464
return
6565
}
@@ -108,19 +108,19 @@ func (p *ValidationReportPrinter) printChecks(checks []schema.ValidationCheck) {
108108
}
109109

110110
func (p *ValidationReportPrinter) printHeading(heading string) {
111-
p.Format.Heading.Printf("# %s\n\n", heading)
111+
_, _ = p.Format.Heading.Printf("# %s\n\n", heading)
112112
}
113113

114114
func (p *ValidationReportPrinter) printCheck(check schema.ValidationCheck) {
115115
if check.Assertion {
116-
p.Format.Success.Printf("✔ %s\n", check.Description)
116+
_, _ = p.Format.Success.Printf("✔ %s\n", check.Description)
117117
return
118118
}
119119

120120
if check.Severity == schema.ValidationSeverityWarning {
121-
p.Format.Warning.Printf("⚠ %s\n", check.Description)
121+
_, _ = p.Format.Warning.Printf("⚠ %s\n", check.Description)
122122
return
123123
}
124124

125-
p.Format.Error.Printf("✘ %s\n", check.Description)
125+
_, _ = p.Format.Error.Printf("✘ %s\n", check.Description)
126126
}

sdk/rpc/server/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (t *RPCServer) ExecutableNeedsAuth(req proto.ExecutableNeedsAuthRequest, re
107107
needsAuth, ok := t.needsAuth[req.ExecutableID]
108108
if !ok || needsAuth == nil {
109109
return &errFunctionFieldNotSet{
110-
objName: req.ExecutableID.String(),
110+
objName: req.String(),
111111
funcName: "NeedsAuth",
112112
}
113113
}
@@ -134,7 +134,7 @@ func (t *RPCServer) CredentialImport(req proto.ImportCredentialRequest, resp *sd
134134
importer, ok := t.importers[req.CredentialID]
135135
if !ok || importer == nil {
136136
return &errFunctionFieldNotSet{
137-
objName: req.CredentialID.String(),
137+
objName: req.String(),
138138
funcName: "Importer",
139139
}
140140
}

sdk/schema/executable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (c CredentialUsage) Validate() (bool, ValidationReport) {
130130

131131
report.AddCheck(ValidationCheck{
132132
Description: "Credential usage has either a credential reference or selection defined, but not both",
133-
Assertion: (c.SelectFrom != nil || c.Name != "") && !(c.SelectFrom != nil && c.Name != ""),
133+
Assertion: (c.SelectFrom != nil || c.Name != "") && (c.SelectFrom == nil || c.Name == ""),
134134
Severity: ValidationSeverityError,
135135
})
136136
return report.IsValid(), report

0 commit comments

Comments
 (0)