File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 2121# VulnTotal is a free software tool from nexB Inc. and others.
2222# Visit https://github.com/nexB/vulnerablecode/ for support and download.
2323
24+ import glob
25+ import importlib
26+ import inspect
27+ from os .path import basename
28+ from os .path import dirname
29+ from os .path import isfile
30+ from os .path import join
2431
25- DATASOURCE_REGISTRY = []
32+ from vulntotal . validator import DataSource
2633
27- DATASOURCE_REGISTRY = {x .__module__ .split ("." )[- 1 ]: x for x in DATASOURCE_REGISTRY }
34+ DATASOURCE_REGISTRY = {}
35+ files = glob .glob (join (dirname (__file__ ), "*.py" ))
36+ modules = [
37+ f"vulntotal.datasources.{ basename (f )[:- 3 ]} "
38+ for f in files
39+ if isfile (f ) and not f .endswith ("__init__.py" )
40+ ]
41+
42+
43+ for module in modules :
44+ for name , cls in inspect .getmembers (importlib .import_module (module ), inspect .isclass ):
45+ if cls .__module__ == module and cls .__base__ == DataSource :
46+ DATASOURCE_REGISTRY [cls .__module__ .split ("." )[- 1 ]] = cls
47+ break
You can’t perform that action at this time.
0 commit comments