fix(content-policy): bind pinned installer evidence#2086
Conversation
📝 WalkthroughWalkthroughThis PR tightens content policy validation for GitHub scripts by replacing a simple URL-based immutability check with a contextual evidence-binding mechanism that verifies pinned scripts are tied to git clone and commit checkout commands in installer execution flows. ChangesImmutable Script Binding Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Important Gittensory found maintainer review notesPublic GitHub metadata was checked for review readiness. Gittensor-specific context appears only when confirmed. Readiness score: 93/100
Signal definitions
Review context
Maintainer notes
Contributor next steps
Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. Learn more about Gittensor contribution workflows. |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/content-policy-validation.test.ts (1)
290-335: 💤 Low valueConsider adding a test case for
git switch --detachvariant.The
checkoutCommitIndexfunction supports bothgit checkoutandgit switch --detachfor checking out a pinned commit, but the test suite only exercises thegit checkoutpath. Adding a test withgit switch --detach ${revision}would improve confidence in that code path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/content-policy-validation.test.ts` around lines 290 - 335, Add a new test variant in tests/content-policy-validation.test.ts mirroring the "allows cloned local scripts with immutable script source evidence" case but use the alternative checkout command supported by checkoutCommitIndex: replace occurrences of "git checkout ${revision}" in both the installCommand and the bash snippet with "git switch --detach ${revision}" (give the new it(...) a distinct name like "allows cloned local scripts with immutable script source evidence using git switch --detach"); call runContentPolicy the same way (e.g., with "same_repo_direct" or a new scenario name if needed), then assert result.status is 0 and that the output.reviewFlags does not contain { id: "mutable_script_install_source" } just like the original test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/content-policy-validation.test.ts`:
- Around line 290-335: Add a new test variant in
tests/content-policy-validation.test.ts mirroring the "allows cloned local
scripts with immutable script source evidence" case but use the alternative
checkout command supported by checkoutCommitIndex: replace occurrences of "git
checkout ${revision}" in both the installCommand and the bash snippet with "git
switch --detach ${revision}" (give the new it(...) a distinct name like "allows
cloned local scripts with immutable script source evidence using git switch
--detach"); call runContentPolicy the same way (e.g., with "same_repo_direct" or
a new scenario name if needed), then assert result.status is 0 and that the
output.reviewFlags does not contain { id: "mutable_script_install_source" } just
like the original test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9a24a1f5-931a-465e-8c9f-e9e49be820ef
📒 Files selected for processing (2)
scripts/ci/validate-content-policy.mjstests/content-policy-validation.test.ts
🔍 Maintainer advisory reviewReviewed 2 changed file(s) — two independent AI reviewers. This is an advisory review — it does not merge or close the PR. Suggested action: 🛠️ Request changes. (reviewers split: merge / request changes) Address the items below before merging. Reviewer A · Suggestions
Worth double-checking
Reviewer B · Suggestions
Worth double-checking
|
Motivation
mutable_script_install_sourcecheck even when the pinned URL was unrelated to the cloned repo or the executed local script.git cloneis pinned and actually checked out before execution.Description
githubSourceRefto includeownerandrepometadata and addgithubRepoRef/githubRepoKeyhelpers to identify repository origins for submitted URLs inscripts/ci/validate-content-policy.mjs.collectGitCloneRepos), normalize and collect local installer script paths (collectLocalScriptInstallRefs/normalizeScriptPath), detect checkout of a pinned commit (checkoutCommitIndex), and validate bound evidence (hasBoundImmutableGithubScriptEvidence).mutable_script_install_sourceis suppressed only when a pinned script URL matches the cloned repo, matches the executed script path, and the install instructions explicitly check out the pinned commit before running the script inscripts/ci/validate-content-policy.mjs.tests/content-policy-validation.test.tscovering unrelated pinned script evidence, wrong script path evidence, missing checkout of the pinned commit, and the valid same-repo/same-script/pinned-checkout case.Testing
pnpm exec vitest run tests/content-policy-validation.test.tsand all tests passed (19 tests, 0 failures).pnpm validate:content:strictwhich validated content (912 files) and passed.git diff --checkto ensure no trailing whitespace/format issues and the check passed.Codex Task
Summary by CodeRabbit
Tests
Chores