Skip to content

test(shellmode): make command lookup independent of host PATH - #353

Merged
Patel230 merged 1 commit into
mainfrom
test/shellmode-path-independence
Oct 22, 2026
Merged

Patel230 merged 1 commit into
mainfrom
test/shellmode-path-independence

Conversation

@Patel230

@Patel230 Patel230 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

  • TestClassifyInput failed on a machine without make: ClassifyInput("make -C build") returned ClassAgent because isValidCommand used exec.LookPath directly, so results depended on the host toolchain.
  • The security job was red on a Go standard-library CVE: GO-2026-6443 (crypto/x509, fixed in Go 1.27.3).

What

  • Route command resolution through a package-level lookPath variable (defaults to exec.LookPath); production behavior is unchanged.
  • Add a stubCommands test helper that replaces lookup for the duration of a test and clears the package-level cmdCache, restoring both with t.Cleanup.
  • Use it in both classification tests so routing assertions depend only on the input, not on installed binaries or test order.
  • Commit policy: new commit policy CI job (scripts/check-commit-policy.sh) requires every commit in the PR/push to have a verified signature and rejects AI co-author or AI generation trailers (Claude, Copilot, GPT, Cursor, Gemini, Codex, Aider, etc.). The commit in this PR is GitHub-signed so it passes its own check.
  • Bump CI GO_VERSION to 1.27.3 for the x509 fix.

Verification

  • go test ./internal/features/shellmode/ -count=1 ✅ with no make on PATH
  • go vet ./internal/features/shellmode/ ✅
  • gofumpt -l / goimports -l clean ✅
  • Commit policy script correctly flags the old unsigned commit and passes the signed one ✅

@Patel230 Patel230 closed this Oct 22, 2026
@Patel230
Patel230 force-pushed the test/shellmode-path-independence branch from 4de9b3d to 4403e25 Compare October 22, 2026 09:42
- Indirect exec.LookPath through a package variable and stub it in tests so routing results do not depend on installed binaries (e.g. make).
- Clear the lookup cache around each stub so results cannot leak between tests.
- Add a commit-policy CI job requiring verified signatures and rejecting AI co-author/attribution trailers.
- Bump CI Go to 1.27.3 to clear GO-2026-6443 (crypto/x509).
@Patel230 Patel230 reopened this Oct 22, 2026
@Patel230
Patel230 merged commit 4fe5cd4 into main Oct 22, 2026
23 checks passed
@Patel230
Patel230 deleted the test/shellmode-path-independence branch October 22, 2026 10:35
Patel230 added a commit that referenced this pull request Oct 22, 2026
- Indirect exec.LookPath through a package variable and stub it in tests so routing results do not depend on installed binaries (e.g. make).
- Clear the lookup cache around each stub so results cannot leak between tests.
- Add a commit-policy CI job requiring verified signatures and rejecting AI co-author/attribution trailers.
- Bump CI Go to 1.27.3 to clear GO-2026-6443 (crypto/x509).
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