Repository navigation
Conversation
Run gosec across cmd/vmafx-{controller,node,server,operator,mcp,tune}/...,
pkg/..., and gen/go/... 38 raw findings — 10 in protoc-generated /
cgo trampoline code (excluded via -exclude-generated), 26 in
fork-original source. All 26 source findings resolved; CI gate added
in .github/workflows/go-ci.yml plus make lint-go target.
One real bug: cmd/vmafx-mcp/impl.go::describeModel accepted a
caller-supplied `name` and joined it onto the repo root before
os.Stat-ing the result. A request like {"name": "../../../etc/passwd"}
would have reached /etc/passwd because the candidate path was not
constrained to libvmaf.AllowedRoots(). Routed through
libvmaf.ValidatePath; new regression test
cmd/vmafx-mcp/impl_gosec_test.go::TestDescribeModelRejectsTraversal.
Other fixes:
- G306/G301: cmd/vmafx-tune/cmd/compare.go::writeOutput tightened
from 0o644 / 0o755 to 0o600 / 0o750.
- G104: runVmafScore's outFile.Close() and os.Remove(outPath)
errors now checked.
- 22 G204 / G304 / G202 false positives previously suppressed via
//nolint:gosec (which gosec ignores — it only honours #nosec)
rewritten to // #nosec G<rule> -- ... per CLAUDE §12 r12.
Deliverables: ADR-0983, docs/research/, changelog.d/security/,
docs/rebase-notes.md, docs/state.md row,
cmd/vmafx-mcp/AGENTS.md invariant #7.
Refs: ADR-0983.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lusoris
marked this pull request as ready for review
May 31, 2026 22:07
Contributor
Author
20 tasks done
lusoris
added a commit
that referenced
this pull request
May 31, 2026
…510) Re-run of the gosec static-security scan against the post-#505 / post-#509-close master tip. PR #509 had source conflicts with PR #505 on pkg/bisect/bisect.go and pkg/encoder/encoder.go; this v2 sweep applies the same security-hardening fixes while preserving the ctx + per-stage timeout that #505 added. Findings: 38 raw, 10 in generated/cgo trampoline code (excluded via -exclude-generated), 26 fork-original. All 26 source findings now discharged. Post-fix `gosec -exclude-generated ./...` returns 0 issues. Real bug fixed: - G304 in cmd/vmafx-mcp/impl.go::describeModel — joined caller-supplied `name` onto repo root and os.Stat-ed the result, allowing {"name": "../../../etc/passwd"} to escape libvmaf.AllowedRoots(). Routed through libvmaf.ValidatePath; regression test at cmd/vmafx-mcp/impl_gosec_test.go::TestDescribeModelRejectsTraversal. Hardening: - G306/G301 in cmd/vmafx-tune/cmd/compare.go::writeOutput — tightened to 0o600 (file) / 0o750 (directory). - G104 in cmd/vmafx-mcp/impl.go::runVmafScore — outFile.Close() and os.Remove(outPath) return values now checked. - G204/G304 ×22 — `//nolint:gosec` comments rewritten to `// #nosec G<rule> -- <citation>` (gosec ignores nolint:gosec). - G202 in cmd/vmafx-controller/queue/queue.go — verified safe (only repeatCommaQ output concatenated; status values bind via placeholders). CI gate: gosec step in .github/workflows/go-ci.yml + make lint-go target. Differs from PR #509: - pkg/bisect/bisect.go: keeps PR #505's exec.CommandContext + scoreTimeout() — just adds the #nosec G204 citation. - pkg/encoder/encoder.go: keeps PR #505's exec.CommandContext + encodeTimeout()/probeTimeout() — same. Verification: - gosec -exclude-generated -quiet ./... → 0 findings (was 26) - go vet ./... clean - go build ./... clean - go test -race ./cmd/vmafx-mcp/ -run TestDescribeModel → 5/5 pass - go test -race ./... (skip vmafx-operator envtest) → all packages OK except TestHandleVmafScore_RoutesToDirect + TestHandleDescribeModel_DirectAugments in cmd/vmafx-mcp/ which require libvmaf.so and fail identically on master (verified via stash + re-run). - bash scripts/ci/check-adr-numbering.sh → PASS - bash scripts/ci/check-copyright.sh → PASS - pre-commit run --files → PASS Refs ADR-0983. Co-authored-by: Lusoris <lusoris@pm.me> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gosecstatic-security scan across the Go surface(
cmd/vmafx-{controller,node,server,operator,mcp,tune}/...,pkg/...,gen/go/...). 38 raw findings → 0 in fork-original sourcepost-sweep, 10 in generated code excluded via
-exclude-generated.cmd/vmafx-mcp/impl.go::describeModelaccepted acaller-supplied
name, joined it onto the repo root, andos.Stat-edthe result —
{"name": "../../../etc/passwd"}would have escapedlibvmaf.AllowedRoots(). Routed throughlibvmaf.ValidatePath;regression test
cmd/vmafx-mcp/impl_gosec_test.go::TestDescribeModelRejectsTraversaladded.
.github/workflows/go-ci.ymlaftergo vetplus
make lint-goMakefile target. Future PRs touching Go gate ongosec -exclude-generated -quiet ./...returning 0 findings.Per-rule findings (pre / post)
gen/go/vmafx.pb.go::unsafe.Slice)pkg/libvmaf/direct.go)Per-finding fix summary
Real bug — G304 path traversal
cmd/vmafx-mcp/impl.go::describeModel— caller-suppliednamejoined to repo root, then opened. Fixed by routing the candidate
path through
libvmaf.ValidatePathso the lookup is bounded tolibvmaf.AllowedRoots().cmd/vmafx-mcp/impl_gosec_test.go::TestDescribeModelRejectsTraversalasserts the reject for
../../../etc/passwd,../../../../etc/shadow,/etc/passwd,/proc/self/environ.Permissions tightening — G301 / G306
cmd/vmafx-tune/cmd/compare.go::writeOutput—MkdirAll
0o755→0o750, WriteFile0o644→0o600. Reportsinclude dataset path identifiers; restrict to the owner.
Unhandled error — G104
cmd/vmafx-mcp/impl.go::runVmafScore—outFile.Close()andos.Remove(outPath)results now checked. Close failureshort-circuits the request; remove failure logs to stderr
(best-effort cleanup).
False positives now correctly cited — G204 / G304 / G202 (22 sites)
Every existing
//nolint:gosec ...was rewritten to// #nosec G<rule> -- <citation>. gosec does NOT parsegolangci-lint nolint directives — the old comments were dead text
that did not suppress anything. Per-site citations name the
validating helper (constant binary name,
libvmaf.ValidatePath,os.CreateTemp,os.MkdirTemp,exec.LookPath).Touched:
cmd/vmafx-mcp/impl.go(15),pkg/storage/fuse_mount.go,pkg/storage/http_serve.go,pkg/encoder/encoder.go,pkg/gpu/detect.go,pkg/ai/infer.go,pkg/bisect/bisect.go,cmd/vmafx-controller/queue/queue.go.Test additions
cmd/vmafx-mcp/impl_gosec_test.go::TestDescribeModelRejectsTraversal(1 test, 4 sub-cases) — path-traversal-style names rejected.
cmd/vmafx-mcp/impl_gosec_test.go::TestDescribeModelRejectsEmptyName— defence-in-depth on the empty-name guard.
Deliverables (CLAUDE.md §12 r11)
docs/research/gosec-findings-fix-sweep-2026-06-01.mdcmd/vmafx-mcp/AGENTS.mdinvariant chore(deps): Update dependency openai to >=2.38.0 #7changelog.d/security/gosec-findings-fix-sweep.mddocs/rebase-notes.mdTest plan
Go CIworkflow —go vet, the newgosec -exclude-generatedstep, and
go test(skipcmd/vmafx-operator— envtest binariesnot on hosted runner) all green.
beyond
// #noseccitations.Refs: ADR-0983.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
🤖 Generated with Claude Code