Skip to content

Commit ead942b

Browse files
committed
update dataset, tools, and Readme.md.
1 parent 89e2c85 commit ead942b

File tree

1,630 files changed

+1398
-75052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,630 files changed

+1398
-75052
lines changed

Performance_evaluation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from os.path import join as pjoin
33
from sklearn.metrics import confusion_matrix
44

5-
data_dir = "./logs/timestamp_results/"
5+
data_dir = "./comparison/reentrancy/"
66

77

88
# Performance evaluation, tools : SmartCheck, Securify, Mythril, Oyente
@@ -13,11 +13,11 @@ def read_label(fpath, line_parse_fn=None):
1313
return data
1414

1515

16-
ground_truth = read_label("ground_truth_185.txt", line_parse_fn=lambda s: int(float(s.strip())))
17-
securify_label = read_label("securify_label_185.txt", line_parse_fn=lambda s: int(float(s.strip())))
18-
smartcheck_label = read_label("smartcheck_label_185.txt", line_parse_fn=lambda s: int(float(s.strip())))
19-
myth_label = read_label("myth_label_185.txt", line_parse_fn=lambda s: int(float(s.strip())))
20-
oyente_label = read_label("oyente_label_185.txt", line_parse_fn=lambda s: int(float(s.strip())))
16+
ground_truth = read_label("ground_truth.txt", line_parse_fn=lambda s: int(float(s.strip())))
17+
securify_label = read_label("securify_label.txt", line_parse_fn=lambda s: int(float(s.strip())))
18+
smartcheck_label = read_label("smartcheck_label.txt", line_parse_fn=lambda s: int(float(s.strip())))
19+
myth_label = read_label("myth_label.txt", line_parse_fn=lambda s: int(float(s.strip())))
20+
oyente_label = read_label("oyente_label.txt", line_parse_fn=lambda s: int(float(s.strip())))
2121

2222
# tn, fp, fn, tp = confusion_matrix(ground_truth, securify_label).ravel()
2323
tn, fp, fn, tp = confusion_matrix(ground_truth, smartcheck_label).ravel()

SmConVulDetector.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
torch.cuda.manual_seed_all(args.seed)
3333
rnd_state = np.random.RandomState(args.seed)
3434

35-
print('Loading data...')
35+
print('Loading training_data...')
3636

3737

3838
class DataReader():
3939
"""
40-
Class to read the txt files containing all data of the dataset
40+
Class to read the txt files containing all training_data of the dataset
4141
"""
4242

4343
def __init__(self, data_dir, rnd_state=None, use_cont_node_attr=False, folds=n_folds):
@@ -111,8 +111,8 @@ def __init__(self, data_dir, rnd_state=None, use_cont_node_attr=False, folds=n_f
111111
for u in np.unique(features_all):
112112
print('feature {}, count {}/{}'.format(u, np.count_nonzero(features_all == u), len(features_all)))
113113

114-
N_graphs = len(labels) # number of samples (graphs) in data
115-
assert N_graphs == len(data['adj_list']) == len(features_onehot), 'invalid data'
114+
N_graphs = len(labels) # number of samples (graphs) in training_data
115+
assert N_graphs == len(data['adj_list']) == len(features_onehot), 'invalid training_data'
116116

117117
# Create test sets first
118118
train_ids, test_ids = split_ids(rnd_state.permutation(N_graphs), folds=folds)
@@ -143,7 +143,7 @@ def read_graph_adj(self, fpath, nodes, graphs):
143143
node1 = int(edge[0].strip()) - 1 # -1 because of zero-indexing in our code
144144
node2 = int(edge[1].strip()) - 1
145145
graph_id = nodes[node1]
146-
assert graph_id == nodes[node2], ('invalid data', graph_id, nodes[node2])
146+
assert graph_id == nodes[node2], ('invalid training_data', graph_id, nodes[node2])
147147
if graph_id not in adj_dict:
148148
n = len(graphs[graph_id])
149149
adj_dict[graph_id] = np.zeros((n, n))
@@ -183,7 +183,7 @@ def read_node_features(self, fpath, nodes, graphs, fn):
183183
return node_features_lst
184184

185185

186-
datareader = DataReader(data_dir='./data/%s/' % args.dataset, rnd_state=rnd_state,
186+
datareader = DataReader(data_dir='./training_data/%s/' % args.dataset, rnd_state=rnd_state,
187187
use_cont_node_attr=args.use_cont_node_attr, folds=args.folds)
188188

189189
# train and test
@@ -239,7 +239,7 @@ def train(train_loader):
239239
for i in range(len(data)):
240240
data[i] = data[i].to(args.device)
241241
optimizer.zero_grad()
242-
# output = model(data[0], data[1]) # when model is gcn_origin or gat, use this
242+
# output = model(training_data[0], training_data[1]) # when model is gcn_origin or gat, use this
243243
output = model(data) # when model is gcn_modify, use this
244244
loss = loss_fn(output, data[4])
245245
loss.backward()
@@ -266,7 +266,7 @@ def test(test_loader):
266266
for batch_idx, data in enumerate(test_loader):
267267
for i in range(len(data)):
268268
data[i] = data[i].to(args.device)
269-
# output = model(data[0], data[1]) # when model is gcn_origin or gat, use this
269+
# output = model(training_data[0], training_data[1]) # when model is gcn_origin or gat, use this
270270
output = model(data) # when model is gcn_modify, use this
271271
loss = loss_fn(output, data[4], reduction='sum')
272272
test_loss += loss.item()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FALLBACK FUN0 0 NULL
2+
FUN0 FALLBACK 0 NULL
3+
FUN1 FUN1 0 NULL
4+
FUN2 FUN2 0 NULL
5+
FUN3 FUN3 0 NULL
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FALLBACK FUN0 0 NULL
2+
FUN0 FALLBACK 0 NULL
3+
FUN1 FUN1 0 NULL
4+
FUN3 FUN3 0 NULL
5+
FUN2 VAR0 1 FOR
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FALLBACK FUN0 0 NULL
2+
FUN0 FALLBACK 0 NULL
3+
FUN1 FUN1 0 NULL
4+
FUN2 FUN2 0 NULL
5+
FUN3 FUN3 0 NULL

0 commit comments

Comments
 (0)