SAST Security Plugin
扫描代码安全漏洞
此技能提供全面的静态应用程序安全测试指导,帮助在部署前识别代码中的漏洞。它引导用户配置和运行多个 SAST 工具,适用于不同的语言和框架。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“SAST Security Plugin”。 Help me scan my Python Flask app for SQL injection vulnerabilities
预期结果:
要使用 Bandit 和 Semgrep 扫描您的 Flask 应用程序以查找 SQL 注入漏洞:
1. 安装工具:`pip install bandit semgrep`
2. 运行 Bandit:`bandit -r . -f json -o bandit-report.json`
3. 使用 SQL 注入规则运行 Semgrep:
```bash
semgrep --config=p/security-audit --json --output=semgrep-sqli.json
```
4. 查看 JSON 报告中的 SQL 注入发现。查找:
- SQL 查询中的字符串格式化(B608、B611)
- 查询中未经过滤的用户输入
- 缺少参数化查询
5. 通过使用参数化查询修复已识别的问题:
```python
# 存在漏洞
cursor.execute("SELECT * FROM users WHERE id = " + user_id)
# 安全
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
```
正在使用“SAST Security Plugin”。 Configure ESLint security for my TypeScript React application
预期结果:
为 TypeScript React 配置 ESLint 安全:
1. 安装依赖:
```bash
npm install --save-dev eslint @typescript-eslint/parser @eslint/plugin-security eslint-plugin-react
```
2. 创建 .eslintrc-security.json:
```json
{
"parser": "@typescript-eslint/parser",
"plugins": ["@eslint/plugin-security", "react"],
"extends": ["plugin:security/recommended"],
"rules": {
"security/detect-object-injection": "error",
"security/detect-non-literal-fs-filename": "error",
"security/detect-eval-with-expression": "error",
"no-danger": "error"
}
}
```
3. 运行扫描:
```bash
eslint --ext .ts,.tsx --format json > eslint-security-report.json
```
安全审计
安全This is a prompt-only documentation skill providing SAST (Static Application Security Testing) guidance. The static analyzer scanned 0 executable files (0 lines of code) because the skill consists entirely of markdown documentation (SKILL.md). No suspicious patterns or risk factors were detected. The skill provides legitimate security guidance for configuring and running established SAST tools like Bandit, Semgrep, and ESLint Security.
质量评分
你能构建什么
部署前安全审查
在将代码部署到生产环境之前运行全面的 SAST 扫描,以便及早发现漏洞。
遗留代码安全评估
对继承的或较旧的代码库进行安全问题和技术债务审计。
CI/CD 安全门禁
将自动化安全扫描集成到拉取请求工作流中,阻止存在漏洞的代码。
试试这些提示
帮助我设置并运行 Bandit 来扫描我的 Python 项目中的安全漏洞。我在当前目录中有一个 Django 应用程序。
我需要对包含 Python、JavaScript 和 Go 代码的项目运行全面的安全扫描。向我展示如何配置 Semgrep 来扫描所有这些语言并聚合结果。
我们组织有特定的安全策略。创建一个 Semgrep 自定义规则来检测源代码文件中硬编码的内部 API 密钥。
设置一个 GitHub Actions 工作流,在每个拉取请求上运行 SAST 扫描。包括 Python 的 Bandit、JavaScript 的 ESLint Security,并在发现 HIGH 或 CRITICAL 漏洞时使构建失败。
最佳实践
- 在开发早期使用预提交钩子运行 SAST 扫描,以便在代码审查之前发现问题
- 结合使用多个 SAST 工具,因为每种工具都能捕获不同类型的漏洞 - Bandit 用于 Python,Semgrep 用于多语言,ESLint 用于 JS/TS
- 通过为测试文件、生成代码和已知安全模式配置排除项来调整误报
避免
- 运行扫描但不审查或分类结果 - 高误报率可能导致警报疲劳
- 根据严重程度(仅 CRITICAL/HIGH)进行优先级排序,而是阻止任何发现的部署
- 在未验证数据处理策略的情况下将专有代码上传到外部扫描服务