Skip to content

Commit

Permalink
Retain empty group for npm to perform strict search (#80)
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu authored Dec 22, 2023
1 parent c43479c commit d9d6e35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "appthreat-vulnerability-db"
version = "5.5.6"
version = "5.5.7"
description = "AppThreat's vulnerability database and package search library with a built-in file based storage. OSV, CVE, GitHub, npm are the primary sources of vulnerabilities."
authors = [
{name = "Team AppThreat", email = "cloud@appthreat.com"},
Expand Down
14 changes: 11 additions & 3 deletions vdb/lib/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,19 @@ def bulk_index_search(pkg_list):
version = None
# This key could be either a vendor|name or name
vendor_idx_key = None
pkg_type = None
if pkg.get("purl"):
purl_obj = parse_purl(pkg.get("purl"))
# Retain empty group names
vendor = purl_obj.get("namespace")
# Fallback to using type as the vendor
pkg_type = purl_obj.get("type")
if not vendor:
vendor = purl_obj.get("type")
if pkg_type in ("npm",):
# Search for empty vendor in the key
vendor = ""
else:
# Fallback to using type as the vendor
vendor = pkg_type
name = purl_obj.get("name")
version = purl_obj.get("version")
else:
Expand All @@ -222,7 +229,8 @@ def bulk_index_search(pkg_list):
)
version_list = None
# If there is vendor information use it to perform strict search
if vendor:
# For ecosystem such as npm, always perform such a strict search to reduce false positives
if vendor or (pkg_type and pkg_type in ("npm",)):
version_list = vendor_index_data.get(vendor_idx_key, [])
store_pos_cve = pos_index_data.get(vendor_idx_key)
else:
Expand Down

0 comments on commit d9d6e35

Please sign in to comment.