fix(validator): keep hidden rules out of the pin #246
No reviewers
Labels
No labels
bug
cannot reproduce
duplicate
enhancement
help wanted
invalid
need info
need triage
need verification
not a bug
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
claudiomaradonna/agent-foundry!246
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "validator-blankline-pin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
scripts/verify-agent-config.shis how this source, and every projectthat adopts it, holds the seven OpenCode adapters to their pinned
permission lists:
check_permissionscompares the frontmatter'spermissions:block as exact text, so an adapter whose read-only reviewergained a web tool fails the check. That guarantee depended on how the
block's lines are collected. Extraction kept the
permissions:key andthe lines after it that start with two spaces, and stopped at any other
line — including one a YAML block sequence happily survives. The rules
after such a line stayed part of the same list for OpenCode and vanished
from the comparison, so the tampering passed. Reported by
security-reviewerwhile reviewing pull request #242, filed as #244.
What changed
check_permissionsnow ends the block where YAML ends it: at a line thatstarts with neither whitespace nor
#. Empty lines, lines of whitespaceonly, and comments at any indentation therefore reach the exact-text
comparison, and since no pinned block holds one, a file that hides a rule
behind them fails with the diagnostic it already knows,
permissions block missing or altered. A top-level key after the blockstill ends the block, so a project adding the
model:the tuning guidesuggests below its list is unaffected.
Three tamperings land as regression tests beside the other OpenCode
reviewer cases, one per line form — the empty line, a tab, and a comment —
each built by a new
opencode_hidden_granthelper that takes the line toinsert. A separate commit, before the fix, pins the tuning placement:
accepts an OpenCode reviewer adapter with a key after its permissions block.How to verify
Base
f491863, branchvalidator-blankline-pinat89f4139. From afresh checkout,
bash tests/verify-agent-config.shprintsall 337 agent configuration tests passed; the base passes with its own333.
The three guards use a helper the branch adds, so they fail on the base's
code:
The three cases print
not ok — unexpectedly validand the area exits 1;the same file on the branch prints
okfor all eleven cases. Run andreported from this session.
To see the bypass in the client, which needs no model call: seed a scratch
git repository with the branch's
.opencode/agents/and a stubAGENTS.md, add a hidden rule tochange-reviewer.mdafter a line ofyour choosing —
# tidyon its own at column zero, thenOn the base,
scripts/verify-agent-config.sh <that repository>saysstatically validwhileopencode debug agents(OpenCode v2.3.2) showsthat reviewer holding
webfetch/*=allow; on this branch the same filereports
permissions block missing or altered. The three forms were runthis way, with results in the work folder.
Checks run at
89f4139, all passing: 337 agent-configuration tests, 46work-folder check tests,
scripts/verify-agent-config.shvalid(
state=template), shell check 51 files clean,prettier --check '**/*.md'clean,git diff --check mainclean. Not run: the behavioralevals, billed and maintainer-run; this change reaches no prompt.
Considerations
The pin stays a comparison of line shapes, so it is only as wide as what
the extraction recognizes; the permanent fix is parsing the frontmatter as
YAML, which needs a dependency the test commands do not have. A project
whose own adapter holds a comment or a whitespace-only line inside its
block now fails the check with the generic diagnostic — deliberate, since
the block is pinned text, and the diff shows the offending line. Two
pre-existing gaps in the same file, both unchanged by this branch, are
filed as #245: the delimiters the check trusts are not the ones the client
follows, and a CRLF checkout refuses a legitimate adapter.