feat(plugins): implement unchecked return value detection plugin (#16) - #99
Open
Salahalioui wants to merge 1 commit into
Open
feat(plugins): implement unchecked return value detection plugin (#16)#99Salahalioui wants to merge 1 commit into
Salahalioui wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16
Summary of Changes
Implements the
@veridion/plugin-unchecked-returnscanner plugin to detect unchecked low-level Solidity calls (.call(),.send(),.delegatecall()) per SWC-104 guidelines, and registers it inscanner-core.Architectural Design & Edge Case Handling
Rather than relying on naive regex matching that breaks across multi-line definitions or comments, the plugin uses a deterministic character scanner:
{}brace depth from declaration boundaries (function,constructor,modifier,receive,fallback) to guarantee strict function scope isolation. Checks in one function cannot leak or validate calls in another.require(call),if (!call) revert(),return call) from statements where return values are captured via tuple(bool ok, ) = ...or variable declarationbool sent = ....!ok), negative equality (ok == false), and equality against untrusted variables (ok == someFlag).address.transfer()calls because the EVM automatically reverts on failure and returns no boolean.Implementation Details
plugins/unchecked-return/src/index.ts: ImplementsIRulePlugin, exposing AST-free lexer, scope boundary tracker, statement locator, and truthiness evaluator.plugins/unchecked-return/src/index.test.ts: 66 unit tests covering positive detections, tuple omissions, single assignments, variable reassignments, external object lookalikes (verifier.assert(ok)), comments/strings masking, and multi-contract isolation.packages/scanner-core/src/plugin-registry.ts: RegistersUncheckedReturnPluginindefaultPluginsand exportscreateDefaultRegistry().packages/scanner-core/src/plugin-registry.test.ts: Integration tests verifying scanner registration and end-to-end detection.Test & Verification Evidence
Run locally with:
Output: