@@ -58,6 +58,35 @@ module Werkzeug {
5858 */
5959 DataFlow:: Node getlist ( ) { result = getlist ( DataFlow:: TypeTracker:: end ( ) ) }
6060 }
61+
62+ /**
63+ * Provides models for the `werkzeug.datastrctures.FileStorage` class
64+ *
65+ * See https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.FileStorage.
66+ */
67+ module FileStorage {
68+ /**
69+ * A source of an instance of `werkzeug.datastrctures.FileStorage`.
70+ *
71+ * This can include instantiation of the class, return value from function
72+ * calls, or a special parameter that will be set when functions are call by external
73+ * library.
74+ *
75+ * Use `FileStorage::instance()` predicate to get references to instances of `werkzeug.datastrctures.FileStorage`.
76+ */
77+ abstract class InstanceSource extends DataFlow:: Node { }
78+
79+ /** Gets a reference to an instance of `werkzeug.datastrctures.FileStorage`. */
80+ private DataFlow:: Node instance ( DataFlow:: TypeTracker t ) {
81+ t .start ( ) and
82+ result instanceof InstanceSource
83+ or
84+ exists ( DataFlow:: TypeTracker t2 | result = instance ( t2 ) .track ( t2 , t ) )
85+ }
86+
87+ /** Gets a reference to an instance of `werkzeug.datastrctures.FileStorage`. */
88+ DataFlow:: Node instance ( ) { result = instance ( DataFlow:: TypeTracker:: end ( ) ) }
89+ }
6190 }
6291 }
6392
@@ -76,34 +105,21 @@ module Werkzeug {
76105 }
77106 }
78107
79- module Datastructures {
80- // ---------------------------------------------------------------------- //
81- // FileStorage //
82- // ---------------------------------------------------------------------- //
83- /**
84- * A Node representing an instance of a werkzeug.datastructures.FileStorage
85- *
86- * See https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.FileStorage
87- */
88- abstract class FileStorage extends DataFlow:: Node { }
89-
90- private class FileStorageAdditionalTaintStep extends TaintTracking:: AdditionalTaintStep {
91- override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
92- // TODO: should be `nodeFrom = tracked(any(FileStorage fs))`
93- nodeFrom instanceof FileStorage and
94- exists ( string name |
95- name in [ "filename" ,
96- // str
97- "name" , "content_type" , "mimetype" ,
98- // file-like
99- "stream" ,
100- // TODO: werkzeug.datastructures.Headers
101- "headers" ,
102- // dict[str, str]
103- "mimetype_params" ] and
104- nodeTo .asCfgNode ( ) .( AttrNode ) .getObject ( name ) = nodeFrom .asCfgNode ( )
105- )
106- }
108+ private class FileStorageAdditionalTaintStep extends TaintTracking:: AdditionalTaintStep {
109+ override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
110+ nodeFrom = werkzeug:: datastructures:: FileStorage:: instance ( ) and
111+ exists ( DataFlow:: AttrRead read | nodeTo = read |
112+ read .getAttributeName ( ) in [ "filename" ,
113+ // str
114+ "name" , "content_type" , "mimetype" ,
115+ // file-like
116+ "stream" ,
117+ // TODO: werkzeug.datastructures.Headers
118+ "headers" ,
119+ // dict[str, str]
120+ "mimetype_params" ] and
121+ read .getObject ( ) = nodeFrom
122+ )
107123 }
108124 }
109125}
0 commit comments