-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBandit_result.py
41 lines (36 loc) · 1.08 KB
/
Bandit_result.py
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
import json
from collections import defaultdict
import csv
smellList = []
smellDict = defaultdict()
smellDictCWE = defaultdict()
smellPath = defaultdict()
error = 0
analyzed = 0
with open('dataset.json') as f:
data = json.load(f)
for item in data['results']:
smellList.append(item)
try:
smellDict[item["test_id"]+'_'+item["test_name"]] += 1
# smellDictCWE[item["issue_cwe"]["id"]] += 1
#smellPath[item['filename']] += 1
except KeyError:
#print("KeyError:", item["test_id"],item["test_name"])
smellDict[item["test_id"]+'_'+item["test_name"]] = 1
# smellDictCWE[item["issue_cwe"]["id"]] = 1
#smellPath[item['filename']] = 1
data = []
for key in smellDict:
print(key)
row = []
row.append(key)
row.append(smellDict[key])
data.append(row)
header = ['Message', 'Count']
with open('dataset_bandit.csv', 'w', newline='', encoding='UTF8') as f:
writer = csv.writer(f)
# write the header
writer.writerow(header)
# write the data
writer.writerows(data)