Skip to content

Commit 9891358

Browse files
authored
go1.25 (#104)
1 parent 83b98d5 commit 9891358

30 files changed

+198
-76
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,53 @@
11
name: CI
2+
23
on:
34
push:
45
branches:
56
- master
67
pull_request:
78
branches:
89
- master
10+
schedule:
11+
# Run daily at 2 AM UTC to check for new vulnerabilities
12+
- cron: "0 2 * * *"
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
921
jobs:
1022
test:
23+
timeout-minutes: 15
1124
strategy:
1225
matrix:
13-
go-version: [1.21.x, 1.22.x, 1.23.x]
26+
go-version: [1.25.x, 1.24.x]
1427
os: [ubuntu-latest]
1528
runs-on: ${{ matrix.os }}
1629
steps:
17-
- uses: actions/setup-go@v3
30+
- uses: actions/checkout@v6
31+
with:
32+
persist-credentials: false
33+
34+
- uses: actions/setup-go@v6
1835
with:
1936
go-version: ${{ matrix.go-version }}
20-
- uses: actions/checkout@v3
37+
cache: true
38+
2139
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v3
40+
uses: golangci/golangci-lint-action@v9
41+
with:
42+
version: v2.7.2
43+
44+
- name: Build
45+
run: go build -v ./...
46+
47+
- name: Run govulncheck
48+
uses: golang/govulncheck-action@v1
2349
with:
24-
version: v1.63
25-
- run: go vet ./...
26-
- run: go test ./...
27-
- run: env GOARCH=386 go test ./...
50+
go-version-input: ${{ matrix.go-version }}
51+
52+
- name: Test
53+
run: go test -race ./...

.golangci.yml

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,85 @@
1-
linters-settings:
2-
gocritic:
3-
disabled-checks:
4-
- ifElseChain
5-
- elseif
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
tests: true
6+
7+
formatters:
8+
enable:
9+
- gofumpt
610

711
linters:
812
enable:
9-
- gofmt
10-
- gocritic
11-
- unconvert
12-
- revive
13-
- govet
13+
# Core recommended linters
14+
- errcheck # Checks for unchecked errors
15+
- govet # Go vet checks
16+
- ineffassign # Detects ineffectual assignments
17+
- staticcheck # Advanced static analysis
18+
- unused # Finds unused code
19+
20+
# Code quality
21+
- misspell # Finds commonly misspelled words
22+
- unconvert # Unnecessary type conversions (already enabled in original)
23+
- unparam # Finds unused function parameters
24+
- gocritic # Various checks (already enabled in original)
25+
- revive # Fast, configurable linter (already enabled in original)
26+
27+
# Security and best practices
28+
- gosec # Security-focused linter
29+
- bodyclose # Checks HTTP response body closed
30+
- noctx # Finds HTTP requests without context
31+
32+
settings:
33+
gocritic:
34+
disabled-checks:
35+
- ifElseChain
36+
- elseif
37+
38+
govet:
39+
enable-all: true
40+
disable:
41+
- shadow
42+
- fieldalignment
43+
44+
revive:
45+
enable-all-rules: false
46+
47+
exclusions:
48+
rules:
49+
# Exclude specific revive rules
50+
- linters:
51+
- revive
52+
text: "package-comments"
53+
54+
- linters:
55+
- revive
56+
text: "exported"
57+
58+
# Exclude specific staticcheck rules
59+
- linters:
60+
- staticcheck
61+
text: "ST1005"
62+
63+
# Exclude specific gocritic rules
64+
- linters:
65+
- gocritic
66+
text: "ifElseChain"
67+
68+
# Exclude misspell in test vectors (generated test data)
69+
- linters:
70+
- misspell
71+
path: "encoding/basex/vectors_test.go"
72+
73+
# Exclude staticcheck suggestions in test/production code
74+
- linters:
75+
- staticcheck
76+
text: "QF1003"
77+
78+
- linters:
79+
- staticcheck
80+
text: "QF1008"
81+
82+
# Exclude unparam warnings in test code
83+
- linters:
84+
- unparam
85+
path: "_test\\.go"

armor.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ func (s *framedDecoderStream) loadHeader() (err error) {
197197
// Read from a framedDeecoderStream. The frame is the "BEGIN FOO." block
198198
// at the beginning, and the "END FOO." block at the end.
199199
func (s *framedDecoderStream) Read(p []byte) (n int, err error) {
200-
201200
if s.state == fdsHeader {
202201
err = s.loadHeader()
203202
if err != nil {

armor62.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ func NewArmor62DecoderStream(r io.Reader, hc HeaderChecker, fc FrameChecker) (io
5151

5252
// Armor62Open runs armor stream decoding, but on a string, and it outputs
5353
// a string. It does not do any validation on the header and footer.
54-
// Deprecated: user Armor62OpenWithValidation instead.
54+
//
55+
// Deprecated: use Armor62OpenWithValidation instead.
5556
func Armor62Open(msg string) (body []byte, header string, footer string, err error) {
5657
body, _, header, footer, err = Armor62OpenWithValidation(msg, nil, nil)
5758
return body, header, footer, err

armor62_sign.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func NewSignDetachedArmor62Stream(version Version, detachedsig io.Writer, signer
6060
return nil, err
6161
}
6262
return closeForwarder([]io.WriteCloser{out, enc}), nil
63-
6463
}
6564

6665
// SignDetachedArmor62 returns a detached armored signature of plaintext from signer.

armor_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ func brandCheck(t *testing.T, received string) {
2929
require.Equal(t, ourBrand, received)
3030
}
3131

32-
const hdr = "BEGIN ACME SALTPACK ENCRYPTED MESSAGE"
33-
const ftr = "END ACME SALTPACK ENCRYPTED MESSAGE"
32+
const (
33+
hdr = "BEGIN ACME SALTPACK ENCRYPTED MESSAGE"
34+
ftr = "END ACME SALTPACK ENCRYPTED MESSAGE"
35+
)
3436

3537
func testArmor(t *testing.T, sz int) {
3638
m := msg(sz)
@@ -58,6 +60,7 @@ func TestArmor1024(t *testing.T) {
5860
func TestArmor8192(t *testing.T) {
5961
testArmor(t, 8192)
6062
}
63+
6164
func TestArmor65536(t *testing.T) {
6265
testArmor(t, 65536)
6366
}
@@ -129,7 +132,8 @@ func TestBinaryInput(t *testing.T) {
129132
case <-time.After(5 * time.Second):
130133
buf := make([]byte, 1<<16)
131134
runtime.Stack(buf, true)
132-
os.Stderr.Write(buf)
135+
_, err := os.Stderr.Write(buf)
136+
require.NoError(t, err)
133137
t.Fatal("timed out waiting for Armor62Open to finish")
134138
}
135139

chunk_reader_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ func exampleEncode(plaintext []byte) []byte {
9797
for i := 0; i < len(plaintext); i++ {
9898
block := exampleBlock{
9999
PayloadCiphertext: []byte{^plaintext[i]},
100-
Seqno: packetSeqno(i + 1),
101-
IsFinal: i == len(plaintext)-1,
100+
//nolint:gosec // i is a valid slice index, conversion is safe
101+
Seqno: packetSeqno(i + 1),
102+
IsFinal: i == len(plaintext)-1,
102103
}
103104
err := encoder.Encode(block)
104105
if err != nil {

classify_and_decrypt.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const (
3333
// saltpack message. If err is nil, msgType will return the type of the encoded message, but this does *NOT* guarantee that the
3434
// rest of the message is well formed.
3535
func IsSaltpackBinary(stream *bufio.Reader) (msgType MessageType, version Version, err error) {
36-
3736
b, err := stream.Peek(minLengthToIdentifyBinarySaltpack)
3837
if err == bufio.ErrBufferFull {
3938
return MessageTypeUnknown, Version{}, ErrShortSliceOrBuffer
@@ -48,7 +47,6 @@ func IsSaltpackBinary(stream *bufio.Reader) (msgType MessageType, version Versio
4847
// long enough to make this determination, or if it does not appear to contain a binary saltpack message. If err is nil, msgType
4948
// will return the type of the encoded message, but this does *NOT* guarantee that the rest of the message is well formed.
5049
func IsSaltpackBinarySlice(b []byte) (msgType MessageType, version Version, err error) {
51-
5250
// To avoid decoding the whole header, part of the messagepack decoding is done manually
5351
// instead of through go-codec. See https://github.com/msgpack/msgpack/blob/master/spec.md
5452
// for details on the encoding.
@@ -241,7 +239,8 @@ func ClassifyStream(stream *bufio.Reader) (isArmored bool, brand string, message
241239
// as well as some informtation about the stream. The brand is only returned for armored ciphertexts, mki only
242240
// for encryption-mode ciphertext, senderPublic only for signcryption-mode ciphertexts.
243241
func ClassifyEncryptedStreamAndMakeDecoder(source io.Reader, decryptionKeyring SigncryptKeyring, keyResolver SymmetricKeyResolver) (
244-
plainsource io.Reader, msgType MessageType, mki *MessageKeyInfo, senderPublic SigningPublicKey, isArmored bool, brand string, ver Version, err error) {
242+
plainsource io.Reader, msgType MessageType, mki *MessageKeyInfo, senderPublic SigningPublicKey, isArmored bool, brand string, ver Version, err error,
243+
) {
245244
stream := bufio.NewReader(source)
246245

247246
isArmored, _, msgType, ver, err = ClassifyStream(stream)

common_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func TestComputePayloadAuthenticator(t *testing.T) {
2727
authenticator := computePayloadAuthenticator(macKey, payloadHash)
2828
if !authenticator.Equal(expectedAuthenticators[i]) {
2929
t.Errorf("Got %#v, expected %#v", authenticator, expectedAuthenticators[i])
30-
3130
}
3231
i++
3332
}
@@ -81,20 +80,23 @@ func runTestsOverVersions(t *testing.T, prefix string, fs []func(t *testing.T, v
8180
var secret1 = boxSecretKey{
8281
key: RawBoxKey{0x08},
8382
}
83+
8484
var secret2 = boxSecretKey{
8585
key: RawBoxKey{0x10},
8686
}
8787

8888
var eSecret1 = boxSecretKey{
8989
key: RawBoxKey{0x18},
9090
}
91+
9192
var eSecret2 = boxSecretKey{
9293
key: RawBoxKey{0x20},
9394
}
9495

9596
var public1 = boxPublicKey{
9697
key: RawBoxKey{0x5},
9798
}
99+
98100
var public2 = boxPublicKey{
99101
key: RawBoxKey{0x6},
100102
}

decrypt.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func (ds *decryptStream) tryVisibleReceivers(hdr *EncryptionHeader, ephemeralKey
131131
return nil, nil, -1, ErrBadLookup
132132
}
133133

134+
//nolint:gosec // orig is a valid slice index, conversion is safe
134135
nonce := nonceForPayloadKeyBox(hdr.Version, uint64(orig))
135136
payloadKeySlice, err := sk.Unbox(ephemeralKey, nonce, hdr.Receivers[orig].PayloadKeyBox)
136137
if err != nil {
@@ -160,6 +161,7 @@ func (ds *decryptStream) tryHiddenReceivers(hdr *EncryptionHeader, ephemeralKey
160161

161162
for i, r := range hdr.Receivers {
162163
if len(r.ReceiverKID) == 0 {
164+
//nolint:gosec // i is a valid slice index, conversion is safe
163165
nonce := nonceForPayloadKeyBox(hdr.Version, uint64(i))
164166
payloadKeySlice, err := shared.Unbox(nonce, r.PayloadKeyBox)
165167
if err != nil {
@@ -259,7 +261,6 @@ func computeMACKeyReceiver(version Version, index uint64, secret BoxSecretKey, p
259261
}
260262

261263
func (ds *decryptStream) processBlock(ciphertext []byte, authenticators []payloadAuthenticator, isFinal bool, seqno packetSeqno) ([]byte, error) {
262-
263264
blockNum := encryptionBlockNumber(seqno - 1)
264265

265266
if err := blockNum.check(); err != nil {

0 commit comments

Comments
 (0)