Starred tuple assignment#150
Merged
Merged
Conversation
KevinHock
approved these changes
Jul 24, 2018
Collaborator
KevinHock
left a comment
There was a problem hiding this comment.
This is really great code, thanks for this! :)
| new_ast_node = ast.Assign(target, value) | ||
| new_ast_node.lineno = node.lineno | ||
|
|
||
| ast.copy_location(new_ast_node, node) |
| for var in rhs_visitor.result: | ||
| remaining_variables.remove(var) | ||
|
|
||
| # Pair targets and values until a Starred node is reached |
| [(n.left_hand_side, n.right_hand_side_variables) for n in middle_nodes], | ||
| [('a', ['f']), ('b', ['g', 'h']), ('c', ['g', 'h']), ('d', ['f', 'i']), ('e', ['j'])], | ||
| ) | ||
|
|
Collaborator
There was a problem hiding this comment.
Possible pep8 nit: w/r/t one line between methods of a class.
Try to match the targets with the values so we reduce the number of false positives. Before, all right hand side variables were tainting all of the left hand side variables. a, *b = _, _, TAINT a clean, b tainted a, *b, c = _, _, TAINT, TAINT, _ a clean, b tainted, c clean a, *b, c = _, *_, *TAINT, *_ a clean, b tainted, c tainted
e08b8ab to
80113af
Compare
Collaborator
Author
|
Fixed. I'll try and fix travis and tox configs later because I think flake8 should've caused the build to fail. |
Collaborator
|
Awesome, thanks again :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We can do slightly better than just assigning all of the RHS variables to all the LHS targets.
a, b = c, dshould be easy to propagate taint to the correct variable for instance.When we have starargs then we can still try to propagate taint to the variables which could potentially end up tainted.