-
Notifications
You must be signed in to change notification settings - Fork 29
/
run_infersharp.sh
61 lines (51 loc) · 1.59 KB
/
run_infersharp.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
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
set -e
# Check if we have enough arguments.
if [ "$#" -lt 1 ]; then
echo "run_infersharp.sh <dll_folder_path> <options - see https://fbinfer.com/docs/man-infer-run#OPTIONS>"
exit
fi
infer_args=""
if [ "$#" -gt 1 ]; then
i=2
while [ $i -le $# ]
do
if [ ${!i} == "--output-folder" ]; then
((i++))
output_folder=${!i}
else
infer_args+="${!i} "
fi
((i++))
done
fi
echo "Processing {$1}"
# Preparation
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"
if [ -d infer-staging ]; then rm -Rf infer-staging; fi
mkdir infer-staging
echo -e "Copying binaries to a staging folder...\n"
shopt -s globstar
# Find all .dlls with matching .pdbs within the same folder and copy them in pairs
for f in "$1"/**; do
if [ "${f##*.}" == "dll" ]; then
if [ -f "${f%.*}.pdb" ]; then
cp -n "$f" "${f%.*}.pdb" infer-staging
fi
fi
done
# Run InferSharp analysis.
echo -e "Code translation started..."
./Cilsil/Cilsil translate infer-staging --outcfg infer-staging/cfg.json --outtenv infer-staging/tenv.json --cfgtxt infer-staging/cfg.txt --extprogress
echo -e "Code translation completed. Analyzing...\n"
infer run $infer_args --cfg-json infer-staging/cfg.json --tenv-json infer-staging/tenv.json
if [ "$output_folder" != "" ]; then
if [ ! -d "$output_folder" ]; then
mkdir "$output_folder"
fi
cp infer-out/report.sarif infer-out/report.txt $output_folder/
echo -e "\nFull reports available at '$output_folder'\n"
fi