SONARPY-489 Rule S2092: Creating cookies without the "secure" flag is security-sensitive#548
Conversation
16204c5 to
34be11e
Compare
34be11e to
d6f9167
Compare
d6f9167 to
8594962
Compare
There was a problem hiding this comment.
If I understood correctly, we won't cover this case at first, so I guess it might be worth updating the rule description.
There was a problem hiding this comment.
This implementation seems to assume the secure flag will always be passed as a keyword argument, with a risk of FP if it's passed as a positional argument. I haven't checked for django but I believe it's possible to use positional arguments with flask at least.
Would you consider accounting for positional arguments as well to avoid those FP (maybe by doing something similar to PredictableSaltCheck) ?
There was a problem hiding this comment.
Yes good point, I'll check for positional argument
There was a problem hiding this comment.
I think you forgot to rename this variable.
There was a problem hiding this comment.
Indeed, thanks! :)
There was a problem hiding this comment.
Just a thought: do you think it would actually be feasible to raise on cases like:
cookie['c1'] = 'value' # FN
by checking whether the cookie symbol has another assignment usage with the same c1 subscript as well as a secure one?
Maybe it's not worth doing as I believe this is not the usual way to set cookies and it might be more complex to do than it looks, but I prefer mentioning it, feel free to disregard this!
There was a problem hiding this comment.
That's a fair point. However I have the feeling that the value doesn't justify the extra complexity. I suggest to create a ticket to keep track of this FN.
There was a problem hiding this comment.
Ticket created https://jira.sonarsource.com/browse/SONARPY-577
guillaume-dequenne
left a comment
There was a problem hiding this comment.
Just a comment about Optional#orElse, otherwise lgtm
There was a problem hiding this comment.
Could you use Optional#orElseGet instead of orElse ? As the latter is always evaluated no matter whether the former is present or not.
There was a problem hiding this comment.
good catch! thanks!
… security-sensitive
e426190 to
5879569
Compare
GitOrigin-RevId: 6f869848853e50be065ae5cb257c74c3691001d0
GitOrigin-RevId: 6f869848853e50be065ae5cb257c74c3691001d0
No description provided.