-
Notifications
You must be signed in to change notification settings - Fork 1
/
ScaResolver
executable file
·54 lines (45 loc) · 1.4 KB
/
ScaResolver
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
#!/bin/bash
set -e
echo -e "\r\nExecuting SCAResolver in container: ${CONTAINER_TAG}"
echo -e "\r\n"
i=0
reformed_args=()
while [ ! -z ${1} ]; do
case $1 in
"-s")
reformed_args[$i]=$1
((++i))
shift
SCAN_PATH=$(dirname $1)
reformed_args[$i]="/sandbox/input_sandbox"
((++i))
shift
continue
;;
"-r")
reformed_args[$i]=$1
((++i))
shift
RESULT_PATH=$(dirname $1)
reformed_args[$i]="/sandbox/output/$(basename $1)"
((++i))
shift
continue
;;
esac
reformed_args[$i]=$1
((++i))
shift
done
echo -e "\r\nSCAResolver reformed args: ${reformed_args[@]}"
echo -e "\r\n"
mkdir -p $RESULT_PATH
echo -e "\r\nExecuting as $(whoami)"
echo -e "\r\n"
echo -e "\r\nHost output directory: $(stat -c "User:%U(%u) Group:%G(%g) %A" $RESULT_PATH)"
echo -e "\r\n"
echo -e "\r\nContainer output directory: $(docker run -t -v $RESULT_PATH:/sandbox/output --entrypoint=stat $CONTAINER_TAG -c "User:%U(%u) Group:%G(%g) %A" /sandbox/output)"
echo -e "\r\n"
echo -e "\r\nIf host and container UID/GID are mismatched, the SCAResolver container needs to be built using the Host UID/GID"
echo -e "\r\n"
docker run -t -v $SCAN_PATH:/sandbox/input -v $RESULT_PATH:/sandbox/output $CONTAINER_TAG ${reformed_args[@]}