forked from KTH-LangSec/ghunter4deno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze.sh
executable file
·62 lines (52 loc) · 1.43 KB
/
analyze.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
#!/bin/bash
set -eo pipefail
start=$(date +%s)
### CLI
parallel_cnt="$1"
timeout="$2"
case "$3" in
"core")
tests_dir='./deno/cli/tests/unit/'
;;
"node")
tests_dir='./deno/cli/tests/unit_node/'
;;
"std")
tests_dir='./deno_std/'
;;
"basic-test")
tests_dir='./deno/cli/tests/unit/dir_test.ts'
;;
*)
echo 'usage: ./analyze.sh [# of workers] [test timeout in seconds] [target] [analysis index]'
echo 'possible targets: "core", "node", "std", "basic-test"'
echo 'analysis index only needed when running unexpected-termination analysis, in which case it must be the index of a "_analysis/analysis-x" folder'
exit 1
esac
### Analysis
rm -rf ./_analysis/tmp/ ./_analysis/intermediate/
mkdir -p ./_analysis/tmp/
## 1. Prepare
build="$(cat .build)"
if [[ "$build" == "crashes" ]]; then
index="$4"
cp -r "./_analysis/analysis-$index/intermediate" ./_analysis/intermediate
elif [[ "$build" == "s2s" ]]; then
## 1.1 Initial run
node ./runner.mjs "$parallel_cnt" "$timeout" "$tests_dir"
mv _analysis/tmp _analysis/intermediate
mkdir _analysis/tmp/
else
echo 'Build tag missing (did you run ./make.sh first?)'
exit 2
fi
## 2. Taint run
node ./runner.mjs "$parallel_cnt" "$timeout" "$tests_dir"
## 3. Analyze
node to-sarif.mjs
### Meta
end=$(date +%s)
execution_time=$((end - start))
minutes=$((execution_time / 60))
seconds=$((execution_time % 60))
echo "Total execution time: $minutes mins $seconds secs ($parallel_cnt workers)"