sast-flawfinder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSAST Scan with Flawfinder (C/C++)
使用Flawfinder进行SAST扫描(C/C++)
You are a security engineer running static analysis on C/C++ code using Flawfinder.
你是一名安全工程师,正在使用Flawfinder对C/C++代码执行静态分析。
When to use
适用场景
Use this skill when asked to perform a SAST scan or security review on C or C++ code.
当需要对C或C++代码执行SAST扫描或安全审查时,使用本技能。
Prerequisites
前提条件
- Flawfinder installed ()
pip install flawfinder - Verify:
flawfinder --version
- 已安装Flawfinder()
pip install flawfinder - 验证安装:
flawfinder --version
Instructions
操作步骤
- Identify the target — Determine the C/C++ source file(s) or directory to scan.
- Run the scan:
bash
flawfinder --json <target-path> > flawfinder-results.json- With minimum risk level:
flawfinder --minlevel=3 --json <target> - With column info:
flawfinder --columns --json <target> - CSV output:
flawfinder --csv <target> > results.csv
- With minimum risk level:
- Parse the results — Read JSON output and present findings:
| # | Risk Level (0-5) | CWE | File:Line:Column | Function | Finding | Remediation |
|---|-------------------|-----|------------------|----------|---------|-------------|- Summarize — Provide total hits by risk level, critical findings (level 4-5) first, safe alternatives.
- 确定目标 — 确定要扫描的C/C++源文件或目录。
- 运行扫描:
bash
flawfinder --json <target-path> > flawfinder-results.json- 指定最低风险等级:
flawfinder --minlevel=3 --json <target> - 包含列信息:
flawfinder --columns --json <target> - 输出CSV格式:
flawfinder --csv <target> > results.csv
- 指定最低风险等级:
- 解析结果 — 读取JSON输出并呈现检测结果:
| 序号 | 风险等级(0-5) | CWE | 文件:行:列 | 函数 | 检测结果 | 修复建议 |
|---|-------------------|-----|------------------|----------|---------|-------------|- 总结 — 按风险等级统计总检测数,优先展示严重检测结果(等级4-5),并提供安全替代方案。
Key Risk Categories
核心风险类别
| Category | Dangerous Functions | Safe Alternatives |
|---|---|---|
| Buffer overflow | | |
| Format string | | |
| Race condition | | |
| Integer overflow | | |
| Memory | | Bounded |
| Crypto | | |
| 类别 | 危险函数 | 安全替代方案 |
|---|---|---|
| 缓冲区溢出 | | |
| 格式化字符串 | | |
| 竞争条件 | | 带正确标志的 |
| 整数溢出 | | 带边界检查的 |
| 内存操作 | 无边界的 | 带边界的 |
| 加密 | | |