Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default HTML report from Docker images #2091

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docker/Dockerfile.docker
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ RUN apt-get update && \
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common git && \
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
apt-get update && apt-get install -y docker-ce jq && \
npm install --global snyk snyk-to-html && \
apt-get update && apt-get install -y docker-ce && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -20,7 +20,6 @@ ENV HOME /home/node
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION docker
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.gradle-2.8
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ RUN apt-get update && \
curl -L https://services.gradle.org/distributions/gradle-2.8-bin.zip -o gradle-2.8-bin.zip && \
unzip gradle-2.8-bin.zip -d /home/node/ &&\
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -26,7 +26,6 @@ ENV PATH=$PATH:$GRADLE_HOME/bin
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION gradle-2.8
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.gradle-4.4
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ RUN apt-get update && \
curl -L https://services.gradle.org/distributions/gradle-4.4-bin.zip -o gradle-4.4-bin.zip && \
unzip gradle-4.4-bin.zip -d /home/node/ && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -26,7 +26,6 @@ ENV PATH=$PATH:$GRADLE_HOME/bin
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION gradle-4.4
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.gradle-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ RUN apt-get update && \
curl -L https://services.gradle.org/distributions/gradle-5.4-bin.zip -o gradle-5.4-bin.zip && \
unzip gradle-5.4-bin.zip -d /home/node/ && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -26,7 +26,6 @@ ENV PATH=$PATH:$GRADLE_HOME/bin
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION gradle-5.4
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.gradle-5.4_java11
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ RUN apt-get update && \
curl -L https://services.gradle.org/distributions/gradle-5.4-bin.zip -o gradle-5.4-bin.zip && \
unzip gradle-5.4-bin.zip -d /home/node/ && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
apt-get install -y nodejs && \
node -v && \
npm -v && \
npm install --global snyk snyk-to-html && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -28,7 +28,6 @@ ENV PATH=$PATH:$GRADLE_HOME/bin
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENTRYPOINT ["./docker-entrypoint.sh"]

Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.maven-3.5.4
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ RUN apt-get update && \
tar -xvzf apache-maven-3.5.4-bin.tar.gz && \
rm -f apache-maven-3.5.4-bin.tar.gz && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -26,7 +26,6 @@ ENV PATH /home/node/apache-maven-3.5.4/bin:$PATH
ENV PROJECT_PATH /project

ADD docker-entrypoint.sh .
ADD snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION maven-3.5.4
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.maven-3.6.3
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ RUN apt-get update && \
tar -xvzf apache-maven-3.6.3-bin.tar.gz && \
rm -f apache-maven-3.6.3-bin.tar.gz && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -26,7 +26,6 @@ ENV PATH /home/node/apache-maven-3.6.3/bin:$PATH
ENV PROJECT_PATH /project

ADD docker-entrypoint.sh .
ADD snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION maven-3.6.3
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.maven-3.6.3_java11
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ RUN apt-get update && \
tar -xvzf apache-maven-3.6.3-bin.tar.gz && \
rm -f apache-maven-3.6.3-bin.tar.gz && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -26,7 +26,6 @@ ENV PATH /home/node/apache-maven-3.6.3/bin:$PATH
ENV PROJECT_PATH /project

ADD docker-entrypoint.sh .
ADD snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION maven-3.6.3_java11
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.npm_ruby
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ENV HOME /home/node

# Install snyk cli and clean up
RUN apt-get update && \
apt-get install -y jq git && \
npm install --global snyk snyk-to-html && \
apt-get install -y git && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -17,7 +17,6 @@ RUN apt-get update && \
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
# This image is currently being used for nuget, composer and ruby
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.python-2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get update && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -23,7 +23,6 @@ ENV PROJECT_PATH /project

COPY docker-python-entrypoint.sh .
COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION python-2
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.python-3
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get update && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -23,7 +23,6 @@ ENV PROJECT_PATH /project

COPY docker-python-entrypoint.sh .
COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION python-3
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.python-3.6
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get update && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -23,7 +23,6 @@ ENV PROJECT_PATH /project

COPY docker-python-entrypoint.sh .
COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION python-3.6
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.python-3.8
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get update && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -23,7 +23,6 @@ ENV PROJECT_PATH /project

COPY docker-python-entrypoint.sh .
COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION python-3.8
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.python-3.9
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get update && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -23,7 +23,6 @@ ENV PROJECT_PATH /project

COPY docker-python-entrypoint.sh .
COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION python-3.9
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.sbt-0.13.16
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ RUN apt-get update && \
echo "net.virtualvoid.sbt.graph.DependencyGraphSettings.graphSettings" >> /home/node/.sbt/0.13/user.sbt && \
echo "-sbt-version 0.13.16" >> /etc/sbt/sbtopts && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -36,7 +36,6 @@ ENV M2 /home/node/.m2
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION sbt-0.13.16
Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile.sbt-1.0.4
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ RUN apt-get update && \
echo "addCommandAlias(\"dependency-tree\", \"dependencyTree\")" >> /root/.sbt/1.0/user.sbt && \
echo "addCommandAlias(\"dependency-tree\", \"dependencyTree\")" >> /home/node/.sbt/1.0/user.sbt && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs jq && \
npm install --global snyk snyk-to-html && \
apt-get install -y nodejs && \
npm install --global snyk && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand All @@ -35,7 +35,6 @@ ENV M2 /home/node/.m2
ENV PROJECT_PATH /project

COPY docker-entrypoint.sh .
COPY snyk_report.css .

ENV SNYK_INTEGRATION_NAME DOCKER_SNYK_CLI
ENV SNYK_INTEGRATION_VERSION sbt-1.0.4
Expand Down
68 changes: 0 additions & 68 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

OUTPUT_FILE=snyk-result.json
MONITOR_OUTPUT_FILE=snyk-monitor-result.json
ERROR_FILE=snyk-error.log
HTML_FILE=snyk_report.html
SNYK_COMMAND="$1"
SNYK_PARAMS="${@:2}"
ADDITIONAL_ENV=""
Expand Down Expand Up @@ -38,37 +36,6 @@ exitWithMsg() {
exit "$2"
}

##
## Start of backward compatability code.
## Should be phased out when we phase out the current version of the jenkins
## plugin.
## These parameters should only be used with the Jenkins plugin! Please see
## README.md for more info.
##

TEST_SETTINGS=""
PROJECT_SUBDIR=""

if [ -n "${TARGET_FILE}" ]; then
if [ ! -f "${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}" ]; then
exitWithMsg "\"${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}\" does not exist" 2
fi

PROJECT_SUBDIR=$(dirname "${TARGET_FILE}")
MANIFEST_NAME=$(basename "${TARGET_FILE}")
TEST_SETTINGS="--file=${MANIFEST_NAME} "
fi

if [ -n "${ORGANIZATION}" ]; then
TEST_SETTINGS="${TEST_SETTINGS} --org=${ORGANIZATION}"
fi

SNYK_PARAMS="${SNYK_PARAMS} ${TEST_SETTINGS}"

##
## End of backward compatability code
##

if [ -z "${SNYK_TOKEN}" ]; then
exitWithMsg "Missing \${SNYK_TOKEN}" 2
fi
Expand All @@ -88,38 +55,3 @@ RC=$?
if [ "$RC" -ne "0" ] && [ "$RC" -ne "1" ]; then
exitWithMsg "${OUTPUT_FILE}" "$RC"
fi

#
# Commented out the condition because we want to always generate the html
# file until we phase out the old version of the Jenkins plugin.
# TODO: Re-add this option to documentation once back
#
# - `GENERATE_REPORT` - [OPTIONAL] if set, this will generate the HTML report
# with a summary of the vulnerabilities detected by snyk.
#
# if [ -n $GENERATE_REPORT ]; then
runCmdAsDockerUser "touch \"${PROJECT_PATH}/${PROJECT_FOLDER}/${HTML_FILE}\""

if [ -n "$MONITOR" ]; then
echo "Monitoring & generating report ..."
runCmdAsDockerUser "PATH=$PATH snyk monitor --json ${SNYK_PARAMS} ${ADDITIONAL_ENV} > ${MONITOR_OUTPUT_FILE} 2>$ERROR_FILE"
runCmdAsDockerUser "cat ${MONITOR_OUTPUT_FILE} | jq -r 'if type==\"array\" then .[].uri? else .uri? end' | awk '{print \"<center><a target=\\\"_blank\\\" href=\\\"\" \$0 \"\\\">View On Snyk.io</a></center>\"}' > \"${PROJECT_PATH}/${PROJECT_FOLDER}/${HTML_FILE}\" 2>>\"${ERROR_FILE}\""
fi


runCmdAsDockerUser "cat \"${OUTPUT_FILE}\" | \
jq 'def sortBySeverity: .vulnerabilities|= map(. + {severity_numeric: (if(.severity) == \"high\" then 1 else (if(.severity) == \"medium\" then 2 else (if(.severity) == \"low\" then 3 else 4 end) end) end)}) |.vulnerabilities |= sort_by(.severity_numeric) | del(.vulnerabilities[].severity_numeric); if (. | type) == \"array\" then map(sortBySeverity) else sortBySeverity end'| \
snyk-to-html | \
sed 's/<\/head>/ <link rel=\"stylesheet\" href=\"snyk_report.css\"><\/head>/' \
>> \"${PROJECT_PATH}/${PROJECT_FOLDER}/${HTML_FILE}\""

runCmdAsDockerUser "cat /home/node/snyk_report.css > \
\"${PROJECT_PATH}/${PROJECT_FOLDER}/snyk_report.css\""

if [ $RC -ne "0" ]; then
exitWithMsg "${OUTPUT_FILE}" "$RC"
fi

cat "${OUTPUT_FILE}"

exit "$RC"
Loading