-
Notifications
You must be signed in to change notification settings - Fork 238
/
reaching_definitions_taint.py
29 lines (24 loc) · 1.33 KB
/
reaching_definitions_taint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from .base_cfg import AssignmentNode
from .constraint_table import constraint_table
from .reaching_definitions_base import ReachingDefinitionsAnalysisBase
class ReachingDefinitionsTaintAnalysis(ReachingDefinitionsAnalysisBase):
"""Reaching definitions analysis rules implemented."""
def fixpointmethod(self, cfg_node):
JOIN = self.join(cfg_node)
# Assignment check
if isinstance(cfg_node, AssignmentNode):
arrow_result = JOIN
# vv_result is necessary to know `image_name = image_name.replace('..', '')` is a reassignment.
if cfg_node.vv_result:
if cfg_node.left_hand_side not in cfg_node.vv_result:
# Get previous assignments of cfg_node.left_hand_side and remove them from JOIN
arrow_result = self.arrow(JOIN, cfg_node.left_hand_side)
# Other reassignment check
elif cfg_node.left_hand_side not in cfg_node.right_hand_side_variables:
# Get previous assignments of cfg_node.left_hand_side and remove them from JOIN
arrow_result = self.arrow(JOIN, cfg_node.left_hand_side)
arrow_result = arrow_result | self.lattice.el2bv[cfg_node]
constraint_table[cfg_node] = arrow_result
# Default case
else:
constraint_table[cfg_node] = JOIN