-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add docker files for CLI and update README
- Loading branch information
Showing
7 changed files
with
611 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM node:8-slim | ||
|
||
MAINTAINER Snyk Ltd | ||
|
||
# Install Java 8 | ||
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list | ||
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list | ||
|
||
# Accept license non-iteractive | ||
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections | ||
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 | ||
RUN apt-get update | ||
RUN apt-get install -y oracle-java8-installer oracle-java8-set-default | ||
|
||
#Install gradle | ||
RUN curl -L https://services.gradle.org/distributions/gradle-2.8-bin.zip -o gradle-2.8-bin.zip && \ | ||
apt-get install -y unzip && \ | ||
unzip gradle-2.8-bin.zip -d /home/node/ | ||
|
||
# Install snyk cli | ||
RUN npm install --global snyk snyk-to-html && \ | ||
apt-get update && \ | ||
apt-get install jq | ||
|
||
ENV GRADLE_HOME=/home/node/gradle-2.8 | ||
ENV PATH=$PATH:$GRADLE_HOME/bin | ||
|
||
RUN chmod -R a+wrx /home/node | ||
WORKDIR /home/node | ||
ENV HOME /home/node | ||
ENV M2 /home/node/.m2 | ||
|
||
# The path at which the project is mounted (-v runtime arg) | ||
ENV PROJECT_PATH /project | ||
|
||
ADD docker-entrypoint.sh . | ||
ADD snyk_report.css . | ||
|
||
ENTRYPOINT ["./docker-entrypoint.sh"] | ||
|
||
# Default command is `snyk test` | ||
# Override with `docker run ... snyk/snyk-cli <command> <args>` | ||
CMD ["test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM node:8-slim | ||
|
||
MAINTAINER Snyk Ltd | ||
|
||
# Install Java 8 | ||
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list | ||
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list | ||
|
||
# Accept license non-iteractive | ||
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections | ||
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 | ||
RUN apt-get update | ||
RUN apt-get install -y oracle-java8-installer oracle-java8-set-default | ||
|
||
#Install maven | ||
RUN wget http://www-eu.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz | ||
RUN tar -xvzf apache-maven-3.5.2-bin.tar.gz | ||
RUN rm -f apache-maven-3.5.2-bin.tar.gz | ||
|
||
# Install snyk cli | ||
RUN npm install --global snyk snyk-to-html && \ | ||
apt-get update && \ | ||
apt-get install jq | ||
|
||
RUN chmod -R a+wrx /home/node | ||
WORKDIR /home/node | ||
ENV HOME /home/node | ||
ENV M2 /home/node/.m2 | ||
ENV PATH /apache-maven-3.5.2/bin:$PATH | ||
|
||
# The path at which the project is mounted (-v runtime arg) | ||
ENV PROJECT_PATH /project | ||
|
||
ADD docker-entrypoint.sh . | ||
ADD snyk_report.css . | ||
|
||
ENTRYPOINT ["./docker-entrypoint.sh"] | ||
|
||
# Default command is `snyk test` | ||
# Override with `docker run ... snyk/snyk-cli <command> <args>` | ||
CMD ["test"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM node:8-slim | ||
|
||
MAINTAINER Snyk Ltd | ||
|
||
# Install snyk cli | ||
RUN npm install --global snyk snyk-to-html && \ | ||
apt-get update && \ | ||
apt-get install jq | ||
|
||
RUN chmod -R a+wrx /home/node | ||
WORKDIR /home/node | ||
ENV HOME /home/node | ||
|
||
# The path at which the project is mounted (-v runtime arg) | ||
ENV PROJECT_PATH /project | ||
|
||
ADD docker-entrypoint.sh . | ||
ADD snyk_report.css . | ||
|
||
ENTRYPOINT ["./docker-entrypoint.sh"] | ||
|
||
# Default command is `snyk test` | ||
# Override with `docker run ... snyk/snyk-cli <command> <args>` | ||
CMD ["test"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM node:8-slim | ||
|
||
MAINTAINER Snyk Ltd | ||
|
||
# Install Java 8 | ||
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list | ||
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list | ||
|
||
# Accept license non-iteractive | ||
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections | ||
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 | ||
RUN apt-get update | ||
RUN apt-get install -y oracle-java8-installer oracle-java8-set-default | ||
|
||
#Install sbt | ||
RUN echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list && \ | ||
apt-get install apt-transport-https && \ | ||
curl -L -o sbt.deb http://dl.bintray.com/sbt/debian/sbt-0.13.16.deb && \ | ||
dpkg -i sbt.deb | ||
|
||
RUN echo "docker-user ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers && \ | ||
mkdir -p /home/node/.sbt/0.13/plugins && \ | ||
echo "addSbtPlugin(\"net.virtual-void\" % \"sbt-dependency-graph\" % \"0.8.2\")" >> /home/node/.sbt/0.13/plugins/build.sbt && \ | ||
echo "net.virtualvoid.sbt.graph.DependencyGraphSettings.graphSettings" >> /home/node/.sbt/0.13/user.sbt && \ | ||
echo "-sbt-version 0.13.16" >> /etc/sbt/sbtopts | ||
|
||
# Install snyk cli | ||
RUN npm install --global snyk snyk-to-html && \ | ||
apt-get update && \ | ||
apt-get install -y jq | ||
|
||
RUN chmod -R a+wrx /home/node | ||
WORKDIR /home/node | ||
ENV HOME /home/node | ||
ENV M2 /home/node/.m2 | ||
|
||
# The path at which the project is mounted (-v runtime arg) | ||
ENV PROJECT_PATH /project | ||
|
||
ADD docker-entrypoint.sh . | ||
ADD snyk_report.css . | ||
|
||
ENTRYPOINT ["./docker-entrypoint.sh"] | ||
|
||
# Default command is `snyk test` | ||
# Override with `docker run ... snyk/snyk-cli <command> <args>` | ||
CMD ["test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
OUTPUT_FILE=snyk-result.json | ||
ERROR_FILE=snyk-error.log | ||
HTML_FILE=snyk_report.html | ||
SNYK_COMMAND="$1" | ||
SNYK_PARAMS="${@:2}" | ||
|
||
if [ -z $USER_ID ]; then | ||
USER_ID=`id -u` | ||
fi | ||
|
||
if [ $USER_ID -ne 0 ]; then | ||
useradd -m -o -u $USER_ID -d /home/node docker-user 2>/dev/null | ||
fi | ||
|
||
runCmdAsDockerUser () { | ||
if [ $USER_ID -ne 0 ]; then | ||
su docker-user -m -c "$1; status=$?" | ||
else | ||
bash -c "$1; status=$?" | ||
fi | ||
|
||
return $status | ||
} | ||
|
||
exitWithMsg () { | ||
echo "Failed to run the process ..." | ||
|
||
if [ -f $1 ]; then | ||
cat "$1" | ||
else | ||
echo "$1" | ||
fi | ||
|
||
exit $2 | ||
} | ||
|
||
if [ -z $SNYK_TOKEN ]; then | ||
exitWithMsg "Missing \$SNYK_TOKEN" 1 | ||
fi | ||
|
||
cd "$PROJECT_PATH/$TARGET_FILE_DIR" | ||
|
||
runCmdAsDockerUser "PATH=$PATH snyk $SNYK_COMMAND $SNYK_PARAMS --json > $OUTPUT_FILE 2>$ERROR_FILE" | ||
|
||
RC=$? | ||
|
||
if [ $RC -ne "0" ] && [ $RC -ne "1" ]; then | ||
exitWithMsg "$OUTPUT_FILE" $RC | ||
fi | ||
|
||
if [ ! -z $MONITOR ]; then | ||
runCmdAsDockerUser "PATH=$PATH snyk monitor $SNYK_PARAMS" | ||
fi | ||
|
||
if [ ! -z $GENERATE_REPORT ]; then | ||
runCmdAsDockerUser "cat $OUTPUT_FILE | jq '.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)' | snyk-to-html | sed 's/<\/head>/ <link rel=\"stylesheet\" href=\"snyk_report.css\"><\/head>/' > $HTML_FILE" | ||
runCmdAsDockerUser "cat /home/node/snyk_report.css > snyk_report.css" | ||
fi | ||
|
||
if [ $RC -ne "0" ]; then | ||
exitWithMsg "$OUTPUT_FILE" $RC | ||
fi | ||
|
||
cat $OUTPUT_FILE | ||
|
||
exit $RC |
Oops, something went wrong.