Ich habe ein Skript, das eine CSV liest Datei csv fileanhängt Werte Python Wörterbuch
Asset IP Address,Vulnerability Title
50.103.128.11,Partition Mounting Weakness
10.103.128.11,UDP IP ID Zero
10.103.128.11,Root's umask value is unsafe
0.103.128.11,Root's umask value is unsafe
20.103.128.11,Root's umask value is unsafe
10.103.128.11,ICMP timestamp response
22.103.128.11,ICMP timestamp response
10.103.128.11,UDP IP ID Zero
10.103.129.11,Partition Mounting Weakness
und nach meinem Skript ausgeführt
import csv
from pprint import pprint
#with open('test.csv', 'rb') as f:
# reader = csv.DictReader(f, delimiter=',')
# for row in reader:
# print row
#dict = {a:[], b:[]}
dict = {}
with open('test.csv', 'rb') as f:
reader = csv.DictReader(f, delimiter=',')
for row in reader:
a = row["Vulnerability Title"]
b = [row["Asset IP Address"]]
#b = row(["Asset IP Address"])
#dict = {a:[], b:[]}
if a in dict:
#print row["Vulnerability Title"]
#if row["Vulnerability Title"] in dict:
dict[a].append(b)
else:
dict[a] = b
pprint(dict)
liest die Verwundbarkeit Listen und ein Wörterbuch mit ips erstellen, haben Diese Schwachstelle. Wie auch immer, meine Ergebnisse sind eine Liste mit einer zusätzlichen Klammer. wollte erreichen, dass jemand bessere Ideen hat oder mir helfen kann. results
{'ICMP timestamp response': ['10.103.128.11', ['22.103.128.11']],
'Partition Mounting Weakness': ['50.103.128.11', ['10.103.129.11']],
"Root's umask value is unsafe": ['10.103.128.11',
['0.103.128.11'],
['20.103.128.11']],
'UDP IP ID Zero': ['10.103.128.11', ['10.103.128.11']]}
Sie brauchen nicht die outter '[]' in 'b = [row [“ Asset IP Address "]]' – innoSPG