Skip to content

Commit

Permalink
fix: [website] Ensures that the vulnerability id has been specified b…
Browse files Browse the repository at this point in the history
…y the user.
  • Loading branch information
cedricbonhomme committed Aug 27, 2024
1 parent 36fae38 commit 5706b0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion website/web/api/v1/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,17 @@ def post(self) -> Tuple[Dict[Any, Any], int]:
logger.warning("JSON validation failed.")
abort(400, "JSON validation failed.")

vuln_id = vuln["cveMetadata"]["vulnId"].lower()
vuln_id = vuln["cveMetadata"].get("vulnId", "").lower()
cve_id = vuln["cveMetadata"].get("cveId", "").lower() or None

if not vuln_id:
abort(
400,
"You must specify a vulnerability id to the format: {}.".format(
local_instance_vulnid_pattern
),
)

source = (
vulnerabilitylookup.get_vulnerability_source(vuln_id) or local_instance_name
)
Expand Down
2 changes: 1 addition & 1 deletion website/web/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_sri(directory: str, filename: str) -> str:

# ##### Jinja custom filters

application.jinja_env.filters['str_to_obj'] = jinja_filters.str_to_obj
application.jinja_env.filters["str_to_obj"] = jinja_filters.str_to_obj
application.jinja_env.filters["datetimeformat"] = jinja_filters.datetimeformat
application.jinja_env.filters["string_to_datetime"] = jinja_filters.string_to_datetime
application.jinja_env.filters["markdown"] = jinja_filters.to_markdown
Expand Down

0 comments on commit 5706b0f

Please sign in to comment.