Skip to content

Commit 1cb8ead

Browse files
committed
Use explicit list of datasources
This is better, safer and simpler than a discovered list Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 7af1b5d commit 1cb8ead

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

vulntotal/datasources/__init__.py

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
#
22
# Copyright (c) nexB Inc. and others. All rights reserved.
3-
# http://nexb.com and https://github.com/nexB/vulnerablecode/
4-
# The VulnTotal software is licensed under the Apache License version 2.0.
5-
# Data generated with VulnTotal require an acknowledgment.
3+
# VulnerableCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/vulnerablecode for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
68
#
7-
# You may not use this software except in compliance with the License.
8-
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
9-
# Unless required by applicable law or agreed to in writing, software distributed
10-
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11-
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
12-
# specific language governing permissions and limitations under the License.
13-
#
14-
# When you publish or redistribute any data created with VulnTotal or any VulnTotal
15-
# derivative work, you must accompany this data with the following acknowledgment:
16-
#
17-
# Generated with VulnTotal and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
18-
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
19-
# VulnTotal should be considered or used as legal advice. Consult an Attorney
20-
# for any legal advice.
21-
# VulnTotal is a free software tool from nexB Inc. and others.
22-
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
239

2410
import glob
2511
import importlib
@@ -29,19 +15,21 @@
2915
from os.path import isfile
3016
from os.path import join
3117

18+
from vulntotal.datasources import deps
19+
from vulntotal.datasources import github
20+
from vulntotal.datasources import gitlab
21+
from vulntotal.datasources import oss_index
22+
from vulntotal.datasources import osv
23+
from vulntotal.datasources import snyk
24+
from vulntotal.datasources import vulnerablecode
3225
from vulntotal.validator import DataSource
3326

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
27+
DATASOURCE_REGISTRY = {
28+
"deps": deps.DepsDataSource,
29+
"github": github.GithubDataSource,
30+
"gitlab": gitlab.GitlabDataSource,
31+
"oss_index": oss_index.OSSDataSource,
32+
"osv": osv.OSVDataSource,
33+
"snyk": snyk.SnykDataSource,
34+
"vulnerablecode": vulnerablecode.VulnerableCodeDataSource,
35+
}

0 commit comments

Comments
 (0)