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

Transform all async ast nodes into sync nodes #158

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

Merged
KevinHock merged 1 commit into python-security:master from bcaller:await-transform
Jul 31, 2018

Conversation

@bcaller
Copy link
Collaborator

@bcaller bcaller commented Jul 31, 2018
edited
Loading

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))

KevinHock reacted with thumbs up emoji KevinHock reacted with hooray emoji KevinHock reacted with heart emoji
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))`
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

@KevinHock KevinHock Jul 31, 2018

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

Reviewers

@KevinHock KevinHock KevinHock approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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