class
Analyzer::Python::Sanic
Defined in:
analyzer/analyzers/python/sanic.crConstant Summary
-
ADD_ROUTE_CALL_RE =
/\b(#{PYTHON_VAR_NAME_REGEX})\.add_route\s*\((.*)\)\s*$/m -
ADD_WEBSOCKET_ROUTE_CALL_RE =
/\b(#{PYTHON_VAR_NAME_REGEX})\.add_websocket_route\s*\((.*)\)\s*$/m -
AS_VIEW_RE =
/^(#{PYTHON_VAR_NAME_REGEX})\.as_view\s*\(/ -
BLUEPRINT_CALL_RE =
/\.blueprint\s*\(\s*(#{PYTHON_VAR_NAME_REGEX})(.*?)\)/m -
BLUEPRINT_CTOR_RE =
/(#{PYTHON_VAR_NAME_REGEX})\s*=\s*(?:sanic\.)?Blueprint\s*\((.*?)\)/m -
BLUEPRINT_GROUP_RE =
/(?:#{PYTHON_VAR_NAME_REGEX}\s*=\s*)?Blueprint\s*\.\s*group\s*\((.*?)\)/m -
DOTTED_REFERENCE_RE =
/^#{PYTHON_VAR_NAME_REGEX}(?:\.#{PYTHON_VAR_NAME_REGEX})*$/ -
REQUEST_PARAM_FIELD_PATTERNS =
REQUEST_PARAM_FIELDS.map do |field, tuple| {"request.#{field}", tuple[1], /request\.#{field}(?:\.get)?\(['"']([^'"']+)['"']\)/, /request\.#{field}\[['"']([^'"']+)['"']\]/} end -
get_endpointsrebuilt two PCRE2 patterns per request field on every handler-body line. The field set is fixed, so precompile the access patterns (and therequest.<field>guard substring) once. Tuple shape: {guard_substring, noir_param_type, paren_re, bracket_re} -
REQUEST_PARAM_FIELDS =
{"args" => {["GET"], "query"}, "form" => {["POST", "PUT", "PATCH", "DELETE"], "form"}, "files" => {["POST", "PUT", "PATCH", "DELETE"], "form"}, "json" => {["POST", "PUT", "PATCH", "DELETE"], "json"}, "cookies" => {nil, "cookie"}, "headers" => {nil, "header"}} -
Reference: https://sanic.readthedocs.io/en/stable/sanic/request.html
-
REQUEST_PARAM_TYPES =
{"query" => nil, "form" => ["POST", "PUT", "PATCH", "DELETE"], "json" => ["POST", "PUT", "PATCH", "DELETE"], "cookie" => nil, "header" => nil} -
SANIC_INSTANCE_RE =
/(#{PYTHON_VAR_NAME_REGEX})(?::#{PYTHON_VAR_NAME_REGEX})?=(?:sanic\.)?Sanic\(/ -
Hoisted out of the analyze loops: an interpolated regex literal recompiles (PCRE2 JIT) on every evaluation, and these interpolate only constants. The
.to_sexpansion is byte-identical to the previous inline form, so matching behaviour is unchanged. -
STATIC_CALL_RE =
/\b(#{PYTHON_VAR_NAME_REGEX})\.static\s*\((.*)\)\s*$/m