Skip to content

Commit

Permalink
Have the shorthand vulnerability redirector handle IDs with colons (#…
Browse files Browse the repository at this point in the history
…2431)

AlmaLinux has colons in its identifiers, which were not working
correctly because the regex didn't match them, and they were being URL
encoded.
  • Loading branch information
andrewpollock authored Aug 2, 2024
1 parent 17393fd commit 755be7e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gcp/appengine/frontend_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
_PAGE_LOOKAHEAD = 4
_REQUESTS_PER_MIN = 30
_WORD_CHARACTERS_OR_DASH = re.compile(r'^[+\w-]+$')
_WORD_CHARACTERS_OR_DASH_OR_COLON = re.compile(r'^[+\w:-]+$')
_VALID_BLOG_NAME = _WORD_CHARACTERS_OR_DASH
_VALID_VULN_ID = _WORD_CHARACTERS_OR_DASH
_VALID_VULN_ID = _WORD_CHARACTERS_OR_DASH_OR_COLON
_BLOG_CONTENTS_DIR = 'blog'
_DEPS_BASE_URL = 'https://deps.dev'
_FIRST_CVSS_CALCULATOR_BASE_URL = 'https://www.first.org/cvss/calculator'
Expand Down Expand Up @@ -247,6 +248,8 @@ def vulnerability(vuln_id):
@blueprint.route('/<potential_vuln_id>')
def vulnerability_redirector(potential_vuln_id):
"""Convenience redirector for /VULN-ID to /vulnerability/VULN-ID."""
# AlmaLinux have colons in their identifiers, which gets URL encoded.
potential_vuln_id = parse.unquote(potential_vuln_id)
if not _VALID_VULN_ID.match(potential_vuln_id):
abort(404)
return None
Expand Down

0 comments on commit 755be7e

Please sign in to comment.