mahalakshme-04/Ai-Powered-Security-Vulnerability-Scanner

GitHub: mahalakshme-04/Ai-Powered-Security-Vulnerability-Scanner

利用 Nemotron 70B 大模型在 GitHub Actions 中自动审查 Pull Request 的安全风险,输出评分与 OWASP 映射并支持 Slack 告警。

Stars: 0 | Forks: 0

# AI 安全审查 Agent 通过 OpenRouter 使用 **NVIDIA Nemotron 70B(免费)** 自动进行 Pull Request 安全分析。 ## 工作原理 ``` PR opened / updated │ ▼ GitHub Actions (ubuntu-latest runner) │ ▼ security_review_agent.py │ ├─► Fetch PR diff (GitHub API) ├─► Send to Nemotron 70B (OpenRouter — free tier) ├─► Parse JSON response │ risk_score, vulnerabilities, OWASP mappings ├─► Post comment on PR (GitHub API) └─► risk_score ≥ 50 → Slack alert ``` ## 设置说明 ### 1. 获取免费的 OpenRouter API key 在 https://openrouter.ai 注册 —— 免费模型无需信用卡。 进入 Keys → Create Key。 ### 2. 获取 Slack Webhook(可选) https://api.slack.com/apps → Create App → Incoming Webhooks → Add Webhook ### 3. 添加 GitHub Secrets Settings → Secrets and variables → Actions → New repository secret: | Secret | 值 | |--------|-------| | `OPENROUTER_API_KEY` | 你的 OpenRouter key(使用逗号分隔多个 key 以便轮换) | | `SLACK_WEBHOOK_URL` | Slack webhook URL(可选) | ### 4. 将此文件夹推送到 GitHub ``` cd AI_Security_Agent git init git add . git commit -m "feat: add AI security review agent" git remote add origin https://github.com/YOUR_USERNAME/AI_Security_Agent.git git push -u origin main ``` ### 5. 启用 Actions 写入权限 Settings → Actions → General → Workflow permissions → Read and write → Save ### 6. 打开一个 Pull Request —— 该 agent 将自动运行 ## 风险评分指南 | 分数 | 级别 | 操作 | |--------|-----------------|-------------------------------| | 0–24 | 🟢 安全 | 可以合并 | | 25–49 | 🟡 低 | 审查发现的问题 | | 50–74 | 🟠 中等 | 合并前修复 + Slack 告警 | | 75–100 | 🔴 高/严重 | 必须修复 + Slack 告警 | ## 项目结构 ``` AI_Security_Agent/ ├── .github/ │ └── workflows/ │ ├── pr-security-review.yml # Triggers on every PR │ └── pr-merge-notification.yml # Triggers on PR merge ├── scripts/ │ ├── security_review_agent.py # Main AI agent │ └── requirements.txt └── README.md ``` ## 本地测试 ``` export GITHUB_TOKEN=ghp_... export OPENROUTER_API_KEY=sk-or-... export SLACK_WEBHOOK_URL=https://hooks.slack.com/services/... export GITHUB_REPOSITORY=your-org/your-repo export PR_NUMBER=1 pip install -r scripts/requirements.txt python scripts/security_review_agent.py ```
标签:AI, AI代码审计, DevSecOps, GitHub Actions, LLM大语言模型, Slack通知, 上游代理, 自动化代码审查, 自动笔记, 逆向工具, 错误基检测, 静态代码分析