-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbugaudit-runner
56 lines (51 loc) · 2.11 KB
/
bugaudit-runner
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
#!/usr/bin/env bash
export BUGAUDIT_SSH_PRIVATE_KEY="/bugaudit-ssh-key/ssh-priv-key"
if [ -f "$BUGAUDIT_SSH_PRIVATE_KEY" ]; then
cp $BUGAUDIT_SSH_PRIVATE_KEY /root/.ssh/id_rsa
chmod 400 /root/.ssh/id_rsa
if [ ! -z "$BUGAUDIT_SSH_KEY_PASSPHRASE" ]; then
ssh-keygen -p -P $BUGAUDIT_SSH_KEY_PASSPHRASE -N "" -f /root/.ssh/id_rsa
fi
else
echo "SSH Private Key not found. Proceeding without a key file [May impact builds that require key]"
fi
if [ ! -z "$BUGAUDIT_CONFIG" ]; then
echo "BugAudit Config: $BUGAUDIT_CONFIG"
if [[ $BUGAUDIT_CONFIG != http* ]]; then
export BUGAUDIT_CONFIG_FILE_MOUNT_PATH="/bugaudit-config-dir/bugaudit-config.json"
if [ -f "$BUGAUDIT_CONFIG_FILE_MOUNT_PATH" ]; then
export BUGAUDIT_CONFIG="/bugaudit-workspace/bugaudit-config.json"
cp $BUGAUDIT_CONFIG_FILE_MOUNT_PATH $BUGAUDIT_CONFIG
else
echo "The config file you referred using BUGAUDIT_CONFIG seems unreadable."
echo "Please make sure the file exists or specify the absolute path"
exit 1
fi
fi
fi
if [ ! -z "$BUGAUDIT_GIT_REPO" ]; then
if [[ $BUGAUDIT_GIT_REPO == http* ]]; then
echo "Please provide a valid SSH based clone URI through BUGAUDIT_GIT_REPO"
else
if [ ! -z "$BUGAUDIT_GIT_BRANCH" ]; then
git clone --depth 1 -b $BUGAUDIT_GIT_BRANCH $BUGAUDIT_GIT_REPO .
else
git clone --depth 1 $BUGAUDIT_GIT_REPO .
fi
fi
else
echo "BUGAUDIT_GIT_REPO was not provided, looking into host-local directory"
export BUGAUDIT_HOST_GIT_DIR="/bugaudit-host-dir/.git"
if [ -d "$BUGAUDIT_HOST_GIT_DIR" ]; then
echo "Making a copy of local repo from host directory"
cp -a /bugaudit-host-dir/. /bugaudit-workspace/
fi
fi
export BUGAUDIT_SCAN_SOURCE_GIT_DIR="/bugaudit-workspace/.git"
if [ -d "$BUGAUDIT_SCAN_SOURCE_GIT_DIR" ]; then
bugaudit
else
echo "No git repository was found. Run this inside a local git repository."
echo "Alternatively you can also provide remote SSH Git repo URL through BUGAUDIT_GIT_REPO environment variable"
exit 1
fi