-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgen_vgraph_db.sh
More file actions
executable file
·31 lines (28 loc) · 1.55 KB
/
gen_vgraph_db.sh
File metadata and controls
executable file
·31 lines (28 loc) · 1.55 KB
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
# This function will find a CPG of patch and vuln function and generate the core graphs and nodes
MAX_NUM_PROCS=4
LOG_FILE='gen_vgraph_db.log'
VULN_PATCH_DB='data/vuln_patch_graph_db'
VGRAPH_DB='data/vgraph_db'
echo "Logging to $LOG_FILE..."
for repo in `ls $VULN_PATCH_DB`; do
for cve in `ls $VULN_PATCH_DB/$repo`; do
for hsh in `ls $VULN_PATCH_DB/$repo/$cve/vuln/`; do
for src_file in `ls $VULN_PATCH_DB/$repo/$cve/vuln/$hsh`; do
for g in `ls $VULN_PATCH_DB/$repo/$cve/vuln/$hsh/$src_file/graph | grep 'gpickle'`; do
func=`echo $g | sed 's/.gpickle//'`
if [ ! -f $VULN_PATCH_DB/$repo/$cve/vuln/$hsh/$src_file/graph/${func}.gpickle ]; then
echo "Missing vulnerable graph for ${repo} ${cve} ${func}...Skipping" >> $LOG_FILE
elif [ ! -f $VULN_PATCH_DB/$repo/$cve/patch/$hsh/$src_file/graph/${func}.gpickle ]; then
echo "Missing patched graph for ${repo} ${cve} ${func}...Skipping" >> $LOG_FILE
else
# Should have everything we need
python gen_vgraph.py $VULN_PATCH_DB/$repo/$cve/vuln/$hsh/$src_file/graph/${func}.gpickle $VULN_PATCH_DB/$repo/$cve/patch/$hsh/$src_file/graph/${func}.gpickle $VGRAPH_DB/$repo/$cve/$hsh/$src_file $func >> $LOG_FILE &
fi
while [ "`jobs | wc -l`" -gt "$MAX_NUM_PROCS" ]; do
sleep 0.5
done
done
done
done
done
done