docs: surface sub-parser trust model on the using-words-from pragma (#496)#508
Conversation
Adds the `using-words-from` trust contract to `LibParsePragma`'s NatSpec. Sub-parsers run during parse and emit bytecode that gets spliced into the result. `integrityCheck2` validates structural correctness but cannot verify the sub-parser's output matches the source text semantically. Integrators must vet every sub-parser address under the same trust model as the expression itself. Closes #496 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthrough
ChangesSub-parser Trust Model Documentation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/lib/parse/LibParsePragma.sol`:
- Around line 35-53: The NatSpec doc block in LibParsePragma.sol (the
multi-paragraph comment at the top of the file describing the trust model) mixes
explicit tags with untagged /// lines, which are not treated as continuations;
revise that comment so each paragraph is explicitly tagged (for example, prepend
`@dev` to implementation/behavior paragraphs and `@custom`:security to
threat-model/security paragraphs) so every line is a valid NatSpec entry and no
untagged /// lines remain.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 498ba1ad-bb92-4741-82ba-1fb1f8692211
📒 Files selected for processing (1)
src/lib/parse/LibParsePragma.sol
| /// Trust model: sub-parsers run under the same trust assumption as the | ||
| /// expression author. A buggy or malicious sub-parser can: | ||
| /// - emit syntactically valid bytecode that nevertheless encodes | ||
| /// behaviour the user did not write (e.g. wrong opcode index, swapped | ||
| /// inputs); | ||
| /// - emit constants of its choosing, including ones that look like | ||
| /// addresses the user did not specify; | ||
| /// - decline to parse legitimate input and revert the entire expression. | ||
| /// | ||
| /// The integrity check on the assembled bytecode catches stack-shape and | ||
| /// pointer-bounds violations. It does NOT verify semantic equivalence | ||
| /// between the source text and the bytecode the sub-parser produced — | ||
| /// that's a function of the sub-parser's correctness, not the | ||
| /// interpreter's. | ||
| /// | ||
| /// Integrators MUST vet every sub-parser address they accept (or that | ||
| /// users include via the `using-words-from` pragma) under the same trust | ||
| /// model they apply to the expression itself. An expression with a | ||
| /// hostile sub-parser is equivalent to a hostile expression. |
There was a problem hiding this comment.
Add explicit NatSpec tags to each paragraph in this doc block.
Line 35-Line 53 uses untagged /// lines after an explicit-tag block; per repo rule, those lines are not treated as continuations. Please tag each paragraph explicitly (e.g., @dev or @custom:security).
Proposed compliant rewrite
-/// Trust model: sub-parsers run under the same trust assumption as the
-/// expression author. A buggy or malicious sub-parser can:
+/// `@dev` Trust model: sub-parsers run under the same trust assumption as the
+/// expression author. A buggy or malicious sub-parser can:
/// - emit syntactically valid bytecode that nevertheless encodes
/// behaviour the user did not write (e.g. wrong opcode index, swapped
/// inputs);
/// - emit constants of its choosing, including ones that look like
/// addresses the user did not specify;
/// - decline to parse legitimate input and revert the entire expression.
///
-/// The integrity check on the assembled bytecode catches stack-shape and
+/// `@dev` The integrity check on the assembled bytecode catches stack-shape and
/// pointer-bounds violations. It does NOT verify semantic equivalence
/// between the source text and the bytecode the sub-parser produced —
/// that's a function of the sub-parser's correctness, not the
/// interpreter's.
///
-/// Integrators MUST vet every sub-parser address they accept (or that
+/// `@dev` Integrators MUST vet every sub-parser address they accept (or that
/// users include via the `using-words-from` pragma) under the same trust
/// model they apply to the expression itself. An expression with a
/// hostile sub-parser is equivalent to a hostile expression.As per coding guidelines, “In NatSpec doc blocks containing explicit tags (e.g., @title), all entries must be explicitly tagged; untagged lines do not continue the previous tag”.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// Trust model: sub-parsers run under the same trust assumption as the | |
| /// expression author. A buggy or malicious sub-parser can: | |
| /// - emit syntactically valid bytecode that nevertheless encodes | |
| /// behaviour the user did not write (e.g. wrong opcode index, swapped | |
| /// inputs); | |
| /// - emit constants of its choosing, including ones that look like | |
| /// addresses the user did not specify; | |
| /// - decline to parse legitimate input and revert the entire expression. | |
| /// | |
| /// The integrity check on the assembled bytecode catches stack-shape and | |
| /// pointer-bounds violations. It does NOT verify semantic equivalence | |
| /// between the source text and the bytecode the sub-parser produced — | |
| /// that's a function of the sub-parser's correctness, not the | |
| /// interpreter's. | |
| /// | |
| /// Integrators MUST vet every sub-parser address they accept (or that | |
| /// users include via the `using-words-from` pragma) under the same trust | |
| /// model they apply to the expression itself. An expression with a | |
| /// hostile sub-parser is equivalent to a hostile expression. | |
| /// `@dev` Trust model: sub-parsers run under the same trust assumption as the | |
| /// expression author. A buggy or malicious sub-parser can: | |
| /// - emit syntactically valid bytecode that nevertheless encodes | |
| /// behaviour the user did not write (e.g. wrong opcode index, swapped | |
| /// inputs); | |
| /// - emit constants of its choosing, including ones that look like | |
| /// addresses the user did not specify; | |
| /// - decline to parse legitimate input and revert the entire expression. | |
| /// | |
| /// `@dev` The integrity check on the assembled bytecode catches stack-shape and | |
| /// pointer-bounds violations. It does NOT verify semantic equivalence | |
| /// between the source text and the bytecode the sub-parser produced — | |
| /// that's a function of the sub-parser's correctness, not the | |
| /// interpreter's. | |
| /// | |
| /// `@dev` Integrators MUST vet every sub-parser address they accept (or that | |
| /// users include via the `using-words-from` pragma) under the same trust | |
| /// model they apply to the expression itself. An expression with a | |
| /// hostile sub-parser is equivalent to a hostile expression. |
🤖 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 `@src/lib/parse/LibParsePragma.sol` around lines 35 - 53, The NatSpec doc block
in LibParsePragma.sol (the multi-paragraph comment at the top of the file
describing the trust model) mixes explicit tags with untagged /// lines, which
are not treated as continuations; revise that comment so each paragraph is
explicitly tagged (for example, prepend `@dev` to implementation/behavior
paragraphs and `@custom`:security to threat-model/security paragraphs) so every
line is a valid NatSpec entry and no untagged /// lines remain.
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
|
Tip For best results, initiate chat on the files or code changes. SIZE=S |
Summary
Closes #496
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit