Skip to content

Commit f25e76a

Browse files
dependabot[bot]Daisuke Maki
andauthored
Bump golangci/golangci-lint-action from 6.1.1 to 6.2.0 (#1268)
* 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 * fix more instances of os.CreateTempDir * set p2c for newer jose * use t.Cleanup * remove parallel testing --------- 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 221e43e commit f25e76a

File tree

7 files changed

+26
-31
lines changed

7 files changed

+26
-31
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
@@ -138,8 +138,8 @@ func GenerateX25519Jwk() (jwk.Key, error) {
138138
return k, nil
139139
}
140140

141-
func WriteFile(template string, src io.Reader) (string, func(), error) {
142-
file, cleanup, err := CreateTempFile(template)
141+
func WriteFile(dir, template string, src io.Reader) (string, func(), error) {
142+
file, cleanup, err := CreateTempFile(dir, template)
143143
if err != nil {
144144
return "", nil, fmt.Errorf(`failed to create temporary file: %w`, err)
145145
}
@@ -156,14 +156,14 @@ func WriteFile(template string, src io.Reader) (string, func(), error) {
156156
return file.Name(), cleanup, nil
157157
}
158158

159-
func WriteJSONFile(template string, v interface{}) (string, func(), error) {
159+
func WriteJSONFile(dir, template string, v interface{}) (string, func(), error) {
160160
var buf bytes.Buffer
161161

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

169169
func DumpFile(t *testing.T, file string) {
@@ -215,8 +215,8 @@ func DumpFile(t *testing.T, file string) {
215215
t.Logf("=== END %s (formatted JSON) ===", file)
216216
}
217217

218-
func CreateTempFile(template string) (*os.File, func(), error) {
219-
file, err := os.CreateTemp("", template)
218+
func CreateTempFile(dir, template string) (*os.File, func(), error) {
219+
file, err := os.CreateTemp(dir, template)
220220
if err != nil {
221221
return nil, nil, fmt.Errorf(`failed to create temporary file: %w`, err)
222222
}
@@ -277,7 +277,7 @@ func DecryptJweFile(ctx context.Context, file string, alg jwa.KeyEncryptionAlgor
277277
return jwe.Decrypt(buf, jwe.WithKey(alg, rawkey))
278278
}
279279

280-
func EncryptJweFile(ctx context.Context, payload []byte, keyalg jwa.KeyEncryptionAlgorithm, keyfile string, contentalg jwa.ContentEncryptionAlgorithm, compressalg jwa.CompressionAlgorithm) (string, func(), error) {
280+
func EncryptJweFile(ctx context.Context, dir string, payload []byte, keyalg jwa.KeyEncryptionAlgorithm, keyfile string, contentalg jwa.ContentEncryptionAlgorithm, compressalg jwa.CompressionAlgorithm) (string, func(), error) {
281281
key, err := ParseJwkFile(ctx, keyfile)
282282
if err != nil {
283283
return "", nil, fmt.Errorf(`failed to parse keyfile %s: %w`, keyfile, err)
@@ -311,7 +311,7 @@ func EncryptJweFile(ctx context.Context, payload []byte, keyalg jwa.KeyEncryptio
311311
return "", nil, fmt.Errorf(`failed to encrypt payload: %w`, err)
312312
}
313313

314-
return WriteFile("jwx-test-*.jwe", bytes.NewReader(buf))
314+
return WriteFile(dir, "jwx-test-*.jwe", bytes.NewReader(buf))
315315
}
316316

317317
func VerifyJwsFile(ctx context.Context, file string, alg jwa.SignatureAlgorithm, jwkfile string) ([]byte, error) {
@@ -342,7 +342,7 @@ func VerifyJwsFile(ctx context.Context, file string, alg jwa.SignatureAlgorithm,
342342
return jws.Verify(buf, jws.WithKey(alg, pubkey))
343343
}
344344

345-
func SignJwsFile(ctx context.Context, payload []byte, alg jwa.SignatureAlgorithm, keyfile string) (string, func(), error) {
345+
func SignJwsFile(ctx context.Context, dir string, payload []byte, alg jwa.SignatureAlgorithm, keyfile string) (string, func(), error) {
346346
key, err := ParseJwkFile(ctx, keyfile)
347347
if err != nil {
348348
return "", nil, fmt.Errorf(`failed to parse keyfile %s: %w`, keyfile, err)
@@ -353,5 +353,5 @@ func SignJwsFile(ctx context.Context, payload []byte, alg jwa.SignatureAlgorithm
353353
return "", nil, fmt.Errorf(`failed to sign payload: %w`, err)
354354
}
355355

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

jwe/jwe_test.go

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

680-
f, err := os.CreateTemp("", "test-read-file-*.jwe")
680+
f, err := os.CreateTemp(t.TempDir(), "test-read-file-*.jwe")
681681
if !assert.NoError(t, err, `os.CreateTemp should succeed`) {
682682
return
683683
}

jws/jws_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ func TestDecode_ES384Compact_NoSigTrim(t *testing.T) {
863863
func TestReadFile(t *testing.T) {
864864
t.Parallel()
865865

866-
f, err := os.CreateTemp("", "test-read-file-*.jws")
866+
f, err := os.CreateTemp(t.TempDir(), "test-read-file-*.jws")
867867
require.NoError(t, err, `io.CreateTemp should succeed`)
868868
defer f.Close()
869869

jwt/jwt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ func TestSignTyp(t *testing.T) {
739739
func TestReadFile(t *testing.T) {
740740
t.Parallel()
741741

742-
f, err := os.CreateTemp("", "test-read-file-*.jwt")
742+
f, err := os.CreateTemp(t.TempDir(), "test-read-file-*.jwt")
743743
if !assert.NoError(t, err, `os.CreateTemp should succeed`) {
744744
return
745745
}

jwx_test.go

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

9090
// Test compatibility against `jose` tool
9191
func TestJoseCompatibility(t *testing.T) {
92-
t.Parallel()
93-
9492
if testing.Short() {
9593
t.Logf("Skipped during short tests")
9694
return
@@ -101,8 +99,11 @@ func TestJoseCompatibility(t *testing.T) {
10199
return
102100
}
103101

102+
// latchset/jose uses a larger p2c count than we allow
103+
jwe.Settings(jwe.WithMaxPBES2Count(32768))
104+
t.Cleanup(func() { jwe.Settings(jwe.WithMaxPBES2Count(10000)) })
105+
104106
t.Run("jwk", func(t *testing.T) {
105-
t.Parallel()
106107
testcases := []struct {
107108
Name string
108109
Raw interface{}
@@ -140,8 +141,6 @@ func TestJoseCompatibility(t *testing.T) {
140141
for _, tc := range testcases {
141142
tc := tc
142143
t.Run(tc.Name, func(t *testing.T) {
143-
t.Parallel()
144-
145144
ctx, cancel := context.WithCancel(context.Background())
146145
defer cancel()
147146

@@ -173,8 +172,6 @@ func TestJoseCompatibility(t *testing.T) {
173172
// In order to avoid doing this in an ad-hoc way, we're just going to
174173
// ask our jose package for the algorithms that it supports, and generate
175174
// the list dynamically
176-
177-
t.Parallel()
178175
ctx, cancel := context.WithCancel(context.Background())
179176
defer cancel()
180177
set, err := jose.Algorithms(ctx, t)
@@ -233,7 +230,6 @@ func TestJoseCompatibility(t *testing.T) {
233230
}
234231
})
235232
t.Run("jws", func(t *testing.T) {
236-
t.Parallel()
237233
tests := []jwa.SignatureAlgorithm{
238234
jwa.ES256,
239235
//jwa.ES256K,
@@ -253,7 +249,6 @@ func TestJoseCompatibility(t *testing.T) {
253249
for _, test := range tests {
254250
test := test
255251
t.Run(test.String(), func(t *testing.T) {
256-
t.Parallel()
257252
ctx, cancel := context.WithCancel(context.Background())
258253
defer cancel()
259254
joseJwsInteropTest(ctx, test, t)
@@ -329,7 +324,7 @@ func joseInteropTest(ctx context.Context, spec interopTest, t *testing.T) {
329324
}
330325
})
331326
t.Run("Encrypt with jwx, Decrypt with jose", func(t *testing.T) {
332-
jwxCryptFile, jwxCryptCleanup, err := jwxtest.EncryptJweFile(ctx, expected, spec.alg, joseJwkFile, spec.enc, jwa.NoCompress)
327+
jwxCryptFile, jwxCryptCleanup, err := jwxtest.EncryptJweFile(ctx, t.TempDir(), expected, spec.alg, joseJwkFile, spec.enc, jwa.NoCompress)
333328
if !assert.NoError(t, err, `jwxtest.EncryptJweFile should succeed`) {
334329
return
335330
}
@@ -383,7 +378,7 @@ func joseJwsInteropTest(ctx context.Context, alg jwa.SignatureAlgorithm, t *test
383378
}
384379
})
385380
t.Run("Sign with jwx, Verify with jose", func(t *testing.T) {
386-
jwxCryptFile, jwxCryptCleanup, err := jwxtest.SignJwsFile(ctx, expected, alg, joseJwkFile)
381+
jwxCryptFile, jwxCryptCleanup, err := jwxtest.SignJwsFile(ctx, t.TempDir(), expected, alg, joseJwkFile)
387382
if !assert.NoError(t, err, `jwxtest.SignJwsFile should succeed`) {
388383
return
389384
}

0 commit comments

Comments
 (0)