-
Notifications
You must be signed in to change notification settings - Fork 969
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
Fixed data dependencies for ReferenceVariable
#2288
base: dev
Are you sure you want to change the base?
Conversation
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThe recent update introduces a functionality for checking dependencies between state variables in a smart contract named "Index". It specifically adds an Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- examples/scripts/data_dependency.py (1 hunks)
- examples/scripts/data_dependency.sol (1 hunks)
- slither/analyses/data_dependency/data_dependency.py (1 hunks)
Additional comments: 3
examples/scripts/data_dependency.sol (1)
- 119-127: The
Index
contract is correctly implemented with a public mapping and a function to update theref
variable based on the sender's address. This follows Solidity best practices for mapping usage and function visibility.examples/scripts/data_dependency.py (1)
- 130-144: The script correctly implements functionality to check dependencies between state variables in the
Index
contract. It uses theis_dependent
function effectively to verify dependencies betweenref
,mapping_var
, andmsg.sender
. This addition follows Python best practices and is logically sound.slither/analyses/data_dependency/data_dependency.py (1)
- 423-424: The modification to include
ir.variable_right
in theread
list whenlvalue
is an instance ofReferenceVariable
is correctly implemented. This change ensures that data dependencies are accurately captured, addressing the issue highlighted in the PR description.
I think it makes sense to consider both the lefthand and righthand side as tainted for |
if isinstance(ir, OperationWithLValue) and ir.lvalue:
if isinstance(ir.lvalue, LocalIRVariable) and ir.lvalue.is_storage:
continue
if isinstance(ir.lvalue, ReferenceVariable):
lvalue = ir.lvalue.points_to
if lvalue:
add_dependency(lvalue, function, ir, is_protected)
add_dependency(ir.lvalue, function, ir, is_protected) For an |
Sorry, I miss understood and this is a separate issue.
|
I have simplified the condition.
|
Thanks for the example as it helped me understand the changes. As I understand, previously the data dependency would not consider
I think this makes sense, but I want to double check with @montyly considering this may be a purposeful under-approximation to prevent additional false positives in detectors that use the data dependency analysis. |
In an
Index
operation,ir.lvalue
depends onir.variable_left
andir.variable_right
.Summary by CodeRabbit