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
Python: Add basic flow for class attributes #14706
base: main
Are you sure you want to change the base?
Conversation
All are for the better 🎉
|
FYI: Tests on this PR will fail until #14590 is merged (now merged into this PR 👍) |
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.
Some questions, but I think this is an improvement regardless of the answers and further improvements can be made later. You included a nice set of test to make that easier 👍
| @@ -64,7 +64,7 @@ class Unsafe: | |||
| def test_value_pattern(): | |||
| match SOURCE: | |||
| case Unsafe.VALUE as x: | |||
| SINK(x) #$ flow="SOURCE, l:-2 -> x" MISSING: flow="SOURCE, l:-5 -> x" | |||
| SINK(x) #$ flow="SOURCE, l:-2 -> x" flow="SOURCE, l:-5 -> x" | |||
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.
Nice bonus :-)
python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll
Outdated
Show resolved
Hide resolved
|
|
||
| set_to_source() | ||
|
|
||
| SINK(WithTuple2.my_tuple[0]) # $ MISSING: flow="SOURCE, l:-10 -> WithTuple2.my_tuple[0]" |
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.
Is this missing because we do not have post-update nodes?
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.
No. It's missing because we don't have any global for the store to WithTuple2 in set_to_source, to the reference in the test_class_override function. Without that global flow (jump step), we just get flow from the class definition (that is, think it's still a nonsource).
If we inlined set_to_source, we would get flow through normal attribute-store, so that doesn't count.
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.
I've renamed the function to make this more clear
| class Outer: | ||
| src = SOURCE | ||
| class Inner: | ||
| src = SOURCE |
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.
Do we want a test updating this value, to test the need for post-update nodes?
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.
I didn't find a need for it. Happy to accept a suggestion if you feel like it 😊
…ate.qll Co-authored-by: yoff <lerchedahl@gmail.com>
No description provided.