Skip to content

Commit

Permalink
Ingest Rust data through Github api (#1427)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
shravankshenoy and TG1999 authored Jul 22, 2024
1 parent 7e2a70a commit d7b66fb
Show file tree
Hide file tree
Showing 4 changed files with 9,703 additions and 3 deletions.
5 changes: 3 additions & 2 deletions vulnerabilities/importers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"PIP": "pypi",
"RUBYGEMS": "gem",
"NPM": "npm",
"RUST": "cargo",
# "GO": "golang",
}

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

if pkg_type in ("nuget", "pypi", "gem", "golang", "npm"):
if pkg_type in ("nuget", "pypi", "gem", "golang", "npm", "cargo"):
return PackageURL(type=pkg_type, name=github_name)

logger.error(f"get_purl: Unknown package type {pkg_type}")
Expand Down
Loading

0 comments on commit d7b66fb

Please sign in to comment.