-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: modernise Security/ queries #2739
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
ReflectedXss was the only query that used it with the "a"
cc2d727
to
94750fc
Compare
Since `IntObjectInternal` extends `TInt`, and `TInt` is defined for all instances of `Builtin.intValue`, and `Builtin.intValue` includes both `int` and `long`, we don't need to handles Longs in a special manner, as we did in NumericObject.
also fixes test code to use the right argument name
Replacing `Value.booleanValue`. We wanted to match `Object.booleanValue` that only gives a result if it is either `true` or `false`, but also wanted to keep the flexibility to see if the Value _could_ be `true`/`false`. We don't have a motivating usecase, so let's see if we ever need it :P + fix modernisation regression on py/jinja2/autoescape-false
94750fc
to
c1d073a
Compare
Ready to go now, except for one last question. The characteristic predicate for NumericObject is
but for NumericValue (added in this PR), I was not able to find a
Answering my own questions:I concluded that we don't need to add it, and here is my reasoning. I searched for uses of In and in It is also used in _Since |
I think I was automatically added as a reviewer when you added a comma to a |
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.
A few comments, otherwise LGTM.
test(password='format_string_{}') | ||
|
||
# TODO: we think this is a format string :\ | ||
test(password='''U]E8FPETCS_]{,y>bgyzh^$yC5>SP{E*2=`;3]G~k&+;khy3}4]jdpu;D(aP$SCFA{;hh4n46pUJ%+$nEP_gqNq#X!2$%*C-6y6%''') |
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.
And this means we do not consider it to be a string? That sounds wrong to me.
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 just that if it's a format string, then we don't consider it to be a credentials https://github.com/Semmle/ql/blob/c1d073a54dd299393fecc550b594c4a973278dbf/python/ql/src/Security/CWE-798/HardcodedCredentials.ql#L69
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.
Ah, this makes sense. We wouldn't want to flag random format strings as containing credentials (though I wonder how often this happens. We might want to see what the impact of removing not format_string(str)
is on LGTM).
No description provided.