-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: Expand StringConstCompareBarrier
sanitizer gaurds to cover additional constants
#17540
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
@@ -142,7 +142,7 @@ module UrlRedirect { | |||
/** | |||
* A comparison with a constant string, considered as a sanitizer-guard. | |||
*/ | |||
class StringConstCompareAsSanitizerGuard extends Sanitizer, StringConstCompareBarrier { | |||
class StringConstCompareAsSanitizerGuard extends Sanitizer, ConstCompareBarrier { |
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.
Did you mean to follow the same pattern of deprecation here?
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.
Yes; I had missed it with a find-and-replace.
Updated.
|
||
def test_in_list_with_constants(): | ||
ts = TAINTED_STRING | ||
if ts in ["safe", None, 3, False]: |
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.
Would it be considered tainted if there is a non-constant in this list? Should we have a test with that?
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.
Additional test added.
This looks like a very nice and useful generalisation :-) |
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.
LGTM
Renames
StringConstCompareBarrier
toConstCompareBarrier
and expands it to cover comparisons to additional constats such asNone
.This reduces FP flow in cases such as
if x is None: return x
.