/pom.xml

  1. [...]
  2. <build>
  3. <plugins>
  4. [...]
  5. <!-- SpotBugs Static Analysis -->
  6. <plugin>
  7. <groupId>com.github.spotbugs</groupId>
  8. <artifactId>spotbugs-maven-plugin</artifactId>
  9. <version>3.1.12</version>
  10. <configuration>
  11. <effort>Max</effort>
  12. <threshold>Low</threshold>
  13. <failOnError>true</failOnError>
  14. <includeFilterFile>${session.executionRootDirectory}/spotbugs-security-include.xml</includeFilterFile>
  15. <excludeFilterFile>${session.executionRootDirectory}/spotbugs-security-exclude.xml</excludeFilterFile>
  16. <plugins>
  17. <plugin>
  18. <groupId>com.h3xstream.findsecbugs</groupId>
  19. <artifactId>findsecbugs-plugin</artifactId>
  20. <version>1.9.0</version>
  21. </plugin>
  22. </plugins>
  23. </configuration>
  24. </plugin>
  25. </plugins>
  26. </build>

/spotbugs-security-include.xml

  1. <FindBugsFilter>
  2. <Match>
  3. <Bug category="SECURITY"/>
  4. </Match>
  5. </FindBugsFilter>

/spotbugs-security-exclude.xml

  1. <FindBugsFilter>
  2. </FindBugsFilter>

开始扫描

  1. mvn compile
  2. mvn spotbugs:spotbugs

分析结果

  1. mvn spotbugs:gui

参考资料