Chekroun2004/webguard

GitHub: Chekroun2004/webguard

WebGuard 是一款基于 FastAPI + React + Docker 构建的 Web 漏洞扫描器 SaaS,提供 11 种扫描器并自动生成 PDF 漏洞报告。

Stars: 0 | Forks: 0

# WebGuard **Web 漏洞扫描器 SaaS** — 使用 FastAPI + React + Docker 构建的全栈安全工具。 [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/39/39faa54be350a1dab8afd3b2fb8c1c83e4d9cff84abfef2374d19a18053687c4.svg)](https://github.com/Chekroun2004/webguard/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/Chekroun2004/webguard/branch/main/graph/badge.svg)](https://codecov.io/gh/Chekroun2004/webguard) ![Python](https://img.shields.io/badge/Python-3.11-3776AB?logo=python&logoColor=white) ![FastAPI](https://img.shields.io/badge/FastAPI-0.115-009688?logo=fastapi&logoColor=white) ![React](https://img.shields.io/badge/React-18-61DAFB?logo=react&logoColor=white) ![Docker](https://img.shields.io/badge/Docker-Compose-2496ED?logo=docker&logoColor=white) ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-15-4169E1?logo=postgresql&logoColor=white) ![Tests](https://img.shields.io/badge/tests-161%20passing-brightgreen) ![License](https://img.shields.io/badge/license-academic-lightgrey) 用户提交一个 URL → 系统进行扫描 → 生成包含严重程度和建议的 PDF/JSON 报告。 ## 功能特性 - **11 个**主动和被动 scanner:反射型 XSS、SQLi、CSRF、开放重定向、目录列出、安全 headers、cookies、SSL/TLS、敏感文件、暴露的技术、危险的 HTTP 方法 - 在主动 scanner 之前对目标网站进行**自动爬取** - 可从界面导出的 **PDF/JSON 报告** - **异步扫描**:Celery + Redis,通过 SSE 实时显示进度 - **域名所有权验证**(通过文件或 DNS TXT) - **Rate limiting**:每位用户每小时 5 次扫描,全局每分钟 100 次请求 - 重启时**自动恢复**卡住的扫描任务 - **扫描对比**:专属页面 `/diff`,用于高亮显示同一域名两次扫描之间新增/修复的漏洞 - **邮件通知**:每次扫描结束时自动发送摘要报告(开发环境使用 Mailpit,生产环境使用 SMTP) ## 演示 ### Dashboard — 扫描列表 ![Dashboard](https://static.pigsec.cn/wp-content/uploads/repos/cas/ea/ea8b5c498b4a518e2ab124035a80916b7be088c6a3f9d29e1802b5b0b402f6ec.png) ### 正在进行的扫描 ![Scan en cours](https://static.pigsec.cn/wp-content/uploads/repos/cas/32/32007940d02a21e7b3715f4d2a39fe7bb3183ef92e75d0e6211bd37096a3e0b4.png) ### 漏洞详情 ![Détail scan](https://static.pigsec.cn/wp-content/uploads/repos/cas/c2/c2051bce283a0d9887bd8b0cccf1e7edec68c082cb9b1a05153209f2ac87825b.png) ### 生成的 PDF 报告 ![Rapport PDF](https://static.pigsec.cn/wp-content/uploads/repos/cas/99/99bd6dc697cd20091a39b56299ffbcf3653899911637a75ab4bb8846d134ebf6.png) ### 扫描对比 ![Scan diff](https://static.pigsec.cn/wp-content/uploads/repos/cas/cf/cf1f36d91cba0b04dba0d691686b35feae17d48ac4ba3da500d7ce74dc0ebf9c.png) ### 邮件通知(开发环境使用 Mailpit) ![Email Mailpit](https://static.pigsec.cn/wp-content/uploads/repos/cas/56/561e5dc97c0a2efdee32126fcfc63846ce1acee6de2aa835e619c8650414acd2.png) ## 快速开始 ``` # 1. 克隆仓库 git clone https://github.com/Chekroun2004/webguard.git cd webguard # 2. 配置环境 cp .env.example .env # 3. 启动完整 stack docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build ``` | 服务 | URL | |---|---| | Frontend | http://localhost:5173 | | API | http://localhost:8000 | | Swagger | http://localhost:8000/docs | | Mailpit (emails) | http://localhost:8025 | ## 架构 ``` graph LR User([Utilisateur]) FE["Frontend
React 18 + Vite
:5173"] BE["Backend
FastAPI
:8000"] Q[("Redis 7
queue + cache")] W["Worker
Celery + Beat"] DB[("PostgreSQL 15")] MP["Mailpit
:8025
(dev only)"] User -->|HTTPS| FE FE -->|REST + SSE| BE BE -->|enqueue task| Q Q -->|dequeue| W W -->|HTTP probes| Target[(Cible scannée)] BE <-->|SQLAlchemy async| DB W <-->|SQLAlchemy async| DB W -.->|SMTP rapport| MP classDef svc fill:#6366f1,stroke:#4338ca,color:#fff; classDef store fill:#0ea5e9,stroke:#0369a1,color:#fff; classDef ext fill:#94a3b8,stroke:#475569,color:#fff; class FE,BE,W svc; class Q,DB store; class User,Target,MP ext; ``` **严格的后端分层:** ``` Routes (app/api/v1/) └─▶ Services (app/services/) ← logique métier └─▶ Repositories (app/repositories/) ← accès DB └─▶ Models (app/db/models/) ← SQLAlchemy ORM ``` ## 技术栈 | 层级 | 技术 | |---|---| | Backend | FastAPI 0.115, Python 3.11 | | Workers | Celery 5.4, Redis 7 | | 数据库 | PostgreSQL 15, SQLAlchemy 2.0 (async) | | Auth | JWT (python-jose), argon2 (passlib) | | PDF | WeasyPrint 62, Jinja2 | | Rate limiting | slowapi 0.1.9 | | Frontend | React 18, Vite, Tailwind CSS, shadcn/ui | | 基础设施 | Docker Compose (5 个服务) | ## 测试 ``` # Backend — 161 个测试(内存 SQLite,不使用 Postgres) docker compose exec backend pytest -v # 包含覆盖率 docker compose exec backend pytest --cov=app --cov-report=term-missing # Frontend E2E(Playwright,需要启动 docker compose stack) cd frontend npm ci npx playwright install chromium # une seule fois npm run test:e2e ``` 每次向 `main` 分支进行 push/PR 时,会通过 GitHub Actions 自动执行 CI(包含 pytest + ruff + black + eslint + tsc)。 ## 项目结构 ``` webguard/ ├── backend/ │ ├── app/ │ │ ├── api/v1/ # Routes FastAPI │ │ ├── core/ # Config, sécurité, rate limiting │ │ ├── db/ # Modèles SQLAlchemy + migrations Alembic │ │ ├── scanners/ # 11 scanners (base.py + implémentations) │ │ ├── services/ # Logique métier │ │ ├── repositories/ # Accès base de données │ │ ├── templates/ # Template HTML pour PDF │ │ └── workers/ # Celery tasks + watchdog │ └── tests/ # 161 tests pytest ├── frontend/ │ └── src/ │ ├── pages/ # Dashboard, Scan, Domains, Auth │ ├── hooks/ # TanStack Query hooks │ └── components/ # SeverityBadge, ScanProgressBar └── docker-compose.yml ``` ## 部署 支持以下两种部署目标: - **Render.com**(免费,推荐用于作品集演示)— 通过 `render.yaml` 实现一键 Blueprint 部署。参见 [`docs/DEPLOYMENT_RENDER.md`](docs/DEPLOYMENT_RENDER.md)。 - **Fly.io**(需绑定信用卡,但在 free tier 额度内费用为 $0)— 配置 `fly.toml` + Celery worker。参见 [`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md)。 ## 作者 **Omar Chekroun** — Master IGOV (M1), Faculté des Sciences de Rabat, Université Mohammed V [![LinkedIn](https://img.shields.io/badge/LinkedIn-Omar_Chekroun-0A66C2?logo=linkedin)](https://www.linkedin.com/in/omar-chekroun/) [![GitHub](https://img.shields.io/badge/GitHub-Chekroun2004-181717?logo=github)](https://github.com/Chekroun2004) ## License Internal academic project — UM5 Rabat.
标签:AV绕过, CISA项目, Docker, FastAPI, React, SaaS, Syscalls, Web漏洞扫描, 安全防御评估, 搜索引擎查询, 测试用例, 特征检测, 请求拦截, 逆向工具