-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdra.sh
executable file
·78 lines (49 loc) · 1.98 KB
/
dra.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
72
73
74
75
76
77
78
#!/bin/bash
function dra_commands {
echo -e "${no_color}"
node_modules_dir=`npm root`
dra_grunt_command="grunt --gruntfile=$node_modules_dir/grunt-idra3/idra.js"
dra_grunt_command="$dra_grunt_command -testResult=\"$1\""
dra_grunt_command="$dra_grunt_command -stage=\"$3\""
dra_grunt_command="$dra_grunt_command -drilldownUrl=\"$4\""
debugme echo -e "dra_grunt_command with log & stage: \n\t$dra_grunt_command"
if [ -n "$2" ] && [ "$2" != " " ]; then
debugme echo -e "\tartifact: '$2' is defined and not empty"
dra_grunt_command="$dra_grunt_command -artifact=\"$2\""
debugme echo -e "\tdra_grunt_command: \n\t\t$dra_grunt_command"
else
debugme echo -e "\tartifact: '$2' is not defined or is empty"
debugme echo -e "${no_color}"
fi
debugme echo -e "FINAL dra_grunt_command: $dra_grunt_command"
debugme echo -e "${no_color}"
eval "$dra_grunt_command -f --no-color"
GRUNT_RESULT=$?
debugme echo "GRUNT_RESULT: $GRUNT_RESULT"
if [ $GRUNT_RESULT -ne 0 ]; then
exit 1
fi
echo -e "${no_color}"
}
installDRADependencies
echo ""
for zipFile in appscan-*.zip;
do
# unzip the appscan results
resultDirectory="appscanResultDir"
unzip $zipFile -d $resultDirectory
# full report location
export DRA_LOG_FILE="$EXT_DIR/$resultDirectory/Report-final.xml"
# summary report location. Replace appscan-app.zip with appscan-app.json.
export DRA_SUMMARY_FILE="$EXT_DIR/${zipFile%.zip}.json"
# pass appscan report url to DRA
json=`cat ${DRA_SUMMARY_FILE}`
appscan_url=`python -c "import json; obj = json.loads('$json'); print( obj['url'] );"`
# Upload to DRA
# upload the full appscan report
dra_commands "${DRA_LOG_FILE}" "${zipFile}" "staticsecurityscan" "${appscan_url}"
# upload the summary appscan report
#dra_commands "${DRA_SUMMARY_FILE}" "${DRA_SUMMARY_FILE}" "staticsecurityscan"
# Clean up directory
rm -r $resultDirectory
done