Feat: Add Maven Snyk CLI Scanner
[releng/global-jjb.git] / shell / snyk-cli-scanner-run.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2023 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> snyk-cli-scanner-run.sh"
12
13 # Add mvn to PATH so that the Snyk CLI can use it
14 export PATH=$PATH:"$M2_HOME"/bin
15 # Download and install the latest Snyk scanner
16 echo "Installing Snyk (latest)..."
17 curl https://static.snyk.io/cli/latest/snyk-linux -o snyk
18 sudo chmod +x ./snyk
19 sudo mv ./snyk /usr/local/bin/
20 echo "Verifying Snyk version..."
21 snyk --version
22 echo "Authenticate with SNYK_TOKEN..."
23 snyk auth "$SNYK_CLI"
24 echo "Running Snyk CLI..."
25 snyk test --json --severity-threshold=low --org="$SNYK_ORG"
26 snyk monitor --severity-threshold=low --org="$SNYK_ORG"