feat(security): offline line-level static analysis in the contract scanner [D-25]#443
Open
KayProject wants to merge 1 commit into
Open
Conversation
|
@KayProject Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…anner The built-in audit only ran file-level checklist heuristics and delegated real vulnerability detection to Slither/Mythril. When those tools are not installed the scanner silently missed line-level issues. This wires the existing SecurityPatternLibrary into the built-in analysis so the scanner detects reentrancy, unchecked arithmetic, unsafe unwraps, missing authorization and hardcoded addresses on its own, each reported with a file:line location, severity and remediation. Adds an --offline flag to run the scan with built-in analysis only and skip external tools. Closes Nanle-code#362
e378e4e to
caba45d
Compare
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.
Summary
The built-in contract security scanner (
security audit) ran the file-level checklist and then delegated real vulnerability detection to Slither and Mythril. When those external tools aren't installed,run_builtin_analysisonly produced checklist findings and silently missed line-level issues — so a developer without Slither/Mythril got a weak scan.This makes the scanner self-sufficient: it now performs line-level static analysis against the existing
SecurityPatternLibrarywith no external dependencies.Changes
utils/security/audit.rs—run_builtin_analysisnow also runsrun_pattern_analysis, which walks the contract source through the pattern library (dry-run hardening pass) and emits aVulnerabilityFindingper match with:file:linelocationcommands/security.rs— adds--offlinetosecurity audit, which forces external tools off and runs the built-in scanner only.Coverage gained offline
The pattern library detects exactly the classes called out in the issue, now without any external tooling:
Severity scoring and the report formatter are unchanged — the new findings flow through the existing
compute_summary/compute_score/format_reportpipeline.Tests
builtin_analysis_detects_line_patterns_without_external_tools— runs the built-in analysis on a deliberately vulnerable contract and asserts reentrancy is caught, every pattern finding carries a line-qualified location and remediation, and is attributed to the built-in scanner.pattern_remediation_falls_back_for_unknown_pattern— guards the remediation fallback.Closes #362