Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform all async ast nodes into sync nodes #158

Merged
merged 1 commit into from
Jul 31, 2018

Conversation

bcaller
Copy link
Collaborator

@bcaller bcaller commented Jul 31, 2018

Transform all async ast nodes into sync nodes …
so that they can be handled identically. Sync and async nodes propagate
taint in exactly the same way.

Awaits are more or less removed:
return await x() is converted into return x().

Any AsyncFunctionDef is converted to a FunctionDef.

Same for AsyncFor and AsyncWith.

Using a transformer makes it easier to replace awaits everywhere (c.f. a different attempt at https://github.com/bcaller/pyt/commits/await ).
We have lots of places where we do isinstance(node, ast.Call) but for these we want it to function like isinstance(node, ast.Call) or (isinstance(node, ast.Await) and isinstance(node.value, ast.Call))

so that they can be handled identically. Sync and async nodes propagate
taint in exactly the same way.

Awaits are more or less removed:
`return await x()` is converted into `return x()`.

Any AsyncFunctionDef is converted to a FunctionDef.

Same for AsyncFor and AsyncWith.

Using a transformer makes it easier to replace awaits everywhere.
We have lots of places where we do `isinstance(node, ast.Call)` but for these we want it to function like `isinstance(node, ast.Call) or (isinstance(node, ast.Await) and isinstance(node.value, ast.Call))`
@KevinHock
Copy link
Collaborator

This is genius! 😁 I'll review later today

Copy link
Collaborator

@KevinHock KevinHock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! 🚢

from pyt.core.transformer import AsyncTransformer


class TransformerTest(unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great tests :D

@KevinHock KevinHock merged commit 212e059 into python-security:master Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants