Commit f963d3c
authored
fix: keep test scaffolding out of the binary and bump the toolchain (#254)
gosec became blocking in the shared workflow
([netresearch/.github#312](netresearch/.github#312))
and immediately failed here, as did govulncheck. Both are fixed.
## gosec: test scaffolding was in the production binary
G103 (*audit unsafe*) pointed at `internal/server/test_helpers.go`. The
file has no `_test` suffix, so it compiled into `package server` — the
mock LDAP client, the fixture builder, and its `reflect`+`unsafe` write
to `ldap.Object`'s unexported `dn` field all shipped in the binary.
Nothing called them, but they were there.
Split by what production actually needs: `LDAPClient` is the only
declaration used outside tests (2 call sites) and moves to
`ldap_client.go`; `MockLDAP`, `NewMockLDAP`, `setObjectDN` and
`newTestServer` move to `test_helpers_test.go`. `unsafe` and `reflect`
are now compiled into the test binary only.
**No suppression comment.** gosec runs without `-tests`, so the finding
is gone because the code left the build — not because it was silenced. A
`#nosec` there would have suppressed nothing while implying it had.
The unsafe write itself is unchanged and still justified: simple-ldap-go
writes `Object.dn` only in `objectFromEntry` when decoding a directory
response and exposes no constructor taking a DN, so a fixture cannot be
built through its public API. That library gap is worth closing
separately; it is not this PR's job.
## govulncheck: four stdlib advisories
GO-2026-5856 (crypto/tls), GO-2026-5039 (net/textproto), GO-2026-5037
(crypto/x509), GO-2026-4971 (net). The module was on `go 1.25.1` with no
`toolchain`. It now uses `go 1.26` with `toolchain go1.26.5`, matching
ofelia.
## Verification
Run with go1.26.5:
- gosec: `Issues : 0`, exit 0
- govulncheck: `Your code is affected by 0 vulnerabilities`, exit 0
- `go vet ./...` clean, `go test ./...` passes
- `grep '"unsafe"'` over non-test files returns nothing3 files changed
Lines changed: 21 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 14 | | |
23 | 15 | | |
24 | 16 | | |
25 | 17 | | |
26 | 18 | | |
27 | 19 | | |
28 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
29 | 26 | | |
30 | 27 | | |
31 | 28 | | |
| |||
0 commit comments