https://find-sec-bugs.github.io/
Findsecbugs là một plugin cho việc kiểm tra các lỗi bảo mật cho một ứng dụng web chạy Java.
Plugin này có thể tích hợp với nhiếu công cụ phát triền khác nhau như : Eclipse , IntelliJ và NetBeans.
Ngoài ra nó được dùng trong CI như Jenkins và Sonar.
Bài viết này tập trung vào việc Findsecbugs tích hợp với Maven và Jenkins.
I. Cài đặt FindBug plugin trên Jenkins.
Manage Jenkins >> Manage Plugin >> Available
Select : "FindBug Plug-in"
II. Configure Maven:
1. Cấu hình file POM:
Trong file pom.xml :
[...]
<build>
<plugins>
[...]
<!-- SpotBugs Static Analysis -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<failOnError>true</failOnError>
<includeFilterFile>${session.executionRootDirectory}/spotbugs-security-include.xml</includeFilterFile>
<excludeFilterFile>${session.executionRootDirectory}/spotbugs-security-exclude.xml</excludeFilterFile>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>LATEST</version> <!-- Auto-update to the latest stable -->
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
</build>
File: /spotbugs-security-include.xml
<FindBugsFilter>
<Match>
<Bug category="SECURITY"/>
</Match>
</FindBugsFilter>
File : /spotbugs-security-exclude.xml
<FindBugsFilter>
</FindBugsFilter>
2. Chạy Scan:
mvn compile
mvn spotbugs:spotbugs
Với :findbugs:findbugs
thì complie code trong /target/classes/
3. Phân tích kết quả:
Offical GUI:
mvn spotbugs:gui
XML report;
target/findbugsXml.xml
Khi chạy scan thì kết quả xuất ra file report trong thư mục : target
III. Build trong Jenkins:
clean install findbugs:findbugs
Thiết lập : Build Settings : Check "Publish FindBugs analysis results"
IV: FindBug với Sonarque :
Cài đặt FindBugs:
Mặc định là profile là Sonar way. Bạn chọn một trong 2 profile :
Chạy maven:
mvn sonar:sonar
FindBugs Security Audit
or FindBugs Security Minimal
Chạy maven:
mvn sonar:sonar
Tạo một custom profile thì bạn chọn repository :
Find Sec Bugs:
Nhận xét
Đăng nhận xét