Skip to content

Commit acbaf9c

Browse files
committed
Update testssl_csv_parser.py
1 parent 9eff520 commit acbaf9c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Parser/testssl_csv_parser.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
#Input - testssl out csv file
33
#Output - Dictonary contains ssl vulnerability details
44
import csv
5+
import os
56

67
#Function call to parser the CSV File
78
def parse_testssl_csv_file(input_file):
89
result_dict={}
910
search_list=['heartbleed','ccs','ticketbleed','robot','crime_tls','breach','poodle_ssl','freak','beast','lucky13','sweet32','logjam','drown','secure_renego','secure_client_renego','fallback_scsv']
1011
for item in search_list:
11-
result_dict[item]="N/A" #Pre Populate the dictonary with all the vulnerabilities set to N/A
12-
heartbleed=ccs=ticketbleed=robot=crime=breach=poodle=freak=beast=lucky13=sweet32=logjam=drown=sr_server=sr_client=fallback_scsv="N/A"
13-
with open(input_file, 'r') as file:
14-
reader = csv.reader(file)
15-
for csv_row in reader:
16-
for item in search_list:
17-
if item == csv_row[0].lower(): #csv_row[0] contains the vulnerability name
18-
result_dict[item]=csv_row[3] #csv_row[3] contains the result vulnerable or not
12+
result_dict[item]="N/A" #Populate the dictonary with all the vulnerabilities set to N/A
13+
try:
14+
if os.path.isfile(input_file): #Check if the file exist
15+
with open(input_file, 'r') as file:
16+
reader = csv.reader(file)
17+
for csv_row in reader:
18+
for item in search_list:
19+
if item == csv_row[0].lower(): #csv_row[0] contains the vulnerability name
20+
result_dict[item]=csv_row[3] #csv_row[3] contains the result vulnerable or not
21+
except Exception as e:
22+
#print(e)
23+
result_dict = dict.fromkeys( result_dict, "ERROR" ) #if any error occurs set all the value to ERROR
1924
return result_dict #Result dict
2025

2126
#Call to function by passing the testssl out file

0 commit comments

Comments
 (0)