AuditPilot is a local code security audit prototype built with FastAPI, a static frontend, and an agent-style audit workflow. It supports uploading source files, directories, and archives, then generates findings and reports.
- User registration and login
- Normal user and administrator roles
- Optional bootstrap administrator account from
.env - Multi-file and directory upload
- Static and LLM-assisted review flow
- Optional Java audit skill integration from
RuoJi6/java-audit-skills - WebSocket progress events
- HTML, Markdown, and JSON reports
- Admin page for user control and auditing user tasks
- Per-user OpenAI, DeepSeek, and OpenAI-compatible API settings with encrypted API-key storage
- Automatic model discovery from each user's configured OpenAI-compatible
/modelsendpoint - Admin stop control for queued or running ordinary-user audits
- Independent task-center tab with filtering, renaming, retry, single/bulk deletion, history restore, and baseline selection
- Restart recovery for persisted queued/running audits
- Provider adapters for OpenAI, DeepSeek, OpenAI-compatible, Azure OpenAI, and Ollama
- Incremental file scanning, finding comparison, and source-to-sink call-chain candidates
- Per-user monthly token quotas, usage accounting, login sessions, and administrator operation logs
- LLM usage analytics with period filters, streaks, activity heatmap, and per-model ranking
- Upload/file-count/archive-expansion/storage quota controls
- Alembic database migrations
backend/
app/
api/ FastAPI routes
agent/ Audit workflow
scanners/ Heuristic scanners
services/ Auth, audit, reports, files, events
frontend/
index.html User console
admin.html Administrator console
assets/
scripts/
smoke_test.py
dev.py Cross-platform dev stack controller
- Python 3.12+
- Windows, macOS, or Linux
- Optional: Redis
- Optional: DeepSeek API key for real LLM review
Create .env from the example:
cp .env.example .envOn Windows PowerShell:
Copy-Item .env.example .envImportant local settings:
BACKEND_HOST=127.0.0.1
BACKEND_PORT=8000
FRONTEND_HOST=127.0.0.1
FRONTEND_PORT=3000
AUTH_SECRET_KEY=
CREDENTIAL_ENCRYPTION_KEY=
ADMIN_BOOTSTRAP_USERNAME=
ADMIN_BOOTSTRAP_EMAIL=
ADMIN_BOOTSTRAP_PASSWORD=
ADMIN_BOOTSTRAP_RESET_PASSWORD=false
HUMAN_CHECK_CHALLENGE_TTL_SECONDS=300
HUMAN_CHECK_PROOF_TTL_SECONDS=300
HUMAN_CHECK_MIN_COMPLETION_MS=1200
JAVA_AUDIT_SKILLS_ENABLED=true
JAVA_AUDIT_SKILLS_ROOT=Back up the database, then apply the tracked schema revision:
python -m alembic upgrade head
python -m alembic currentThe first revision adopts existing tables, adds missing platform columns, and creates the session, usage, and administrator log tables. Runtime startup keeps a compatibility column check for older local databases.
GET /api/v1/audit/tasks— paginated personal task historyPATCH /api/v1/audit/{task_id}— rename a taskPOST /api/v1/audit/{task_id}/retry— retry terminal tasksDELETE /api/v1/audit/{task_id}— remove task artifacts and dataGET /api/v1/audit/{task_id}/compare/{baseline_task_id}— compare findingsGET /api/v1/auth/llm-usage— current-month token usageGET/DELETE /api/v1/auth/sessions— list or revoke sessionsGET /api/v1/admin/audit-logs— administrator action historyPATCH /api/v1/admin/users/{user_id}/llm-quota— update a monthly token quotaPOST /api/v1/admin/users/{user_id}/sessions/revoke— revoke a user’s sessions
Set AUTH_SECRET_KEY explicitly if you want stable tokens across restarts. When it is empty, the backend falls back to a per-process secret so placeholder values cannot be abused.
For local use, the first API-key save automatically creates backend/data/.credential_encryption_key and reuses it across restarts. An explicit CREDENTIAL_ENCRYPTION_KEY takes precedence; existing deployments with only AUTH_SECRET_KEY keep using that value. The raw per-user key is never returned by the API or shown again in the UI.
Bootstrap admin creation is disabled by default and only runs when ADMIN_BOOTSTRAP_USERNAME, ADMIN_BOOTSTRAP_EMAIL, and a non-placeholder ADMIN_BOOTSTRAP_PASSWORD are all configured. Existing admin passwords are not overwritten unless ADMIN_BOOTSTRAP_RESET_PASSWORD=true.
The registration slider now requires a backend-issued, single-use proof token before account creation. This closes the old direct-API bypass for the frontend-only check, but an internet-facing deployment should still consider a managed bot-defense service such as Cloudflare Turnstile or hCaptcha.
If JAVA_AUDIT_SKILLS_ROOT is empty, the backend defaults to ~/.codex/skills and will automatically append installed Java audit skill guidance for Java projects.
For Java projects, you can enable full-file review context and stricter heuristic corroboration to cut down false positives in uploaded code.
Use the single cross-platform controller:
python dev.py start
python dev.py stop
python dev.py status
python dev.py restartdev.py creates or reuses .venv, installs requirements.txt, generates frontend/assets/runtime-config.js, and starts the backend and frontend. The project uses .venv only; do not activate an old venv directory.
把完整项目目录上传到 Linux 服务器后,只需要执行这一条命令:
cd /opt/auditpilot
sudo bash start-linux.shstart-linux.sh 会自动安装 Python、Nginx、Redis 和项目依赖,创建独立服务用户、生成安全配置、写入 systemd 服务、配置 Nginx 反向代理、启动服务并完成健康检查。默认使用持久化 SQLite 数据库,访问入口为:
http://服务器IP/
首次启动时脚本会在终端输出管理员账号和随机密码;运行配置保存于 /etc/auditpilot/auditpilot.env。指定域名、端口或固定管理员信息:
sudo env \
PUBLIC_ORIGIN=https://audit.example.com \
HTTP_PORT=80 \
ADMIN_BOOTSTRAP_USERNAME=admin \
ADMIN_BOOTSTRAP_EMAIL=admin@example.com \
ADMIN_BOOTSTRAP_PASSWORD='StrongPassword-ChangeMe' \
bash start-linux.sh日常操作:
sudo bash start-linux.sh restart
sudo bash start-linux.sh stop
sudo bash start-linux.sh status
sudo bash start-linux.sh logs仓库内置 Linux 部署脚本,包含 Nginx、FastAPI、MySQL、Redis、数据库迁移、健康检查和持久卷:
cd /opt
git clone <YOUR_REPOSITORY_URL> auditpilot
cd auditpilot
sudo bash deploy-linux.sh脚本会自动完成:
- 检查并安装 Docker Engine 与 Compose 插件;
- 生成权限为
600的.env.docker; - 随机生成 MySQL、Token 签名和 API Key 加密密钥;
- 创建管理员账号密码;
- 构建镜像、迁移数据库并启动全部服务;
- 等待健康检查完成,然后输出访问地址和管理员密码。
首次部署前可通过环境变量指定地址、端口和管理员:
sudo env \
PUBLIC_ORIGIN=http://192.0.2.10:8080 \
HTTP_PORT=8080 \
ADMIN_BOOTSTRAP_USERNAME=admin \
ADMIN_BOOTSTRAP_EMAIL=admin@example.com \
ADMIN_BOOTSTRAP_PASSWORD='Replace-With-A-Strong-Password' \
bash deploy-linux.sh常用运维命令:
sudo bash deploy-linux.sh status
sudo bash deploy-linux.sh logs
sudo bash deploy-linux.sh restart
sudo bash deploy-linux.sh update
sudo bash deploy-linux.sh stop
sudo bash deploy-linux.sh down配置位于 .env.docker,业务上传、项目、报告、MySQL 和 Redis 数据保存在 Docker 持久卷中。修改 .env.docker 后执行:
sudo bash deploy-linux.sh update如果通过域名和 HTTPS 对外服务,将 PUBLIC_ORIGIN 设置为最终的 https://域名,并在当前 Nginx 前配置证书终止或云负载均衡。
Optional overrides:
python dev.py start --backend-port 18000 --frontend-port 13000 --open-browserDefault URLs:
- Frontend:
http://127.0.0.1:3000 - Admin page:
http://127.0.0.1:3000/admin.html - Backend:
http://127.0.0.1:8000 - Swagger:
http://127.0.0.1:8000/docs
Keep the stack running, then run:
.venv/bin/python scripts/smoke_test.pyOn Windows:
.\.venv\Scripts\python.exe scripts\smoke_test.pyFeature integration checks:
.\.venv\Scripts\python.exe scripts\test_user_llm_config_and_task_stop.pyThe smoke test registers a temporary user, uploads the sample vulnerable file, starts an audit, waits for completion, and prints report information.
Frontend-only checks do not require pytest or a build step:
python scripts/check_frontend.py
node scripts/test_register_slider.js --url=http://127.0.0.1:3000 --browser=chromebackend/data/runtime/backend.out.log
backend/data/runtime/backend.err.log
backend/data/runtime/frontend.out.log
backend/data/runtime/frontend.err.log
backend/data/auditpilot.db
backend/data/uploads/
backend/data/projects/
backend/data/reports/
For production-style deployment, run FastAPI behind a process manager and serve frontend/ with Nginx, IIS, or another static file server. Configure /api/, /docs, /openapi.json, and /api/v1/ws/ to proxy to the backend.