Skip to content

Commit

Permalink
Merge pull request #132 from cicirello/spotbugs
Browse files Browse the repository at this point in the history
Configured SpotBugs and FindSecBugs
  • Loading branch information
cicirello authored Aug 5, 2023
2 parents 96fe3a8 + af20956 commit c7bc140
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 20 deletions.
14 changes: 0 additions & 14 deletions .lift.toml

This file was deleted.

4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2023-01-12
## [Unreleased] - 2023-08-05

### Added

Expand All @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

### CI/CD
* Integrated SpotBugs into build process.
* Integrated Find Security Bugs into build process.

### Other

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ To include generation of a code coverage report during the build,
execute `mvn package -Pcoverage` at the root of the repository to
enable a Maven profile that executes JaCoCo during the test phase.

To run all static analysis tools (i.e., SpotBugs, Find Security Bugs,
refactor-first), execute `mvn package -Panalysis` to enable a Maven
profile that executes the various static analysis tools that we are
using. The SpotBugs html report will be found in the `target` directory,
or you can use the SpotBugs GUI with: `mvn spotbugs:gui -Panalysis`. The
refactor-first report will be found in the `target/site` directory.

To run all of the above: `mvn package -P "analysis,coverage"`.

The jar file of the application is executable, so you then simply
double click it to run.

Expand Down
26 changes: 25 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
</build>
</profile>
<profile>
<id>refactor</id>
<id>analysis</id>
<build>
<plugins>
<plugin>
Expand All @@ -173,6 +173,30 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.7.3.5</version>
<configuration>
<htmlOutput>true</htmlOutput>
<excludeFilterFile>${session.executionRootDirectory}/spotbugs-exclude.xml</excludeFilterFile>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>1.12.0</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>spotbugs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down
13 changes: 13 additions & 0 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<FindBugsFilter>
<!-- Random number generation is not a security application -->
<Match>
<Bug pattern="PREDICTABLE_RANDOM" />
</Match>

<!-- False positive -->
<Match>
<Bug pattern="PATH_TRAVERSAL_IN" />
<Class name="org.cicirello.ibp.MenuBar" />
<Method name="saveSessionLog" />
</Match>
</FindBugsFilter>
5 changes: 1 addition & 4 deletions src/main/java/org/cicirello/ibp/MenuBar.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Interactive Bin Packing.
* Copyright (C) 2008, 2010, 2020-2022 Vincent A. Cicirello
* Copyright (C) 2008, 2010, 2020-2023 Vincent A. Cicirello
*
* This file is part of Interactive Bin Packing.
*
Expand Down Expand Up @@ -344,9 +344,6 @@ public void actionPerformed(ActionEvent e) {
}

void saveSessionLog(File logFile) {
// False positive on a PATH_TRAVERSAL_IN, but @SuppressWarnings("findsecbugs:PATH_TRAVERSAL_IN")
// seems to be ignored by FindSecBugs. Forced to disable detection of this type of bug entirely
// in lift configuration.
if (!logFile.getPath().endsWith(".ibp")) {
logFile = new File(logFile.getPath() + ".ibp");
chooser.setSelectedFile(logFile);
Expand Down

0 comments on commit c7bc140

Please sign in to comment.