-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·55 lines (46 loc) · 1.53 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function isinstalled {
if command -v "$1";
then
true
else
false
fi
}
# doing this to make this work locally since 99% of the times most dev machines already have curl and might not have apt-get
if isinstalled "curl"
then
echo "curl already installed moving on"
else
apt-get update && apt install -y curl
fi
if [ -z ${NANCY_VERSION+x} ];
then echo "NANCY_VERSION is unset, setting it for you now";
NANCY_VERSION=v0.1.15
else
echo "NANCY_VERSION is set to '$NANCY_VERSION'"
fi
mkdir -p /tmp/tools
if [[ "$OSTYPE" == "darwin"* ]]; then
curl -s -L "https://github.com/sonatype-nexus-community/nancy/releases/download/$NANCY_VERSION/nancy-darwin.amd64-$NANCY_VERSION" -o "/tmp/tools/nancy"
else
curl -s -L "https://github.com/sonatype-nexus-community/nancy/releases/download/$NANCY_VERSION/nancy-linux.amd64-$NANCY_VERSION" -o "/tmp/tools/nancy"
fi
chmod +x /tmp/tools/nancy
set -e
DEP_EXIT_CODE=0
SUM_EXIT_CODE=0
LIST_EXIT_CODE=0
/tmp/tools/nancy Gopkg.lock || DEP_EXIT_CODE=$?
/tmp/tools/nancy go.sum || SUM_EXIT_CODE=$?
GO111MODULE=on go list -m all | /tmp/tools/nancy || LIST_EXIT_CODE=$?
echo "go list exit code : $LIST_EXIT_CODE"
echo "go sum exit code : $SUM_EXIT_CODE"
echo "dep exit code : $DEP_EXIT_CODE"
if [[ "$LIST_EXIT_CODE" -eq 0 || "$SUM_EXIT_CODE" -eq 0 || "$DEP_EXIT_CODE" -eq 0 ]]
then
echo "One of the above nancy tests actually passed....that means the project is no longer vulnerable and thats an issue"
exit 1
else
echo "YAH!!! :) Still vulnerable....usually not something you are happy about"
exit 0
fi