Skip to content

Commit 1c222b8

Browse files
author
Maxwell Voss
committed
fix: resolve workspace scanning path logic and docker solc dependency
1 parent 473d532 commit 1c222b8

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ RUN apt-get update && apt-get install -y \
1111
# Install python dependencies
1212
COPY requirements.txt /app/requirements.txt
1313
RUN pip install --no-cache-dir -r /app/requirements.txt
14-
RUN pip install --no-cache-dir web3 slither-analyzer
14+
RUN pip install --no-cache-dir web3 slither-analyzer solc-select
15+
16+
# Install common solc versions for Slither
17+
RUN solc-select install 0.8.20 && \
18+
solc-select install 0.8.24 && \
19+
solc-select use 0.8.24
1520

1621
# Copy the scanner code
1722
COPY . /app

security_scanner.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -619,21 +619,24 @@ def _resolve_contract_path(workspace: str, address: str) -> tuple[str, str]:
619619

620620

621621
@no_dry_run
622-
def scan_contract(contract_address: str) -> None:
622+
def scan_contract(contract_address: str, workspace_override: str = None) -> None:
623623
"""Hybrid scanner: Slither (primary) + Heuristic (secondary).
624624
625625
Runs Slither for dataflow analysis, merges with regex heuristics,
626626
deduplicates, and generates a professional report.
627627
"""
628628
start_time = time.monotonic()
629629

630-
try:
631-
from lib.workspace import resolve_workspace
632-
workspace = resolve_workspace()
633-
except ImportError:
634-
workspace = os.environ.get("OPENCLAW_WORKSPACE") or os.path.expanduser("~/.openclaw/workspace")
635-
if not os.path.exists(workspace):
636-
workspace = os.getcwd()
630+
if workspace_override:
631+
workspace = workspace_override
632+
else:
633+
try:
634+
from lib.workspace import resolve_workspace
635+
workspace = resolve_workspace()
636+
except ImportError:
637+
workspace = os.environ.get("OPENCLAW_WORKSPACE") or os.path.expanduser("~/.openclaw/workspace")
638+
if not os.path.exists(workspace):
639+
workspace = os.getcwd()
637640

638641
_log("INFO", f"Security Scanner v1.0 (Slither Hybrid) — {datetime.now(timezone.utc).isoformat()}")
639642
_log("INFO", f"Target: {contract_address}")
@@ -831,6 +834,14 @@ def scan_contract(contract_address: str) -> None:
831834
if __name__ == "__main__":
832835
import argparse
833836
parser = argparse.ArgumentParser(description="Scan Solidity contracts (V1.0 Slither Hybrid).")
834-
parser.add_argument("--address", required=True, help="Contract address to scan")
837+
parser.add_argument("--address", help="Contract address or path to scan")
838+
parser.add_argument("--workspace", help="Workspace path to scan everything")
835839
args = parser.parse_args()
836-
scan_contract(args.address)
840+
841+
if args.workspace and not args.address:
842+
scan_contract("ALL", workspace_override=args.workspace)
843+
elif args.address:
844+
scan_contract(args.address)
845+
else:
846+
print("Must provide either --address or --workspace")
847+
sys.exit(1)

0 commit comments

Comments
 (0)