-
Notifications
You must be signed in to change notification settings - Fork 71
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
Re-entrancy detector + Control Flow Graph #752
base: dev
Are you sure you want to change the base?
Re-entrancy detector + Control Flow Graph #752
Conversation
@alexroan Please review the detector test file, and see if you can break it ! Let me know if you can think of some edge cases not covered |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Just realized I need to put a filter on the external calls to exclude the ones that are library calls because they are delegate calls and they can't reenter UPDATE |
Ahhhh finally merged dev into this |
Fix #313
Long version:
At the moment Control Flow Graph module exposes -
Cfg::from_function_body(f: &FunctionDefinition)
Cfg::from_modifier_body(f: &ModifierDefinition)
Returns a tuple
(cfg, start_node, end_node)
The first argument is a
cfg
object that gives you access to the adjacency list representation of the control flow graph.The second argument is used to point you to the place in the cfg where the function body's cfg start.
Those 2 things are used to build and traverse the control flow graph. In case you want to see the corresponding AST node, you can call
cfg_node.reflect(context)
on the CFG node. It will returnASTNode
. Thanks to this, you can make use of existing ASTNode libraries and helpers.Also attached to this PR are 2 reentrancy detectors plus an incorrect use of modifier detector that server as examples to see learn how cfg can be leveraged in various detectors
NOTE:
It constructs CFG from
f
's body only. It's not calledCfg::from_function
by choice as that would involve decomposing the entire function (which involves resolving internal functions, resolving modifiers, etc). We don't have that ability yet(Same logic goes for modifiers)