Skip to content

Commit d7b66fb

Browse files
Ingest Rust data through Github api (#1427)
* Modify github importer to ingest rust data Signed-off-by: Shenoy <[email protected]> * Add test data Signed-off-by: Shenoy <[email protected]> --------- Signed-off-by: Shenoy <[email protected]> Co-authored-by: Tushar Goel <[email protected]>
1 parent 7e2a70a commit d7b66fb

File tree

4 files changed

+9703
-3
lines changed

4 files changed

+9703
-3
lines changed

vulnerabilities/importers/github.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"PIP": "pypi",
3838
"RUBYGEMS": "gem",
3939
"NPM": "npm",
40+
"RUST": "cargo",
4041
# "GO": "golang",
4142
}
4243

@@ -47,7 +48,7 @@
4748
# TODO: We will try to gather more info from GH API
4849
# Check https://github.com/nexB/vulnerablecode/issues/1039#issuecomment-1366458885
4950
# Check https://github.com/nexB/vulnerablecode/issues/645
50-
# set of all possible values of first '%s' = {'MAVEN','COMPOSER', 'NUGET', 'RUBYGEMS', 'PYPI', 'NPM'}
51+
# set of all possible values of first '%s' = {'MAVEN','COMPOSER', 'NUGET', 'RUBYGEMS', 'PYPI', 'NPM', 'RUST'}
5152
# second '%s' is interesting, it will have the value '' for the first request,
5253
GRAPHQL_QUERY_TEMPLATE = """
5354
query{
@@ -139,7 +140,7 @@ def get_purl(pkg_type: str, github_name: str) -> Optional[PackageURL]:
139140
vendor, _, name = github_name.partition("/")
140141
return PackageURL(type=pkg_type, namespace=vendor, name=name)
141142

142-
if pkg_type in ("nuget", "pypi", "gem", "golang", "npm"):
143+
if pkg_type in ("nuget", "pypi", "gem", "golang", "npm", "cargo"):
143144
return PackageURL(type=pkg_type, name=github_name)
144145

145146
logger.error(f"get_purl: Unknown package type {pkg_type}")

0 commit comments

Comments
 (0)