1515from pyt .constraint_table import initialize_constraint_table
1616from pyt .fixed_point import analyse
1717from pyt .framework_adaptor import FrameworkAdaptor
18- from pyt .framework_helper import (
18+ from pyt .framework_helper import (
1919 is_django_view_function ,
20- is_flask_route_function
20+ is_flask_route_function ,
21+ is_function
2122)
2223from pyt .node_types import Node
2324from pyt .reaching_definitions_taint import ReachingDefinitionsTaintAnalysis
@@ -95,17 +96,15 @@ def test_find_triggers(self):
9596 l = vulnerabilities .find_triggers (XSS1 .nodes , trigger_words )
9697 self .assert_length (l , expected_length = 1 )
9798
98- 9999 def test_find_sanitiser_nodes (self ):
100100 cfg_node = Node (None , None , line_number = None , path = None )
101- sanitiser_tuple = vulnerabilities .Sanitiser ('escape' , cfg_node )
101+ sanitiser_tuple = vulnerabilities .Sanitiser ('escape' , cfg_node )
102102 sanitiser = 'escape'
103103
104104 result = list (vulnerabilities .find_sanitiser_nodes (sanitiser , [sanitiser_tuple ]))
105105 self .assert_length (result , expected_length = 1 )
106106 self .assertEqual (result [0 ], cfg_node )
107107
108- 109108 def test_build_sanitiser_node_dict (self ):
110109 self .cfg_create_from_file ('examples/vulnerable_code/XSS_sanitised.py' )
111110 cfg_list = [self .cfg ]
@@ -114,7 +113,7 @@ def test_build_sanitiser_node_dict(self):
114113
115114 cfg = cfg_list [1 ]
116115
117- cfg_node = Node (None , None , line_number = None , path = None )
116+ cfg_node = Node (None , None , line_number = None , path = None )
118117 sinks_in_file = [vulnerabilities .TriggerNode ('replace' , ['escape' ], cfg_node )]
119118
120119 sanitiser_dict = vulnerabilities .build_sanitiser_node_dict (cfg , sinks_in_file )
@@ -142,7 +141,6 @@ def run_analysis(self, path):
142141 )
143142 )
144143
145- 146144 def test_find_vulnerabilities_assign_other_var (self ):
147145 vulnerabilities = self .run_analysis ('examples/vulnerable_code/XSS_assign_to_other_var.py' )
148146 self .assert_length (vulnerabilities , expected_length = 1 )
@@ -555,3 +553,37 @@ def test_django_view_param(self):
555553 ~call_1 = ret_render(request, 'templates/xss.html', 'param'param)
556554 """
557555 self .assertTrue (self .string_compare_alpha (vulnerability_description , EXPECTED_VULNERABILITY_DESCRIPTION ))
556+ 557+ 558+ class EngineEveryTest (BaseTestCase ):
559+ def run_empty (self ):
560+ return
561+ 562+ def run_analysis (self , path ):
563+ self .cfg_create_from_file (path )
564+ cfg_list = [self .cfg ]
565+ 566+ FrameworkAdaptor (cfg_list , [], [], is_function )
567+ initialize_constraint_table (cfg_list )
568+ 569+ analyse (cfg_list , analysis_type = ReachingDefinitionsTaintAnalysis )
570+ 571+ trigger_word_file = os .path .join (
572+ 'pyt' ,
573+ 'vulnerability_definitions' ,
574+ 'all_trigger_words.pyt'
575+ )
576+ 577+ return vulnerabilities .find_vulnerabilities (
578+ cfg_list ,
579+ ReachingDefinitionsTaintAnalysis ,
580+ UImode .NORMAL ,
581+ VulnerabilityFiles (
582+ default_blackbox_mapping_file ,
583+ trigger_word_file
584+ )
585+ )
586+ 587+ def test_self_is_not_tainted (self ):
588+ vulnerabilities = self .run_analysis ('examples/example_inputs/def_with_self_as_first_arg.py' )
589+ self .assert_length (vulnerabilities , expected_length = 0 )
0 commit comments