forked from kubescape/github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·34 lines (26 loc) · 979 Bytes
/
entrypoint.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
#!/bin/sh
set -e
if [ ! -z "$INPUT_FRAMEWORK" ] && [ ! -z "$INPUT_CONTROL" ]; then
echo "Framework and Control is specified. Please specify either one of them or neither"
exit 1
fi
# Split the controls by comma and concatenate with quotes around each control
if [ ! -z "$INPUT_CONTROL" ]; then
CONTROLS=""
set -f; IFS=','
set -- $INPUT_CONTROL
set +f; unset IFS
for control in "$@"
do
control=$(echo $control | xargs) # Remove leading/trailing whitespaces
CONTROLS="$CONTROLS\"$control\","
done
CONTROLS=$(echo "${CONTROLS%?}")
fi
FRAMEWORK_CMD=$([ ! -z "$INPUT_FRAMEWORK" ] && echo "framework $INPUT_FRAMEWORK" || echo "")
CONTROL_CMD=$([ ! -z "$INPUT_CONTROL" ] && echo control $CONTROLS || echo "")
COMMAND="kubescape scan $FRAMEWORK_CMD $CONTROL_CMD $INPUT_FILES --fail-threshold $INPUT_THRESHOLD $INPUT_ARGS"
if [ ! -z "$INPUT_EXCEPTIONS" ]; then
COMMAND="${COMMAND} --exceptions ${INPUT_EXCEPTIONS}"
fi
eval $COMMAND