MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / parse_werkzeug_url

Function parse_werkzeug_url

aura/analyzers/python/taint/visitor.py:300–316  ·  view source on GitHub ↗

Parse a flask/werkzeug URL to extract placeholders and their processors This is used in taint analysis to find tainted URL arguments for example: /api/v1.0/lookup/ /info would extract the 'username' placeholder (with no processor)

(url: str)

Source from the content-addressed store, hash-verified

298
299
300def parse_werkzeug_url(url: str) -> dict:
301 """
302 Parse a flask/werkzeug URL to extract placeholders and their processors
303 This is used in taint analysis to find tainted URL arguments
304 for example: /api/v1.0/lookup/<username>/info
305 would extract the 'username' placeholder (with no processor)
306 """
307 regex = re.compile(
308 r"<(?P<processor>([a-z_\d]+)(\(.*\))?:)?(?P<parameter>[a-z\d_]+)>"
309 )
310
311 parsed = {}
312
313 for finding in regex.findall(url):
314 parsed[finding[-1]] = finding[0].rstrip(":")
315
316 return parsed

Callers 1

__mark_sourcesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected