Skip to content

Commit 8b6573e

Browse files
authored
3.x: upgrade owasp dep check 12.1.5 (helidon-io#10706)
* Upgrade owasp dependency check plugin to 12.1.5 * Update dependency check script to handle ossindex.sonatype.org auth
1 parent fcad6e0 commit 8b6573e

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed
Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -e
22
#
3-
# Copyright (c) 2020, 2023 Oracle and/or its affiliates.
3+
# Copyright (c) 2020, 2025 Oracle and/or its affiliates.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -15,31 +15,61 @@
1515
# limitations under the License.
1616
#
1717

18+
set -o pipefail || true # trace ERR through pipes
19+
set -o errtrace || true # trace ERR through commands and functions
20+
set -o errexit || true # exit the script if any statement returns a non-true return value
21+
1822
# Path to this script
19-
[ -h "${0}" ] && readonly SCRIPT_PATH="$(readlink "${0}")" || readonly SCRIPT_PATH="${0}"
23+
if [ -h "${0}" ] ; then
24+
SCRIPT_PATH="$(readlink "${0}")"
25+
else
26+
# shellcheck disable=SC155
27+
SCRIPT_PATH="${0}"
28+
fi
29+
readonly SCRIPT_PATH
2030

21-
# Load pipeline environment setup and define WS_DIR
22-
. $(dirname -- "${SCRIPT_PATH}")/includes/pipeline-env.sh "${SCRIPT_PATH}" '../..'
31+
# Path to the root of the workspace
32+
# shellcheck disable=SC2046
33+
WS_DIR=$(cd $(dirname -- "${SCRIPT_PATH}") ; cd ../.. ; pwd -P)
2334

24-
# Setup error handling using default settings (defined in includes/error_handlers.sh)
25-
error_trap_setup
35+
on_error(){
36+
CODE="${?}" && \
37+
set +x && \
38+
printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \
39+
"${CODE}" "${BASH_SOURCE[0]}" "${LINENO}" "${BASH_COMMAND}"
40+
}
41+
trap on_error ERR
2642

27-
readonly RESULT_FILE=$(mktemp -t XXXdependency-check-result)
43+
RESULT_FILE=$(mktemp -t XXXdependency-check-result)
44+
readonly RESULT_FILE
2845

29-
die() { cat ${RESULT_FILE} ; echo "Dependency report in ${WS_DIR}/target" ; echo "${1}" ; exit 1 ;}
46+
die() { cat "${RESULT_FILE}" ; echo "Dependency report in ${WS_DIR}/target" ; echo "${1}" ; exit 1 ;}
3047

31-
if [ -n "${JENKINS_HOME}" ] || [ "${GITHUB_ACTIONS}" = "true" ]; then
48+
if [ "${PIPELINE}" = "true" ] ; then
3249
# If in pipeline do a priming build before scan
33-
mvn ${MAVEN_ARGS} -f ${WS_DIR}/pom.xml clean install -DskipTests
50+
# shellcheck disable=SC2086
51+
mvn ${MAVEN_ARGS} -f "${WS_DIR}"/pom.xml clean install -DskipTests
52+
fi
53+
54+
# The Sonatype OSS Index analyzer requires authentication
55+
# See https://ossindex.sonatype.org/doc/auth-required
56+
# Set OSS_INDEX_USERNAME and OSS_INDEX_PASSWORD to authenticate.
57+
# Otherwise OSS Index analyzer will be disabled
58+
# And yes, this option uses a lower case i while Username and Password has an upper case I
59+
OSS_INDEX_OPTIONS="-DossindexAnalyzerEnabled=false"
60+
if [ -n "${OSS_INDEX_PASSWORD}" ] && [ -n "${OSS_INDEX_USERNAME}" ]; then
61+
OSS_INDEX_OPTIONS="-DossindexAnalyzerEnabled=true -DossIndexUsername=${OSS_INDEX_USERNAME} -DossIndexPassword=${OSS_INDEX_PASSWORD}"
3462
fi
3563

3664
# Setting NVD_API_KEY is not required but improves behavior of NVD API throttling
3765

66+
# shellcheck disable=SC2086
3867
mvn ${MAVEN_ARGS} -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN org.owasp:dependency-check-maven:aggregate \
39-
-f ${WS_DIR}/pom.xml \
68+
-f "${WS_DIR}"/pom.xml \
4069
-Dtop.parent.basedir="${WS_DIR}" \
41-
-Dnvd-api-key=${NVD_API_KEY} \
42-
> ${RESULT_FILE} || die "Error running the Maven command"
70+
-DnvdApiKey="${NVD_API_KEY}" \
71+
${OSS_INDEX_OPTIONS} \
72+
> "${RESULT_FILE}" || die "Error running the Maven command"
4373

44-
grep -i "One or more dependencies were identified with known vulnerabilities" ${RESULT_FILE} \
74+
grep -i "One or more dependencies were identified with known vulnerabilities" "${RESULT_FILE}" \
4575
&& die "CVE SCAN ERROR" || echo "CVE SCAN OK"

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<version.plugin.source>3.3.0</version.plugin.source>
120120
<version.plugin.spotbugs>4.4.2.2</version.plugin.spotbugs>
121121
<version.plugin.findsecbugs>1.11.0</version.plugin.findsecbugs>
122-
<version.plugin.dependency-check>12.1.3</version.plugin.dependency-check>
122+
<version.plugin.dependency-check>12.1.5</version.plugin.dependency-check>
123123
<version.plugin.surefire>3.0.0</version.plugin.surefire>
124124
<version.plugin.toolchains>1.1</version.plugin.toolchains>
125125
<version.plugin.version-plugin>2.3</version.plugin.version-plugin>

0 commit comments

Comments
 (0)