Skip to content

Commit 9386bf3

Browse files
author
Maxwell Voss
committed
feat(v4.2): Fix mojibake encoding, add 3 new gas rules (6 total), add cargo audit timeout, add pyproject.toml
1 parent 07a91b0 commit 9386bf3

4 files changed

Lines changed: 76 additions & 5 deletions

File tree

gas_optimizer.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,38 @@ def optimize_contract(self, contract_path: str) -> Dict[str, Any]:
5151
})
5252
total_gas_saved += 25
5353

54+
# 4. Calldata vs Memory for external functions
55+
if re.search(r'function\s+\w+\s*\([^)]*\bmemory\b[^)]*\)\s*(external|public)', line):
56+
self.gas_findings.append({
57+
"line": line_num,
58+
"issue": "Memory parameter in external function",
59+
"recommendation": "Use 'calldata' instead of 'memory' for external function parameters to save gas on copy operations.",
60+
"gas_saved_est": 200
61+
})
62+
total_gas_saved += 200
63+
64+
# 5. Constants that should be immutable
65+
if re.search(r'(public|private|internal)\s+(address|uint256|bytes32)\s+\w+\s*=\s*', line):
66+
if 'constant' not in line and 'immutable' not in line:
67+
self.gas_findings.append({
68+
"line": line_num,
69+
"issue": "State variable could be immutable",
70+
"recommendation": "If this variable is only set in the constructor, mark it as 'immutable' to save ~2100 gas per access.",
71+
"gas_saved_est": 2100
72+
})
73+
total_gas_saved += 2100
74+
75+
# 6. Unchecked arithmetic opportunities
76+
if re.search(r'\b(i\s*\+\+|i\s*\+=\s*1)\b', line) and 'unchecked' not in line:
77+
if 'for' not in line: # Skip loop counters already caught
78+
self.gas_findings.append({
79+
"line": line_num,
80+
"issue": "Safe arithmetic without unchecked block",
81+
"recommendation": "Wrap safe increment operations in 'unchecked {}' block to save ~120 gas (Solidity >=0.8.0).",
82+
"gas_saved_est": 120
83+
})
84+
total_gas_saved += 120
85+
5486
return {
5587
"status": "success",
5688
"findings_count": len(self.gas_findings),

pyproject.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[project]
2+
name = "solidity-security-scanner"
3+
version = "2.0.0"
4+
description = "AI-powered smart contract security scanner for Solidity, Rust, and Solana"
5+
readme = "README.md"
6+
license = {text = "MIT"}
7+
requires-python = ">=3.11"
8+
authors = [
9+
{name = "Maxwell VOSS"}
10+
]
11+
keywords = [
12+
"solidity", "ethereum", "smart-contracts", "security", "blockchain",
13+
"defi", "web3", "solana", "rust", "github-actions", "vulnerability-scanner",
14+
"static-analysis", "slither", "foundry", "gas-optimization", "reentrancy"
15+
]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Intended Audience :: Developers",
19+
"Topic :: Security",
20+
"Topic :: Software Development :: Quality Assurance",
21+
"License :: OSI Approved :: MIT License",
22+
"Programming Language :: Python :: 3.11",
23+
]
24+
25+
[project.urls]
26+
Homepage = "https://github.com/mvmax-dev/solidity-security-scanner"
27+
Repository = "https://github.com/mvmax-dev/solidity-security-scanner"
28+
Issues = "https://github.com/mvmax-dev/solidity-security-scanner/issues"
29+
30+
[tool.pytest.ini_options]
31+
testpaths = ["tests"]
32+
python_files = "test_*.py"
33+
addopts = "-v --tb=short"
34+
35+
[tool.flake8]
36+
max-line-length = 127
37+
max-complexity = 10
38+
exclude = [".git", "__pycache__", "dashboard", "venv"]

solana_scanner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def scan(self) -> Dict[str, Any]:
2929
["cargo", "audit", "--json"],
3030
cwd=self.workspace,
3131
capture_output=True,
32-
text=True
32+
text=True,
33+
timeout=120 # 2 minutes max
3334
)
3435

3536
# Simple check

vulnerability_validator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
"""Maxwell VOSS — Strict Vulnerability Validator.
3+
"""Maxwell VOSS - Strict Vulnerability Validator.
44
55
3-Phase validation pipeline before any finding reaches the sales pipeline:
66
7-
Phase A: Slither JSON — real dataflow analysis
8-
Phase B: Context check — CEI pattern, access control, modifiers
9-
Phase C: Confidence scoring — only findings >= 70/100 pass
7+
Phase A: Slither JSON -> real dataflow analysis
8+
Phase B: Context check -> CEI pattern, access control, modifiers
9+
Phase C: Confidence scoring -> only findings >= 70/100 pass
1010
1111
This module is the QUALITY GATE. A finding that fails this gate
1212
is NEVER sold, NEVER reported as valid, and logged as false positive.

0 commit comments

Comments
 (0)