-
Notifications
You must be signed in to change notification settings - Fork 63
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
Open
TilakMaddy
wants to merge
48
commits into
dev
Choose a base branch
from
feature/control-flow-graphs-plus-re-entrancy-detector
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Re-entrancy detector + Control Flow Graph #752
TilakMaddy
wants to merge
48
commits into
dev
from
feature/control-flow-graphs-plus-re-entrancy-detector
Conversation
This file contains 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
TilakMaddy
changed the title
Feature/control flow graphs plus re entrancy detector
Re-entrancy detector introduced with Control Flow Graph
Oct 6, 2024
TilakMaddy
changed the title
Re-entrancy detector introduced with Control Flow Graph
Re-entrancy detector + Control Flow Graph
Oct 6, 2024
@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 |
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.
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)