Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gcp/website/frontend_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def _dict_to_vuln(data: object,
if not vuln_id:
return None

vulnerability = vulnerability_pb2.Vulnerability()
try:
json_format.ParseDict(data, vulnerability, ignore_unknown_fields=True)
vulnerability = sources.parse_vulnerability_from_dict(
data, strict=False)
except Exception as error:
print(f'[emulator] Failed to convert entry in {path}: {error}')
return None
Expand Down
4 changes: 4 additions & 0 deletions gcp/website/frontend_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,9 @@ def sort_versions(versions: list[str], ecosystem: str) -> list[str]:
# with
# <a href="https://chromium.googlesource.com/v8/v8.git/+/refs/heads/beta">
_URL_MARKDOWN_REPLACER = re.compile(r'(<a href=\".*?)(/ /)(.*?\">)')
_ANCHOR_TAG_REPLACER = re.compile(
r'<a\s+[^>]*name=["\'][^"\']*["\'][^>]*>\s*</a>|<a\s+[^>]*name=["\'][^"\']*["\'][^>]*/>',
re.IGNORECASE)


@blueprint.app_template_filter('markdown')
Expand All @@ -852,6 +855,7 @@ def markdown(text):
# space rather than %2B
# See: https://github.com/trentm/python-markdown2/issues/621
md = _URL_MARKDOWN_REPLACER.sub(r'\1/+/\3', md)
md = _ANCHOR_TAG_REPLACER.sub('', md)

return md

Expand Down
2 changes: 2 additions & 0 deletions osv/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import hashlib
import logging
import os
import re

import jsonschema
import pygit2
Expand Down Expand Up @@ -165,6 +166,7 @@ def _get_nested_vulnerability(data, key_path=None):
def parse_vulnerability_from_dict(data, key_path=None, strict=False):
"""Parse vulnerability from dict."""
data = _get_nested_vulnerability(data, key_path)

try:
jsonschema.validate(data, load_schema())
except jsonschema.exceptions.ValidationError as e:
Expand Down