-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Python: Copy sanitizes default modification #3502
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
Conversation
|
Jenkins seems to see the same as me. No new results, but many results duplicated. |
|
Apparently the configuration created the many duplicated results, and apparently it now works without it. Perhaps I fixed the sanitiser in the meantime. |
|
Ok, so tests pass now. I should look into a more robust detection of "value gets copied" I think, the current one only catches the posted FP. |
tausbn
left a comment
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.
Generally this looks good, but there are a bunch of subtleties surrounding how some of Python's mutating list methods work that need to be addressed in the tests. Currently, most of the test code doesn't work, and this is a bit unfortunate.
It's always a good idea to actually run the tests (using cpython) once in a while, as the behaviour may surprise you. 😉
| def safe_method(x=[]): | ||
| return x.count(42) | ||
|
|
||
| # Modification of parameter with default (sanitised) |
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.
Very minor nit: we aim to use US English in our documentation, so get your zs ready for writing sanitization etc. 🙂
|
Cool, I shall figure out how to run tests via |
|
Oh, I didn't notice your earlier comments about the duplicated test results. This is to be expected, due to the fact that you're now using a configuration. In the olden days, we didn't use configurations at all, but relied only on whatever classes you had imported for the given query. To make things a bit more similar to the other languages, we added the configurations. This left us with a bunch of queries that would yield no results, for lack of an appropriate configuration. Because of this, we have a |
|
Thanks, Larsen explained this to me also, I guess I could have edited the previous posts to reflect my new state of less confusion. |
|
Rewrote the tests, I had also duplicated some previous ones. And now I can test that test code behaves as I expect inside VSCode :) |
|
And it came to pass that Jenkins in its wisdom removed the false positive, thus building a better and brighter future, but leaving the developer rather confused. |
|
It is the alert which I get locally but not on Jenkins. It pertains to this function in Apparently, this FP does not occur on Jenkins. |
|
Aha, I can see that I have also received an email from Jenkins about a query change for |
|
After having pulled from |
|
Ok, I think I should write down our conclusions so far. This PR currently suffers from three separate issues:
def tuple_unsuccessfully_copy_before_modify(x=[]):
t = (copy(x), 3) # Tuple wrongly tainted here
t[0].append(42) # FP here
return t[0]taint flows into the tuple
def tuple_copy_before_modify(x=[]):
t = (x.copy(), 3) # Tuple not tainted here
t[0].append(42)
return t[0]taint does not flow into the tuple
I hope that [Too much flow] can be handled by implementing further sanitisers. I Propose that [Too little flow] could be moved to a separate issue, perhaps the current behaviour is even desirable/intended. I think we must solve [Py2/3 discrepancy] before the present PR can be merged. |
|
I'm confused about [Too little flow], it sounds more like a case of "correct result, but for wrong reasons"? |
|
It may be a case of me having untrained expectations of our data flow implementation. I would expect that if taint flows into a component of a tuple, then it flows, in sequence form, into the tuple. |
I'm not sure how to interpret this response 😅 So just to be clear: the function
|
|
|
I commented out the function that behaves differently between py2/3 for now.. |
|
Closing for now as this is getting out-dated. |
Add ESSA definitions via copy as sanitiser.
Currently only tested on the FP snapshot.
I would write tests, but I first need to figure out why the unmodified tests fail...