-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·71 lines (65 loc) · 2.47 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
echo 'Started ... reading parameters'
# Define default values for input parameters
SBOM_FILE="${INPUT_SBOM_FILE:-sbom.json}"
DATA_PROVIDER="${INPUT_DATA_PROVIDER:-ovs}"
OUTPUT_FORMAT="${INPUT_OUTPUT_FORMAT:-stdout}"
OUTPUT_FILE="${INPUT_OUTPUT_FILE:-}"
IGNORE_FILE="${INPUT_IGNORE_FILE:-}"
# Check if SBOM file exists
if [ ! -f "$SBOM_FILE" ]; then
echo "SBOM file '$SBOM_FILE' not found. Please make sure the file exists."
exit 1
fi
# Construct the base command
command="bomber"
echo "Checking command parameters"
# Add the ignore file option if provided
if [ -n "$IGNORE_FILE" ]; then
command="$command --ignore-file=$IGNORE_FILE"
echo 'using ignore file $IGNORE_FILE'
else
echo '--ignore-file not set, proceeding'
fi
# Add the scan command and SBOM file
command="$command scan $SBOM_FILE"
echo "SBOM file to scan: $SBOM_FILE"
# Add the data provider option if provided
if [ "$DATA_PROVIDER" != "ovs" ]; then
case "$DATA_PROVIDER" in
snyk)
# Check if SNYK token is provided
if [ -z "${{ secrets.SNYK_TOKEN }}" ]; then
echo "SNYK token is missing. Please provide the token as a secret."
exit 1
fi
command="$command --provider $DATA_PROVIDER --token=${{ secrets.SNYK_TOKEN }}"
echo "You selected $DATA_PROVIDER as the vulnerability data provider"
;;
ossindex)
# Check if OSSIndex credentials are provided
if [ -z "${{ secrets.OSSINDEX_USERNAME }}" ] || [ -z "${{ secrets.OSSINDEX_TOKEN }}" ]; then
echo "OSS Index credentials are missing. Please provide the username and token as secrets."
exit 1
fi
command="$command --provider $DATA_PROVIDER --username=${{ secrets.OSSINDEX_USERNAME }} --token=${{ secrets.OSSINDEX_TOKEN }}"
echo "You selected $DATA_PROVIDER as the vulnerability data provider"
;;
*)
echo "Invalid data provider: $DATA_PROVIDER. Supported options are 'snyk' and 'ossindex'."
exit 1
;;
esac
else
echo "Using OVS as the data provider"
fi
# Add the output format option
command="$command --output=$OUTPUT_FORMAT"
echo "Preparing output as $OUTPUT_FORMAT"
# Add the output file option if provided
if [ -n "$OUTPUT_FILE" ] && [ "$OUTPUT_FORMAT" != "stdout" ]; then
command="$command > $OUTPUT_FILE"
echo "Output will be saved to $OUTPUT_FILE"
fi
# Execute the constructed command
sh -c "$command"