Skip to content

fix: handle the gosec findings without a baseline - #5

Merged
lusoris merged 13 commits into
mainfrom
fix/gosec-findings
Oct 23, 2026
Merged

lusoris merged 13 commits into
mainfrom
fix/gosec-findings

Conversation

@lusoris

@lusoris lusoris commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

gosec findings in the Go tools drop from 280 on main to 31, and all 31 left are in the frozen P1-SRC-02 runner. Every other finding is fixed in code or marked at its line with a reason; no finding is anchored in a baseline file.

The one injection-shaped site, first

tools/knowledge-mcp/projection.go built SELECT COUNT(*) FROM <table> with the table name taken from the receipt it reads in. The first commit checks every receipt table against the fixed projectionColumns allowlist before any query and fails with the unknown name. projection_table_guard_test.go plants a receipt table x; DROP TABLE components: it fails before the guard and passes after.

The projection validator is split into one function per check; the checks run in the same order as before.

The other findings

  • G104 (unhandled errors): handled, wrapped or joined with the cleanup error; none marked.
  • Fixed in code as well: G115 integer conversions through a checked helper, G122, G301 and G302 directory and file modes, G306 write modes, G602, and some G204, G304 and G703 sites.
  • 87 line marks #nosec Gxxx -- reason, each naming why the input is safe: G304 35, G703 19, G204 12, G704 6, G202 4, G401 3, G505 3, G101 2, G302 1, G306 1, G702 1.
  • G401 and G505 stay: Git blob object ids are SHA-1 by protocol, and SHA-256 binds the bytes separately.
  • G101 stays: the two strings are public tokenizer version ids, not credentials.

The frozen runner keeps its bytes

tools/knowledge-registry/source-acquisition-runner is the P1-SRC-02 runner (review state implementation_frozen); p1-src03-acquisition-runner/runner_test.go pins the sha256 of its files. Any fix or line mark there would break those pins, so the module stays byte-identical to main and keeps its 31 findings (G104 25, G115, G602, G401, G505, G704 2). The adoption change declares them as a dated per-file exception until the runner is frozen again with fixes.

Verification

  • gosec ./... per module: 0 issues in eight modules, 31 in the frozen runner.
  • The frozen runner files match all 7 pinned digests.
  • go test -p 4 -count=1 ./... passes in seven modules. knowledge-retrieval (5) and p1-src03-acquisition-runner (3) fail on exactly the tests main fails: 2 read the canonical JSON vectors, which the adoption change adds, and 6 read shared registry data this repository does not hold yet. A follow-up change makes those 6 read a declared data root and skip by name without it.
  • The commits are split per module so each one can be reviewed and reverted on its own.
  • The cleanup-error and checked-I/O helpers are copied into each module that needs them: every tool is its own Go module and there is no shared library module yet. praetorctl dedupe scan . counts 94 duplicate function groups on this branch against 80 on main.

Order: engine-adoption-knowledge-gosec-debt-20261023

Check receipt table names against the fixed projection column map before
constructing count queries. Split validation into bounded steps and retain
wrapped database errors.

Add receipt injection, unknown and empty table cases, plus known-table and
count-mismatch coverage. Planted checks fail before the guard and pass
afterward; the complete knowledge-mcp module test suite passes.

Signed-off-by: lusoris <lusoris@proton.me>
Reject traversal paths and malformed content digests before materializing
mirrors. Keep generated mirrors and retained evidence private and check
SSH length conversions. Document explicit compiler and signing execution
plus trusted input paths at their source lines.

Planted path and digest cases fail before the fix; module tests and
gosec pass without a baseline.

Signed-off-by: lusoris <lusoris@proton.me>
Join close failures with operation errors across rooted reads and writes,
and retain cleanup failures in quarantine issues. Check SSH envelope
lengths before conversion and document validated file and verifier inputs.

Planted close-failure regression fails before the fix; module tests and
gosec pass without a baseline.

Signed-off-by: lusoris <lusoris@proton.me>
Preserve close failures during rooted store cleanup and create new output
directories with owner access only. Justify descriptor-checked source
paths and fixed ssh-keygen invocations at their finding lines.

Planted close-failure and directory-mode cases fail before the fix; module
tests and gosec pass without a baseline.

Signed-off-by: lusoris <lusoris@proton.me>
Close embedding responses on every decode result and join close failures
with filesystem operation errors. Create private output directories and
document public tokenizer identifiers, digest-pinned executables and
validated paths at their finding lines.

Restore shared canonical vectors from the adoption commit at their pinned
SHA-256. Gosec and targeted security tests pass. The full module suite is
blocked by missing admission artifacts and sandbox uid mapping that the
existing trusted ssh-keygen ownership check correctly rejects.

Signed-off-by: lusoris <lusoris@proton.me>
Join descriptor and HTTP cleanup errors, use checked UID conversion, and
replace manual slice comparison with slices.Equal. Preserve Git-object
transport bounds and document protocol SHA-1 and pinned API origins.

Planted boundary and close-error tests fail before fixes. Module tests
and gosec pass without a baseline.

Signed-off-by: lusoris <lusoris@proton.me>
Handle every reported unchecked close and response-drain error. Bound
UID conversion and retain no-follow descriptor and content-hash checks.
Document Git SHA-1 identity and pinned GitHub API transport.

Gosec passes without a baseline; new security tests pass. The full module
suite remains blocked by absent schemas and legacy frozen-source pins.
Frozen trust manifests and their expected hashes remain intact.

Signed-off-by: lusoris <lusoris@proton.me>
Join descriptor, store and response cleanup failures. Check UID bounds
and preserve signed-plan, exact origin and no-redirect contracts.
Justify protocol SHA-1 and fixed ssh-keygen execution at source.

Module tests and gosec pass without a baseline; planted close and UID
boundary tests fail before fixes.

Signed-off-by: lusoris <lusoris@proton.me>
…errors

Preserve HTTP drain and close failures while retaining exact origin,
response and object bounds. Keep generated files private and document
operator-selected input paths plus protocol-required Git SHA-1.

Module tests and gosec pass without a baseline.

Signed-off-by: lusoris <lusoris@proton.me>
Preserve I/O and cleanup failures, check credential UID conversions and
use rooted descriptor operations for publication trees and suite copies.
Reject symlink roots and entries before changing modes or copying data.
Tighten acceptance artifact permissions and justify fixed SQL fragments,
validated inputs and descriptor-pinned execution at their source lines.

Order publication cleanup before writing status so failures remove
published trees and record degraded state. Planted failure, traversal and
boundary checks reproduce the old behavior. Module tests and gosec pass.

Signed-off-by: lusoris <lusoris@proton.me>
Propagate retrieval placement and sealing failures to publication cleanup
so failed trees cannot remain at their published paths. Reject unexpected
staging inspection errors. Keep catalog rejection nonfatal only after
the rejected retrieval tree has been unsealed and removed successfully.

The planted symlink-root regression fails before the fix and passes with
all published trees absent and degraded status recorded. Positive, rename
boundary and nested catalog-rejection cases pass. Module tests and gosec
pass, and independent review approves the correction.

Signed-off-by: lusoris <lusoris@proton.me>
The vectors copy came in with the retrieval cleanup commit, without
the copy and refresh checks that keep it pinned to its source. The
adoption change adds the copy together with those checks, so this
branch no longer carries it.

Signed-off-by: lusoris <lusoris@proton.me>
The gosec change rewrote cas.go, contract.go and github.go of the
source acquisition runner, whose bytes the P1-SRC-03 runner test pins
(implementation_frozen). The runner module is back to the bytes of
main, together with the helper and test files that belonged to the
rewrite. Its gosec findings are handled by a dated per-file exception
until the runner is frozen again with fixes.

Signed-off-by: lusoris <lusoris@proton.me>
@lusoris
lusoris merged commit 1ef1bb5 into main Oct 23, 2026
2 checks passed
lusoris added a commit that referenced this pull request Oct 23, 2026
Restores the P1-SRC-03 and v3 runner files that their embedded execution manifests pin by digest; #5 had rewritten them. Every pinned repository file matches its manifest again; the gosec findings in these files move to dated per-file exceptions.

Signed-off-by: lusoris <lusoris@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant