Browse code

performance improvement by keeping list of all scanned for files

Hanno Böck authored on08/12/2019 18:43:47
Showing1 changed files
... ...
@@ -82,6 +82,7 @@ except configparser.MissingSectionHeaderError as err:
82 82
     print("Error parsing config files: %s" % err)
83 83
 
84 84
 vdb = []
85
+scanfiles = set()
85 86
 for sect in config.sections():
86 87
     item = {}
87 88
 
... ...
@@ -95,6 +96,7 @@ for sect in config.sections():
95 96
     item['file'] = config.get(sect, 'file')
96 97
     item['vuln'] = config.get(sect, 'vuln')
97 98
     item['subdir'] = int(config.get(sect, 'subdir'))
99
+    scanfiles.add(item['file'])
98 100
 
99 101
     # match magic
100 102
     item['variable'] = re.compile(re.escape(config.get(sect, 'variable'))
... ...
@@ -132,7 +134,7 @@ if opts.xml:
132 134
 
133 135
 for fdir in opts.dirs:
134 136
     for root, NULL, files in os.walk(fdir):
135
-        for filename in files:
137
+        for filename in scanfiles.intersection(files):
136 138
             for item in vdb:
137 139
                 if filename == item['file']:
138 140
                     mfile = os.path.join(root, filename)