sast-spotbugs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSAST Scan with SpotBugs + Find Security Bugs (Java)
借助SpotBugs + Find Security Bugs进行SAST扫描(Java)
You are a security engineer running static analysis on Java code using SpotBugs with the Find Security Bugs plugin.
你是一名安全工程师,正在使用SpotBugs搭配Find Security Bugs插件对Java代码执行静态分析。
When to use
适用场景
Use this skill when asked to perform a SAST scan or security review on Java / JVM code.
当需要对Java / JVM代码执行SAST扫描或安全审查时,可使用该技能。
Prerequisites
前置条件
- SpotBugs installed with Find Security Bugs plugin
- Maven: add +
spotbugs-maven-plugintofindsecbugs-pluginpom.xml - Gradle: add plugin +
com.github.spotbugsdependencyfindsecbugs-plugin - Verify:
spotbugs -version
- 已安装SpotBugs并配置Find Security Bugs插件
- Maven:在中添加
pom.xml+spotbugs-maven-pluginfindsecbugs-plugin - Gradle:添加插件 +
com.github.spotbugs依赖findsecbugs-plugin - 验证:执行
spotbugs -version
Instructions
操作步骤
-
Identify the target — Determine the Java project or compiled classes to scan.
-
Run the scan:Maven:bash
mvn spotbugs:check -Dspotbugs.plugins=com.h3xstream.findsecbugs:findsecbugs-plugin:LATEST mvn spotbugs:spotbugs # generates XML reportStandalone CLI:bashspotbugs -textui -effort:max -low \ -pluginList findsecbugs-plugin.jar \ -xml:withMessages -output spotbugs-results.xml \ ./target/classes -
Parse the results — Read the XML output and present findings:
| # | Priority | Category | Bug Type | Class:Line | Finding | Remediation |
|---|----------|----------|----------|------------|---------|-------------|- Summarize — Provide total bugs by priority, critical security findings first, remediation steps.
-
确定扫描目标 —— 明确要扫描的Java项目或已编译类文件。
-
执行扫描:Maven方式:bash
mvn spotbugs:check -Dspotbugs.plugins=com.h3xstream.findsecbugs:findsecbugs-plugin:LATEST mvn spotbugs:spotbugs # 生成XML报告独立CLI方式:bashspotbugs -textui -effort:max -low \ -pluginList findsecbugs-plugin.jar \ -xml:withMessages -output spotbugs-results.xml \ ./target/classes -
解析扫描结果 —— 读取XML输出并呈现检测结果:
| 序号 | 优先级 | 类别 | 漏洞类型 | 类:行号 | 检测结果 | 修复建议 |
|---|----------|----------|----------|------------|---------|-------------|- 结果汇总 —— 按优先级统计漏洞总数,优先展示高危安全检测结果,并提供修复步骤。
Key Find Security Bugs Categories
Find Security Bugs核心检测类别
| Bug Pattern | Risk |
|---|---|
| SQL_INJECTION | SQL injection |
| COMMAND_INJECTION | OS command injection |
| XXE_DOCUMENT | XML External Entity |
| INSECURE_COOKIE | Missing Secure/HttpOnly flags |
| WEAK_MESSAGE_DIGEST | Insecure hash (MD5/SHA1) |
| OBJECT_DESERIALIZATION | Unsafe deserialization |
| SSRF | Server-Side Request Forgery |
| PATH_TRAVERSAL | Directory traversal |
| CIPHER_INTEGRITY | Insecure cipher mode |
| HARD_CODE_PASSWORD | Hardcoded credentials |
| 漏洞模式 | 风险说明 |
|---|---|
| SQL_INJECTION | SQL注入 |
| COMMAND_INJECTION | 操作系统命令注入 |
| XXE_DOCUMENT | XML外部实体注入 |
| INSECURE_COOKIE | 缺失Secure/HttpOnly标记 |
| WEAK_MESSAGE_DIGEST | 不安全哈希算法(MD5/SHA1) |
| OBJECT_DESERIALIZATION | 不安全反序列化 |
| SSRF | 服务器端请求伪造 |
| PATH_TRAVERSAL | 目录遍历 |
| CIPHER_INTEGRITY | 不安全加密模式 |
| HARD_CODE_PASSWORD | 硬编码凭据 |