File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change
1
+ from flask import Flask , request
2
+
3
+ app = Flask (__name__ )
4
+
5
+
6
+ def recur_without_any_propagation (x ):
7
+ if len (x ) < 20 :
8
+ return recur_without_any_propagation ("a" * 24 )
9
+ return "Done"
10
+
11
+
12
+ def recur_no_propagation_false_positive (x ):
13
+ if len (x ) < 20 :
14
+ return recur_no_propagation_false_positive (x + "!" )
15
+ return "Done"
16
+
17
+
18
+ def recur_with_propagation (x ):
19
+ if len (x ) < 20 :
20
+ return recur_with_propagation (x + "!" )
21
+ return x
22
+
23
+
24
+ @app .route ('/recursive' )
25
+ def route ():
26
+ param = request .args .get ('param' , 'not set' )
27
+ repeated_completely_untainted = recur_without_any_propagation (param )
28
+ app .db .execute (repeated_completely_untainted )
29
+ repeated_untainted = recur_no_propagation_false_positive (param )
30
+ app .db .execute (repeated_untainted )
31
+ repeated_tainted = recur_with_propagation (param )
32
+ app .db .execute (repeated_tainted )
Original file line number Diff line number Diff line change @@ -108,11 +108,11 @@ def test_targets_with_recursive(self):
108
108
excluded_files = ""
109
109
110
110
included_files = discover_files (targets , excluded_files , True )
111
- self .assertEqual (len (included_files ), 31 )
111
+ self .assertEqual (len (included_files ), 32 )
112
112
113
113
def test_targets_with_recursive_and_excluded (self ):
114
114
targets = ["examples/vulnerable_code/" ]
115
115
excluded_files = "inter_command_injection.py"
116
116
117
117
included_files = discover_files (targets , excluded_files , True )
118
- self .assertEqual (len (included_files ), 30 )
118
+ self .assertEqual (len (included_files ), 31 )
Original file line number Diff line number Diff line change @@ -465,6 +465,11 @@ def assert_vulnerable(fixture):
465
465
assert_vulnerable ('result = repr(str("%s" % TAINT.lower().upper()))' )
466
466
assert_vulnerable ('result = repr(str("{}".format(TAINT.lower())))' )
467
467
468
+ def test_recursion (self ):
469
+ # Really this file only has one vulnerability, but for now it's safer to keep the false positive.
470
+ vulnerabilities = self .run_analysis ('examples/vulnerable_code/recursive.py' )
471
+ self .assert_length (vulnerabilities , expected_length = 2 )
472
+
468
473
469
474
class EngineDjangoTest (VulnerabilitiesBaseTestCase ):
470
475
def run_analysis (self , path ):
You can’t perform that action at this time.
0 commit comments