Skip to content

Commit 475aa6c

Browse files
strogiyotecAlmas Abdrazak
andauthored
generate sarif (#1869)
Co-authored-by: Almas Abdrazak <abdrazak.almas@mongodb.com>
1 parent b922075 commit 475aa6c

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

.evergreen/ssdlc-report.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ printf "\nSpotBugs created the following SARIF reports\n"
7171
IFS=$'\n'
7272
declare -a SARIF_PATHS=($(find "${RELATIVE_DIR_PATH}/.." -path "*/spotbugs/*.sarif"))
7373
unset IFS
74+
if [ ${#SARIF_PATHS[@]} -eq 0 ]; then
75+
printf "\nERROR: No SARIF files found matching pattern */spotbugs/*.sarif\n"
76+
exit 1
77+
fi
7478
for SARIF_PATH in "${SARIF_PATHS[@]}"; do
7579
GRADLE_PROJECT_NAME="$(basename "$(dirname "$(dirname "$(dirname "$(dirname "${SARIF_PATH}")")")")")"
7680
NEW_SARIF_PATH="${SSDLC_STATIC_ANALYSIS_REPORTS_PATH}/${GRADLE_PROJECT_NAME}_$(basename "${SARIF_PATH}")"

buildSrc/src/main/kotlin/conventions/spotbugs.gradle.kts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ spotbugs {
4040

4141
tasks.withType<SpotBugsTask>().configureEach {
4242
if (name == "spotbugsMain") {
43-
reports {
44-
register("xml") { required.set(project.buildingWith("xmlReports.enabled")) }
45-
register("html") { required.set(!project.buildingWith("xmlReports.enabled")) }
46-
register("sarif") { required.set(project.buildingWith("ssdlcReport.enabled")) }
43+
reports.create("xml") {
44+
required.set(project.buildingWith("xmlReports.enabled"))
45+
outputLocation.set(file("$buildDir/reports/spotbugs/spotbugs.xml"))
46+
}
47+
reports.create("html") {
48+
required.set(!project.buildingWith("xmlReports.enabled"))
49+
outputLocation.set(file("$buildDir/reports/spotbugs/spotbugs.html"))
50+
}
51+
reports.create("sarif") {
52+
required.set(project.buildingWith("ssdlcReport.enabled"))
53+
outputLocation.set(file("$buildDir/reports/spotbugs/spotbugs.sarif"))
4754
}
4855
} else if (name == "spotbugsTest") {
4956
enabled = false

0 commit comments

Comments
 (0)