Skip to content

Commit c59b5c9

Browse files
committed
Python: Replace use of AttrNode with getMember
1 parent 72a699e commit c59b5c9

File tree

1 file changed

+36
-40
lines changed
  • python/ql/src/semmle/python/frameworks

1 file changed

+36
-40
lines changed

python/ql/src/semmle/python/frameworks/Flask.qll

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -312,46 +312,42 @@ private module FlaskModel {
312312

313313
RequestInputAccess() {
314314
// attributes
315-
exists(AttrNode attr |
316-
this.asCfgNode() = attr and
317-
attr.getObject(attr_name) = flask::request().getAUse().asCfgNode()
318-
|
319-
attr_name in [
320-
// str
321-
"path", "full_path", "base_url", "url", "access_control_request_method",
322-
"content_encoding", "content_md5", "content_type", "data", "method", "mimetype",
323-
"origin", "query_string", "referrer", "remote_addr", "remote_user", "user_agent",
324-
// dict
325-
"environ", "cookies", "mimetype_params", "view_args",
326-
// json
327-
"json",
328-
// List[str]
329-
"access_route",
330-
// file-like
331-
"stream", "input_stream",
332-
// MultiDict[str, str]
333-
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.MultiDict
334-
"args", "values", "form",
335-
// MultiDict[str, FileStorage]
336-
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.FileStorage
337-
// TODO: FileStorage needs extra taint steps
338-
"files",
339-
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.HeaderSet
340-
"access_control_request_headers", "pragma",
341-
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Accept
342-
// TODO: Kinda badly modeled for now -- has type List[Tuple[value, quality]], and some extra methods
343-
"accept_charsets", "accept_encodings", "accept_languages", "accept_mimetypes",
344-
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Authorization
345-
// TODO: dict subclass with extra attributes like `username` and `password`
346-
"authorization",
347-
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.RequestCacheControl
348-
// TODO: has attributes like `no_cache`, and `to_header` method (actually, many of these models do)
349-
"cache_control",
350-
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Headers
351-
// TODO: dict-like with wsgiref.headers.Header compatibility methods
352-
"headers"
353-
]
354-
)
315+
this = flask::request().getMember(attr_name).getAUse() and
316+
attr_name in [
317+
// str
318+
"path", "full_path", "base_url", "url", "access_control_request_method",
319+
"content_encoding", "content_md5", "content_type", "data", "method", "mimetype", "origin",
320+
"query_string", "referrer", "remote_addr", "remote_user", "user_agent",
321+
// dict
322+
"environ", "cookies", "mimetype_params", "view_args",
323+
// json
324+
"json",
325+
// List[str]
326+
"access_route",
327+
// file-like
328+
"stream", "input_stream",
329+
// MultiDict[str, str]
330+
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.MultiDict
331+
"args", "values", "form",
332+
// MultiDict[str, FileStorage]
333+
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.FileStorage
334+
// TODO: FileStorage needs extra taint steps
335+
"files",
336+
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.HeaderSet
337+
"access_control_request_headers", "pragma",
338+
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Accept
339+
// TODO: Kinda badly modeled for now -- has type List[Tuple[value, quality]], and some extra methods
340+
"accept_charsets", "accept_encodings", "accept_languages", "accept_mimetypes",
341+
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Authorization
342+
// TODO: dict subclass with extra attributes like `username` and `password`
343+
"authorization",
344+
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.RequestCacheControl
345+
// TODO: has attributes like `no_cache`, and `to_header` method (actually, many of these models do)
346+
"cache_control",
347+
// https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Headers
348+
// TODO: dict-like with wsgiref.headers.Header compatibility methods
349+
"headers"
350+
]
355351
or
356352
// methods (needs special handling to track bound-methods -- see `FlaskRequestMethodCallsAdditionalTaintStep` below)
357353
this = FlaskRequestTracking::tainted_methods(attr_name).getAUse()

0 commit comments

Comments
 (0)