Skip to content

Commit fea42b5

Browse files
dependabot[bot]Daisuke Maki
andauthored
Bump golangci/golangci-lint-action from 6.1.1 to 6.2.0 (#1269)
* Bump golangci/golangci-lint-action from 6.1.1 to 6.2.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.1.1 to 6.2.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@971e284...ec5d184) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * appease linter --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Daisuke Maki <lestrrat+github@github.com>
1 parent 19d4fae commit fea42b5

File tree

8 files changed

+27
-33
lines changed

8 files changed

+27
-33
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
1010
with:
1111
go-version-file: "go.mod"
12-
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
12+
- uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0
1313
- name: Run go vet
1414
run: |
1515
go vet ./...

internal/jose/jose.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func Algorithms(ctx context.Context, t *testing.T) (*AlgorithmSet, error) {
125125
func GenerateJwk(ctx context.Context, t *testing.T, template string) (string, func(), error) {
126126
t.Helper()
127127

128-
file, cleanup, err := jwxtest.CreateTempFile("jwx-jose-key-*.jwk")
128+
file, cleanup, err := jwxtest.CreateTempFile(t.TempDir(), "jwx-jose-key-*.jwk")
129129
if err != nil {
130130
return "", nil, fmt.Errorf(`failed to create temporary file: %w`, err)
131131
}
@@ -158,7 +158,7 @@ func EncryptJwe(ctx context.Context, t *testing.T, payload []byte, alg string, k
158158

159159
var pfile string
160160
if len(payload) > 0 {
161-
fn, pcleanup, perr := jwxtest.WriteFile("jwx-jose-payload-*", bytes.NewReader(payload))
161+
fn, pcleanup, perr := jwxtest.WriteFile(t.TempDir(), "jwx-jose-payload-*", bytes.NewReader(payload))
162162
if perr != nil {
163163
return "", nil, fmt.Errorf(`failed to write payload to file: %w`, perr)
164164
}
@@ -168,7 +168,7 @@ func EncryptJwe(ctx context.Context, t *testing.T, payload []byte, alg string, k
168168
defer pcleanup()
169169
}
170170

171-
ofile, ocleanup, oerr := jwxtest.CreateTempFile(`jwx-jose-key-*.jwe`)
171+
ofile, ocleanup, oerr := jwxtest.CreateTempFile(t.TempDir(), `jwx-jose-key-*.jwe`)
172172
if oerr != nil {
173173
return "", nil, fmt.Errorf(`failed to create temporary file: %w`, oerr)
174174
}
@@ -205,7 +205,7 @@ func DecryptJwe(ctx context.Context, t *testing.T, cfile, kfile string) ([]byte,
205205
func FmtJwe(ctx context.Context, t *testing.T, data []byte) ([]byte, error) {
206206
t.Helper()
207207

208-
fn, pcleanup, perr := jwxtest.WriteFile("jwx-jose-fmt-data-*", bytes.NewReader(data))
208+
fn, pcleanup, perr := jwxtest.WriteFile(t.TempDir(), "jwx-jose-fmt-data-*", bytes.NewReader(data))
209209
if perr != nil {
210210
return nil, fmt.Errorf(`failed to write data to file: %w`, perr)
211211
}
@@ -237,7 +237,7 @@ func SignJws(ctx context.Context, t *testing.T, payload []byte, keyfile string,
237237

238238
var pfile string
239239
if len(payload) > 0 {
240-
fn, pcleanup, perr := jwxtest.WriteFile("jwx-jose-payload-*", bytes.NewReader(payload))
240+
fn, pcleanup, perr := jwxtest.WriteFile(t.TempDir(), "jwx-jose-payload-*", bytes.NewReader(payload))
241241
if perr != nil {
242242
return "", nil, fmt.Errorf(`failed to write payload to file: %w`, perr)
243243
}
@@ -247,7 +247,7 @@ func SignJws(ctx context.Context, t *testing.T, payload []byte, keyfile string,
247247
defer pcleanup()
248248
}
249249

250-
ofile, ocleanup, oerr := jwxtest.CreateTempFile(`jwx-jose-sig-*.jws`)
250+
ofile, ocleanup, oerr := jwxtest.CreateTempFile(t.TempDir(), `jwx-jose-sig-*.jws`)
251251
if oerr != nil {
252252
return "", nil, fmt.Errorf(`failed to create temporary file: %w`, oerr)
253253
}

internal/jwxtest/jwxtest.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ func GenerateX25519Jwk() (jwk.Key, error) {
135135
return k, nil
136136
}
137137

138-
func WriteFile(template string, src io.Reader) (string, func(), error) {
139-
file, cleanup, err := CreateTempFile(template)
138+
func WriteFile(dir, template string, src io.Reader) (string, func(), error) {
139+
file, cleanup, err := CreateTempFile(dir, template)
140140
if err != nil {
141141
return "", nil, fmt.Errorf(`failed to create temporary file: %w`, err)
142142
}
@@ -153,14 +153,14 @@ func WriteFile(template string, src io.Reader) (string, func(), error) {
153153
return file.Name(), cleanup, nil
154154
}
155155

156-
func WriteJSONFile(template string, v interface{}) (string, func(), error) {
156+
func WriteJSONFile(dir, template string, v interface{}) (string, func(), error) {
157157
var buf bytes.Buffer
158158

159159
enc := json.NewEncoder(&buf)
160160
if err := enc.Encode(v); err != nil {
161161
return "", nil, fmt.Errorf(`failed to encode object to JSON: %w`, err)
162162
}
163-
return WriteFile(template, &buf)
163+
return WriteFile(dir, template, &buf)
164164
}
165165

166166
func DumpFile(t *testing.T, file string) {
@@ -206,8 +206,8 @@ func DumpFile(t *testing.T, file string) {
206206
t.Logf("=== END %s (formatted JSON) ===", file)
207207
}
208208

209-
func CreateTempFile(template string) (*os.File, func(), error) {
210-
file, err := os.CreateTemp("", template)
209+
func CreateTempFile(dir, template string) (*os.File, func(), error) {
210+
file, err := os.CreateTemp(dir, template)
211211
if err != nil {
212212
return nil, nil, fmt.Errorf(`failed to create temporary file: %w`, err)
213213
}
@@ -268,7 +268,7 @@ func DecryptJweFile(ctx context.Context, file string, alg jwa.KeyEncryptionAlgor
268268
return jwe.Decrypt(buf, jwe.WithKey(alg, rawkey))
269269
}
270270

271-
func EncryptJweFile(ctx context.Context, payload []byte, keyalg jwa.KeyEncryptionAlgorithm, keyfile string, contentalg jwa.ContentEncryptionAlgorithm, compressalg jwa.CompressionAlgorithm) (string, func(), error) {
271+
func EncryptJweFile(ctx context.Context, dir string, payload []byte, keyalg jwa.KeyEncryptionAlgorithm, keyfile string, contentalg jwa.ContentEncryptionAlgorithm, compressalg jwa.CompressionAlgorithm) (string, func(), error) {
272272
key, err := ParseJwkFile(ctx, keyfile)
273273
if err != nil {
274274
return "", nil, fmt.Errorf(`failed to parse keyfile %s: %w`, keyfile, err)
@@ -302,7 +302,7 @@ func EncryptJweFile(ctx context.Context, payload []byte, keyalg jwa.KeyEncryptio
302302
return "", nil, fmt.Errorf(`failed to encrypt payload: %w`, err)
303303
}
304304

305-
return WriteFile("jwx-test-*.jwe", bytes.NewReader(buf))
305+
return WriteFile(dir, "jwx-test-*.jwe", bytes.NewReader(buf))
306306
}
307307

308308
func VerifyJwsFile(ctx context.Context, file string, alg jwa.SignatureAlgorithm, jwkfile string) ([]byte, error) {
@@ -333,7 +333,7 @@ func VerifyJwsFile(ctx context.Context, file string, alg jwa.SignatureAlgorithm,
333333
return jws.Verify(buf, jws.WithKey(alg, pubkey))
334334
}
335335

336-
func SignJwsFile(ctx context.Context, payload []byte, alg jwa.SignatureAlgorithm, keyfile string) (string, func(), error) {
336+
func SignJwsFile(ctx context.Context, dir string, payload []byte, alg jwa.SignatureAlgorithm, keyfile string) (string, func(), error) {
337337
key, err := ParseJwkFile(ctx, keyfile)
338338
if err != nil {
339339
return "", nil, fmt.Errorf(`failed to parse keyfile %s: %w`, keyfile, err)
@@ -344,5 +344,5 @@ func SignJwsFile(ctx context.Context, payload []byte, alg jwa.SignatureAlgorithm
344344
return "", nil, fmt.Errorf(`failed to sign payload: %w`, err)
345345
}
346346

347-
return WriteFile("jwx-test-*.jws", bytes.NewReader(buf))
347+
return WriteFile(dir, "jwx-test-*.jws", bytes.NewReader(buf))
348348
}

jwe/jwe_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func TestGHIssue230(t *testing.T) {
535535
func TestReadFile(t *testing.T) {
536536
const s = `eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.OKOawDo13gRp2ojaHV7LFpZcgV7T6DVZKTyKOMTYUmKoTCVJRgckCL9kiMT03JGeipsEdY3mx_etLbbWSrFr05kLzcSr4qKAq7YN7e9jwQRb23nfa6c9d-StnImGyFDbSv04uVuxIp5Zms1gNxKKK2Da14B8S4rzVRltdYwam_lDp5XnZAYpQdb76FdIKLaVmqgfwX7XWRxv2322i-vDxRfqNzo_tETKzpVLzfiwQyeyPGLBIO56YJ7eObdv0je81860ppamavo35UgoRdbYaBcoh9QcfylQr66oc6vFWXRcZ_ZT2LawVCWTIy3brGPi6UklfCpIMfIjf7iGdXKHzg.48V1_ALb6US04U3b.5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6jiSdiwkIr3ajwQzaBtQD_A.XFBoMYUZodetZdvTiFvSkQ`
537537

538-
f, err := os.CreateTemp("", "test-read-file-*.jwe")
538+
f, err := os.CreateTemp(t.TempDir(), "test-read-file-*.jwe")
539539
require.NoError(t, err, `os.CreateTemp should succeed`)
540540
defer f.Close()
541541

jwe/speed_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88
var s = []byte(`eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.OKOawDo13gRp2ojaHV7LFpZcgV7T6DVZKTyKOMTYUmKoTCVJRgckCL9kiMT03JGeipsEdY3mx_etLbbWSrFr05kLzcSr4qKAq7YN7e9jwQRb23nfa6c9d-StnImGyFDbSv04uVuxIp5Zms1gNxKKK2Da14B8S4rzVRltdYwam_lDp5XnZAYpQdb76FdIKLaVmqgfwX7XWRxv2322i-vDxRfqNzo_tETKzpVLzfiwQyeyPGLBIO56YJ7eObdv0je81860ppamavo35UgoRdbYaBcoh9QcfylQr66oc6vFWXRcZ_ZT2LawVCWTIy3brGPi6UklfCpIMfIjf7iGdXKHzg.48V1_ALb6US04U3b.5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6jiSdiwkIr3ajwQzaBtQD_A.XFBoMYUZodetZdvTiFvSkQ`)
99

1010
func BenchmarkSplitLib(b *testing.B) {
11-
for i := 0; i < b.N; i++ {
11+
for range b.N {
1212
SplitLib(s)
1313
}
1414
}
1515

1616
func BenchmarkSplitManual(b *testing.B) {
1717
ret := make([][]byte, 5)
18-
for i := 0; i < b.N; i++ {
18+
for range b.N {
1919
SplitManual(ret, s)
2020
}
2121
}

jws/jws_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ func TestDecode_ES384Compact_NoSigTrim(t *testing.T) {
923923
func TestReadFile(t *testing.T) {
924924
t.Parallel()
925925

926-
f, err := os.CreateTemp("", "test-read-file-*.jws")
926+
f, err := os.CreateTemp(t.TempDir(), "test-read-file-*.jws")
927927
require.NoError(t, err, `io.CreateTemp should succeed`)
928928
defer f.Close()
929929

jwt/jwt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ func TestSignTyp(t *testing.T) {
614614
func TestReadFile(t *testing.T) {
615615
t.Parallel()
616616

617-
f, err := os.CreateTemp("", "test-read-file-*.jwt")
617+
f, err := os.CreateTemp(t.TempDir(), "test-read-file-*.jwt")
618618
require.NoError(t, err, `os.CreateTemp should succeed`)
619619
defer f.Close()
620620

jwx_test.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ func TestDecoderSetting(t *testing.T) {
7878

7979
// Test compatibility against `jose` tool
8080
func TestJoseCompatibility(t *testing.T) {
81-
t.Parallel()
82-
8381
if testing.Short() {
8482
t.Logf("Skipped during short tests")
8583
return
@@ -90,8 +88,10 @@ func TestJoseCompatibility(t *testing.T) {
9088
return
9189
}
9290

91+
jwe.Settings(jwe.WithMaxPBES2Count(32768))
92+
t.Cleanup(func() { jwe.WithMaxPBES2Count(10000) })
93+
9394
t.Run("jwk", func(t *testing.T) {
94-
t.Parallel()
9595
testcases := []struct {
9696
Name string
9797
Raw interface{}
@@ -127,8 +127,6 @@ func TestJoseCompatibility(t *testing.T) {
127127

128128
for _, tc := range testcases {
129129
t.Run(tc.Name, func(t *testing.T) {
130-
t.Parallel()
131-
132130
ctx, cancel := context.WithCancel(context.Background())
133131
defer cancel()
134132

@@ -152,8 +150,6 @@ func TestJoseCompatibility(t *testing.T) {
152150
// In order to avoid doing this in an ad-hoc way, we're just going to
153151
// ask our jose package for the algorithms that it supports, and generate
154152
// the list dynamically
155-
156-
t.Parallel()
157153
ctx, cancel := context.WithCancel(context.Background())
158154
defer cancel()
159155
set, err := jose.Algorithms(ctx, t)
@@ -203,15 +199,13 @@ func TestJoseCompatibility(t *testing.T) {
203199

204200
for _, test := range tests {
205201
t.Run(fmt.Sprintf("%s-%s", test.alg, test.enc), func(t *testing.T) {
206-
t.Parallel()
207202
ctx, cancel := context.WithCancel(context.Background())
208203
defer cancel()
209204
joseInteropTest(ctx, test, t)
210205
})
211206
}
212207
})
213208
t.Run("jws", func(t *testing.T) {
214-
t.Parallel()
215209
tests := []jwa.SignatureAlgorithm{
216210
jwa.ES256(),
217211
//jwa.ES256K,
@@ -289,7 +283,7 @@ func joseInteropTest(ctx context.Context, spec interopTest, t *testing.T) {
289283
require.Equal(t, expected, payload, `decrypted payloads should match`)
290284
})
291285
t.Run("Encrypt with jwx, Decrypt with jose", func(t *testing.T) {
292-
jwxCryptFile, jwxCryptCleanup, err := jwxtest.EncryptJweFile(ctx, expected, spec.alg, joseJwkFile, spec.enc, jwa.NoCompress())
286+
jwxCryptFile, jwxCryptCleanup, err := jwxtest.EncryptJweFile(ctx, t.TempDir(), expected, spec.alg, joseJwkFile, spec.enc, jwa.NoCompress())
293287
require.NoError(t, err, `jwxtest.EncryptJweFile should succeed`)
294288
defer jwxCryptCleanup()
295289

@@ -325,7 +319,7 @@ func joseJwsInteropTest(ctx context.Context, alg jwa.SignatureAlgorithm, t *test
325319
require.Equal(t, expected, payload, `decrypted payloads should match`)
326320
})
327321
t.Run("Sign with jwx, Verify with jose", func(t *testing.T) {
328-
jwxCryptFile, jwxCryptCleanup, err := jwxtest.SignJwsFile(ctx, expected, alg, joseJwkFile)
322+
jwxCryptFile, jwxCryptCleanup, err := jwxtest.SignJwsFile(ctx, t.TempDir(), expected, alg, joseJwkFile)
329323
require.NoError(t, err, `jwxtest.SignJwsFile should succeed`)
330324
defer jwxCryptCleanup()
331325

0 commit comments

Comments
 (0)