Repository navigation
chore(lint): enable gosec in golangci-lint - #1757
Conversation
|
Hey @mbrandenburger 👋 thanks for the PR! This comment updates automatically as you push changes -- think of it as your PR's live scoreboard! PR Checks✅ DCO Sign-off -- All commits have valid sign-offs. Nice work! ❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:
You'll need to sign your commits with GPG (e.g. ✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing! ❌ Issue Link -- This PR is not linked to any issue. Please reference an issue using a closing keyword (e.g. ⏳ All checks must pass before this PR can be reviewed. You've got this! |
SaidAltury-ibm
left a comment
There was a problem hiding this comment.
Thank you @mbrandenburger, LGTM. just link an issue
|
Tick the box to add this pull request to the merge queue (same as
|
Enables gosec and scopes it to the code that ships. A bare enable reports 220 findings. 95 are in _test.go files and 72 in the integration/ harness, where 0644 fixture certs, 0755 scratch directories, subprocess launches with generated paths and deliberately weak TLS in benchmarks describe what that code is for; those are excluded by path. G304/G703 are excluded because the file paths come from operator-supplied core.yaml and MSP directory configuration rather than untrusted input, G404 because math/rand is used for retry jitter and peer/orderer load-balancing and never for a secret, and G115 because the flagged conversions are vault version encoding and proto int32 fields. Each exclusion carries its reasoning in .golangci.yml. That leaves three fixes: the gRPC client disables session tickets, because VerifyPeerCertificate does not run on a resumed session and would otherwise be bypassed (G123); the sqlite driver creates its database directory 0750 instead of world-writable 0777; and the profiler creates its output directory 0750 instead of 0755. Two findings are annotated as false positives: the unsafe.Pointer comparison in the fabricx vault is deterministic lock ordering (G103), and the nil-ctx fallback in delivery.Run is documented behaviour, not a dropped request-scoped context (G118). Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
b1466d9 to
de8a4ee
Compare
Enables
gosecand scopes it to the code that ships.make checksis green.This is part of #1755 and #1741
Scoping
A bare enable reports 220 findings: 95 in
_test.go, 72 in theintegration/nwo harness, 1 inci/, 52 in library code. The test and harness findings describe what that code is for — 0644 fixture certs, 0755 scratch dirs, subprocess launches with generated paths, deliberately weak TLS in benchmarks — so they are excluded by path. Four rule classes are excluded globally, each with its reasoning in.golangci.yml:core.yaml/ MSP config, not untrusted input;filepath.Cleanwould silence without securingmath/randis retry jitter and peer/orderer load-balancing, never a secret or nonceint32fields; truncation only past 2^32 blocksFixes
platform/view/services/grpc/client.go—VerifyPeerCertificatedoes not run on a resumed TLS session, so a custom certificate check could be bypassed. Disables client-side session tickets to force a full handshake (G123). The one genuine security finding in the set.platform/view/services/storage/driver/sql/sqlite/persistence.go— database directory was created0777(world-writable), now0750.node/start/profile/profile.go— profile output directory0755→0750.Annotated false positives
platform/fabricx/core/vault/vault.go—unsafe.Pointercomparison is deterministic lock ordering (G103).platform/fabric/core/generic/delivery/delivery.go— the nil-ctx fallback is documented behaviour, not a dropped request context (G118).Verification
make checksexits 0 — 0 issues across all four linted modules,go fixclean. Unit tests pass for every touched package.Follow-up
Enabling gosec surfaced an unrelated remote-OOM in
comm/io/reader.go(unboundedmake([]byte, l)from a wire varint whenfsc.p2p.maxRecvMsgSizeis 0). Tracked separately in #1756 — not in this PR.