How auditware/radar works
Project Type and Purpose
• This is an open-source static analysis tool (“radar”) for Anchor-based Rust smart contracts.
• It provides a CLI front-end, a controller/orchestrator, a Python/Django REST API with Celery workers, and a Rust-based parser library (rust_syn_wrapper).
• Its goal is to parse a user’s Rust contract code into an AST, apply user-supplied or built-in YAML templates (rules) against that AST via a Python rule engine, and report potential security issues.
File-Structure Analysis
Top-level directories and roles:
• /radar (root executable script): CLI entrypoint users invoke.
• /controller: Python package that implements the CLI logic (controller/main.py), orchestrates parsing and requests to the API.
• /api: A Django project (“api/api”) exposing REST endpoints, loading templates, managing a database, and defining Celery tasks for rule evaluation.
• api/api/settings.py, urls.py, views.py – Django REST framework setup
• api/api/tasks.py – Celery task definitions
• api/builtin_templates – YAML rule definitions shipped with the project
• api/rust_syn_wrapper – Rust library (cargo) providing an AST generator via PyO3 or CLI
• /docker-compose*.yml, Dockerfiles: container definitions for local development (API + controller + message broker + database).
• scripts (install-radar.sh, update-radar.sh): installation and update helpers.
• /docs, /static: documentation and image assets – not part of the core runtime pipeline.
Key README Insights
• Confirms the two main runtimes: a CLI (“radar -p <folder>”) and a web/django–Celery service when run in Docker.
• Emphasizes the use of Python-based rule engine + YAML templates.
• Mentions integration via GitHub Actions or pre-commit hooks (external CI integration).
Detail & Precision Checklist
• Folder-to-component mapping (e.g., /controller → CLI; /api/api → API Server)
• Configuration surfaces: Dockerfiles, docker-compose, .env for broker/DB credentials
• Where builtin_templates live in the flow (loaded by API at startup)
• Error-handling or retry (Celery retries on failure) if space permits