vulnerability-scanner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVulnerability Scanner
漏洞扫描器
Quick Start
快速开始
Scan a codebase for common vulnerabilities:
bash
undefined扫描代码库中的常见漏洞:
bash
undefinedFor JavaScript/TypeScript
For JavaScript/TypeScript
npx eslint --plugin security .
npx eslint --plugin security .
For Python
For Python
bandit -r . -f json
bandit -r . -f json
For general patterns
For general patterns
grep -rn "eval|exec|system|shell" --include=".py" --include=".js"
undefinedgrep -rn "eval|exec|system|shell" --include=".py" --include=".js"
undefinedInstructions
操作步骤
Step 1: Identify Project Type
步骤1:识别项目类型
Detect the technology stack:
- Check for (Node.js)
package.json - Check for or
requirements.txt(Python)pyproject.toml - Check for (Go)
go.mod - Check for (Rust)
Cargo.toml
检测技术栈:
- 检查是否存在(Node.js)
package.json - 检查是否存在或
requirements.txt(Python)pyproject.toml - 检查是否存在(Go)
go.mod - 检查是否存在(Rust)
Cargo.toml
Step 2: Run Static Analysis
步骤2:运行静态分析
JavaScript/TypeScript:
bash
npx eslint --plugin security --ext .js,.ts,.jsx,.tsx .Python:
bash
pip install bandit
bandit -r . -f json -o bandit-report.jsonGo:
bash
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...JavaScript/TypeScript:
bash
npx eslint --plugin security --ext .js,.ts,.jsx,.tsx .Python:
bash
pip install bandit
bandit -r . -f json -o bandit-report.jsonGo:
bash
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...Step 3: Check for Common Patterns
步骤3:检查常见危险模式
Scan for dangerous patterns:
| Pattern | Risk | Languages |
|---|---|---|
| Code injection | JS, Python |
| Command injection | Python |
| Command injection | Python |
| XSS | React |
| SQL string concatenation | SQL injection | All |
| Deserialization | Python |
扫描以下危险代码模式:
| 代码模式 | 风险等级 | 适用语言 |
|---|---|---|
| 代码注入 | JS、Python |
| 命令注入 | Python |
| 命令注入 | Python |
| XSS | React |
| SQL字符串拼接 | SQL注入 | 所有语言 |
| 反序列化风险 | Python |
Step 4: Categorize Findings
步骤4:分类检测结果
Assign severity based on:
- Critical: Remote code execution, authentication bypass
- High: SQL injection, XSS, SSRF
- Medium: Information disclosure, CSRF
- Low: Missing headers, verbose errors
根据以下标准划分严重等级:
- Critical(严重):远程代码执行、身份验证绕过
- High(高危):SQL注入、XSS、SSRF
- Medium(中危):信息泄露、CSRF
- Low(低危):缺失安全头、详细错误信息暴露
Step 5: Generate Report
步骤5:生成检测报告
Format findings:
undefined按以下格式整理检测结果:
undefinedSecurity Scan Results
安全扫描结果
Critical (0)
Critical(严重)(0)
[None found]
[未发现相关漏洞]
High (2)
High(高危)(2)
-
SQL Injection - src/db/queries.js:45
- Pattern: String concatenation in SQL query
- Fix: Use parameterized queries
-
XSS Vulnerability - src/components/Comment.jsx:23
- Pattern: dangerouslySetInnerHTML with user input
- Fix: Sanitize input with DOMPurify
undefined-
SQL注入 - src/db/queries.js:45
- 问题模式:SQL查询中使用字符串拼接
- 修复方案:使用参数化查询
-
XSS漏洞 - src/components/Comment.jsx:23
- 问题模式:将用户输入直接传入dangerouslySetInnerHTML
- 修复方案:使用DOMPurify对输入进行净化
undefinedCommon Vulnerability Patterns
常见漏洞模式
Injection Flaws
注入类漏洞
javascript
// BAD: SQL Injection
const query = `SELECT * FROM users WHERE id = ${userId}`;
// GOOD: Parameterized query
const query = 'SELECT * FROM users WHERE id = ?';
db.query(query, [userId]);javascript
// BAD: SQL Injection
const query = `SELECT * FROM users WHERE id = ${userId}`;
// GOOD: Parameterized query
const query = 'SELECT * FROM users WHERE id = ?';
db.query(query, [userId]);Cross-Site Scripting (XSS)
跨站脚本攻击(XSS)
javascript
// BAD: Direct HTML insertion
element.innerHTML = userInput;
// GOOD: Text content or sanitization
element.textContent = userInput;
// or
element.innerHTML = DOMPurify.sanitize(userInput);javascript
// BAD: Direct HTML insertion
element.innerHTML = userInput;
// GOOD: Text content or sanitization
element.textContent = userInput;
// or
element.innerHTML = DOMPurify.sanitize(userInput);Advanced
进阶内容
For detailed information, see:
- CVE Patterns - Common vulnerability patterns by type
- Remediation Guide - Fix strategies for each vulnerability type
- Tools Reference - Security scanning tools by language
如需详细信息,请参阅:
- CVE Patterns - 按类型划分的常见漏洞模式
- Remediation Guide - 各类型漏洞的修复策略
- Tools Reference - 各语言对应的安全扫描工具