Skip to content

test(marketplace): cover static skill-scan heuristics - #41

Merged
mar-schmidt merged 1 commit into
Podiom:masterfrom
alexsmolya:codex/issue-36-heuristics-tests
Aug 24, 2026
Merged

mar-schmidt merged 1 commit into
Podiom:masterfrom
alexsmolya:codex/issue-36-heuristics-tests

Conversation

@alexsmolya

Copy link
Copy Markdown
Contributor

Closes #36

Adds focused, table-driven tests for the existing static marketplace heuristics.

Coverage includes:

  • scannableText for scripts, Markdown, extensionless scripts/ entries, and non-text assets.
  • All current scriptRules, including pipe-to-shell, network calls, credential paths, base64 blobs, and dynamic execution.
  • Script-rule negative cases, including a curl download without a shell pipe and benign prose.
  • All current promptRules entries plus negative SKILL.md-style prose.
  • dedupeFindings duplicate collapse and distinct (File, Rule) retention.

Production scanner logic was not changed. These tests verify the current regex behavior; they do not claim to provide complete security coverage.

Validation:

  • go test ./internal/marketplace/...
  • go vet ./...
  • git diff --check

The repository-wide Go suite was also attempted. Marketplace tests passed; one unrelated adapter test was blocked by the sandbox refusing a write under /home/alex/.codex.

@mar-schmidt

Copy link
Copy Markdown
Collaborator

Thanks @alexsmolya — second one from you in three minutes, and same apology as on #40: your CI was held in action_required because GitHub gates workflow runs from first-time contributors. That was on us, not you. Approved, it's running now.

Verified locally in the meantime:

  • go test ./internal/marketplace/... -count=1 — pass
  • gofmt -l internal/marketplace/heuristics_test.go — clean
  • go vet ./internal/marketplace/... — clean
  • One added file, no production logic touched

Two things worth calling out.

The negative cases are what make this valuable. TestApplyRulesScriptRules_Negatives asserting that a plain curl ... archive.tar.gz line produces exactly network-call and nothing else is a real assertion about rule precision — it would catch someone later widening the pipe-to-shell regex until it starts firing on any curl. A test suite that only proves the rules fire on bad input tells you nothing about false-positive rate, which for a security scanner is the failure mode that actually costs you users.

Second, I appreciate the honesty in the description: "These tests verify the current regex behavior; they do not claim to provide complete security coverage." That's exactly the right framing and I'd rather have it stated than implied. These lock in current behaviour so it can be changed deliberately — they're a regression net, not a safety guarantee.

On the sandbox note in your description — the unrelated adapter test that wanted to write under your home directory is a known rough edge on our side and nothing to do with your change. Don't worry about it.

Leaving the merge to @mar-schmidt.

@mar-schmidt

Copy link
Copy Markdown
Collaborator

Merged — thanks @alexsmolya, this is the stronger of your two.

Verified: scannableText, applyRules and dedupeFindings are all at 100% coverage after this. I mutation-tested dedupeFindings by making it return nil and your test failed as it should, so these are real assertions, not just execution.

Splitting the positive and negative rule cases into separate test funcs (_Negatives, _NegativeProse) makes the failure output actually readable when something breaks. Appreciated.

@alexsmolya
alexsmolya deleted the codex/issue-36-heuristics-tests branch August 24, 2026 19:06
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.

internal/marketplace/heuristics.go: static skill-scan heuristics have zero tests

2 participants