@@ -142,9 +142,9 @@ def get(self): # $ requestHandler
142
142
self .request .url # $ tainted
143
143
)
144
144
145
- # not a request handler, and not called, btu since we have type-annotation, should be a
145
+ # not a request handler, and not called, but since we have type-annotation, should be a
146
146
# remote-flow-source.
147
- async def test_heuristic_taint (request : web .Request ):
147
+ async def test_source_from_type_annotation (request : web .Request ):
148
148
# picking out just a few of the tests from `test_taint` above, to show that we have
149
149
# the same taint-steps :)
150
150
ensure_tainted (
@@ -153,10 +153,25 @@ async def test_heuristic_taint(request: web.Request):
153
153
await request .content .read (), # $ tainted
154
154
)
155
155
156
+ # Test that since we can reach the `request` object in the helper function, we don't
157
+ # introduce a new remote-flow-source, but instead use the one from the caller. (which is
158
+ # checked to not be tainted)
159
+ async def test_sanitizer (request ): # $ requestHandler
160
+ ensure_tainted (request , request .url , await request .content .read ()) # $ tainted
161
+
162
+ if (is_safe (request )):
163
+ ensure_not_tainted (request , request .url , await request .content .read ())
164
+ test_safe_helper_function_no_route_with_type (request )
165
+
166
+
167
+ async def test_safe_helper_function_no_route_with_type (request : web .Request ):
168
+ ensure_not_tainted (request , request .url , await request .content .read ()) # $ SPURIOUS: tainted
169
+
156
170
157
171
app = web .Application ()
158
172
app .router .add_get (r"/test_taint/{name}/{number:\d+}" , test_taint ) # $ routeSetup="/test_taint/{name}/{number:\d+}"
159
173
app .router .add_view (r"/test_taint_class" , TaintTestClass ) # $ routeSetup="/test_taint_class"
174
+ app .router .add_view (r"/test_sanitizer" , test_sanitizer ) # $ routeSetup="/test_sanitizer"
160
175
161
176
162
177
if __name__ == "__main__" :
0 commit comments