Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 37780ba

Browse files
author
Ben Caller
committed
AugAssign propagates taint
Before, the variable would be tainted only if the last += was tainted. Now url = 'http://' url += TAINT url += '?x=y' url marked as tainted.
1 parent ff0e042 commit 37780ba

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

‎pyt/cfg/stmt_visitor.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,12 @@ def visit_AugAssign(self, node):
499499
rhs_visitor = RHSVisitor()
500500
rhs_visitor.visit(node.value)
501501

502+
lhs = extract_left_hand_side(node.target)
502503
return self.append_node(AssignmentNode(
503504
label.result,
504-
extract_left_hand_side(node.target),
505+
lhs,
505506
node,
506-
rhs_visitor.result,
507+
rhs_visitor.result+ [lhs],
507508
path=self.filenames[-1]
508509
))
509510

‎tests/cfg/cfg_test.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,14 @@ def test_assignment_starred_list(self):
820820
[('a', ['d']), ('b', ['d']), ('c', ['e'])],
821821
)
822822

823+
def test_augmented_assignment(self):
824+
self.cfg_create_from_ast(ast.parse('a+=f(b,c)'))
825+
826+
(node,) = self.cfg.nodes[1:-1]
827+
self.assertEqual(node.label, 'a += f(b, c)')
828+
self.assertEqual(node.left_hand_side, 'a')
829+
self.assertEqual(node.right_hand_side_variables, ['b', 'c', 'a'])
830+
823831

824832
class CFGComprehensionTest(CFGBaseTestCase):
825833
def test_nodes(self):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /