udip15/Shieldlabs-for-kaggle

GitHub: udip15/Shieldlabs-for-kaggle

一款自托管的 AI 驱动安全扫描与修复引擎,整合代码静态分析与 Web 动态扫描,通过跨域攻击链推理与自动化报告帮助企业低成本完成安全审计。

Stars: 0 | Forks: 1

🛡️ ShieldLabs 面向尼泊尔初创企业的 AI 驱动安全扫描器与漏洞修复引擎 什么是 ShieldLabs ShieldLabs 是一个自托管的 Web 应用程序——而不是云 SaaS 产品——它能够扫描公司的代码仓库和在线 Web 基础设施,查找安全漏洞,用通俗易懂的语言进行解释,生成可用的修复方案,并生成一份专业的、适合直接提交给评委/CTO 的 PDF 报告。 可以把它想象成 VS Code,而不是 Google Docs:你下载它,在你自己的机器或私有服务器上运行,你的源代码永远不会离开你的基础设施。 不是:一个你把代码发送过去的公有云服务(比如 Snyk 的托管版) 不是:一个你把代码粘贴进去的聊天机器人 是:一个在本地运行的、由专用扫描器 + AI agents 组成的 pipeline,能够自动化完成人工安全审计的工作 问题所在 尼泊尔(以及整个南亚地区)的大多数早期初创企业在交付代码时都没有进行任何安全审查,原因如下: 一次专业的渗透测试/审计费用高达 ₹50,000 以上,并且需要 1–2 周的时间 初级开发团队不知道该检查什么 现有的免费工具(如 SonarQube Community、OWASP ZAP)非常分散——你需要使用五种不同的工具,它们彼此之间无法互通,而且没有一个工具能解释为什么某个问题很重要,或者如何修复它 ShieldLabs 将整个 pipeline 自动化:扫描 → 检测 → 优先级排序 → 解释 → 修复 → 报告,所有步骤都在一个工作流中完成,并且完全免费。 工作原理 ``` User Input (GitHub URL / ZIP / Domain) │ ▼ Router API handler │ ▼ Create Scan record in DB │ ▼ Code Scanner ──or── Web Scanner (AST + regex + (Nmap + SSL/TLS Bandit + LLM) + Nuclei + sqlmap) │ ▼ Severity Reasoning Agent (CVSS 3.1 + exploitability) │ ▼ Cross-Domain Analysis Agent (attack chains) │ ▼ Fix Generation Agent (secure code + explanation) │ ▼ Store findings in DB │ ▼ Frontend polls for results │ ▼ Report Generation Agent (PDF) │ ▼ User downloads PDF / views dashboard ``` 关键差异化优势:攻击链推理 像“`/api/search` 中的 SQL injection”这样一个单独的漏洞发现,如果单独评估可能只会被评为“中级”。但如果 Web 扫描器同时发现暴露在互联网上且没有任何认证的 MySQL 端口,ShieldLabs 的跨域分析 Agent 就会将这两者联系起来: ``` # 克隆 git clone https://github.com/kaalvex/ShieldLabs.git cd shieldlabs/backend # Virtual environment python -m venv venv # Windows: .\venv\Scripts\Activate.ps1 # Mac/Linux: source venv/bin/activate # 安装依赖 pip install -r requirements.txt # 配置环境 cp .env.example .env # then fill in GROQ_API_KEY, GITHUB_TOKEN, SECRET_KEY # 初始化数据库 python -c "from app.database import init_db; init_db()" # 运行服务器 python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 ``` 验证其是否正在运行: ``` curl http://localhost:8000/api/health ``` 前端: ``` cd frontend npm install npm run dev ``` 项目结构 ``` shieldlabs/ ├── backend/ │ ├── app/ │ │ ├── __init__.py │ │ ├── main.py # FastAPI entry point, CORS, lifespan, health check │ │ ├── database.py # SQLAlchemy engine, session, models: Scan, Finding, Report, AttackChain │ │ ├── schemas.py # Pydantic request/response models (ScanRequest, FindingSchema, etc.) │ │ ├── dependencies.py # Shared FastAPI dependencies (DB session injection) │ │ │ │ │ ├── agents/ │ │ │ ├── __init__.py │ │ │ ├── base.py # ShieldLabsAgent base class (wraps CrewAI Agent) │ │ │ ├── code_parser.py # Code Parser Agent — builds structural map of repo │ │ │ ├── severity_reasoning.py # CVSS 3.1 scoring + exploitability rating agent │ │ │ ├── cross_domain_analyzer.py # Attack chain / compounded risk agent │ │ │ └── fix_generation.py # AI-generated secure code + explanation agent │ │ │ │ │ ├── scanners/ │ │ │ ├── __init__.py │ │ │ ├── ast_parser.py # Python/JS/Go AST parsing (functions, imports, queries) │ │ │ ├── pattern_detector.py # Regex/AST detectors for all 13 vulnerability classes │ │ │ ├── semantic_analyzer.py # LLM-based false-positive filtering on borderline matches │ │ │ ├── web_scanner.py # Nmap port scanning + service/version detection │ │ │ ├── ssl_analyzer.py # testssl.sh integration — TLS version, cert issues │ │ │ ├── headers_checker.py # Security header presence checks (CSP, HSTS, etc.) │ │ │ ├── nuclei_runner.py # Nuclei template-based vulnerability scanning │ │ │ ├── sqlmap_runner.py # Live SQL injection confirmation via sqlmap │ │ │ └── exposed_files.py # Checks for exposed .git, .env, backup.sql, etc. │ │ │ │ │ ├── api/ │ │ │ ├── __init__.py │ │ │ └── routes.py # /api/scan/code, /api/scan/web, /api/analyze, /api/results/{id} │ │ │ │ │ ├── models/ │ │ │ └── __init__.py # (ORM models consolidated in database.py) │ │ │ │ │ └── utils/ │ │ ├── __init__.py │ │ ├── llm.py # ollama_call() + groq_call() wrapper functions │ │ ├── repo_handler.py # GitHub clone / ZIP extraction / temp cleanup │ │ ├── pdf_generator.py # ReportLab + Jinja2 PDF report generation │ │ └── logger.py # Console + file logging configuration │ │ │ ├── requirements.txt # Python dependencies (FastAPI, CrewAI, SQLAlchemy, etc.) │ ├── .env # API keys + config (GROQ_API_KEY, DATABASE_URL, etc. — gitignored) │ ├── .env.example # Template for .env with placeholder values │ └── shieldlabs.db # SQLite database file (generated, gitignored) │ ├── frontend/ │ ├── src/ │ │ ├── components/ │ │ │ ├── UploadForm.jsx # GitHub URL / ZIP upload + domain input │ │ │ ├── ScanProgress.jsx # Real-time scan status (polling/WebSocket) │ │ │ ├── ResultsDashboard.jsx # Findings table, charts, severity breakdown │ │ │ └── VulnCard.jsx # Single finding display: description, code, fix │ │ ├── pages/ # Top-level route pages │ │ ├── api/ # Frontend API client functions │ │ ├── utils/ # Frontend helper functions │ │ ├── App.jsx │ │ └── main.jsx │ ├── public/ │ ├── index.html │ └── package.json │ ├── docs/ # Additional documentation, diagrams │ ├── tests/ │ ├── fixtures/ │ │ └── vulnerable_app/ # Deliberately vulnerable Flask app used for demo/testing │ │ └── app.py │ └── (backend unit/integration tests) │ ├── .gitignore └── README.md ```
标签:AI风险缓解, CISA项目, CTI, Web安全, 人工智能, 用户模式Hook绕过, 蓝队分析, 逆向工具