SONARPY-314 Rule S4790: Hashing data is security-sensitive#216
Conversation
95bf9be to
9fe3950
Compare
There was a problem hiding this comment.
Why using an immutable Set to then stream on it?! Please use:
Stream.of("a", "b").map(...There was a problem hiding this comment.
Same approach as before, no need for the intermediate ImmutableSet
There was a problem hiding this comment.
Rather than chained if-else-ifI would prefer to have a switch:
switch(node.getType()) {
case PythonGrammar.CALL_EXPR:
checkQuestionableHashingAlgorithm(node);
break;
case /*...*/ :
// ...
break;
default:
// do nothing - reacting on all the registered nodes
}There was a problem hiding this comment.
this deserve a comment, otherwise I would tend to remove it.
There was a problem hiding this comment.
don't you want to explicitly return here?
It sounds strange to me that we could raise 2 issues in one run (by reaching both line 128 and 135), but if you think it's OK, then fine.
There was a problem hiding this comment.
yes indeed, I agree. I'll add a return
There was a problem hiding this comment.
In case of parenthesis, TESTLIST_STAR_EXPR will still be the first child of EXPRESSION_STMT.
Parenthesis will be consumed lower in the grammar (in ATOM production rule) and at line 123 I'm taking the firstDescendant(PythonGrammar.ATTRIBUTE_REF).
I'm adding a test case to cover this.
However I just realized I won't raise an issue in this case:
foo.bar, mySettings.PASSWORD_HASHERS = value # Noncompliant
I will change my implementation to cover this case
There was a problem hiding this comment.
return symbol != null ? symbol.qualifiedName() : "";
There was a problem hiding this comment.
.filter(atom -> questionableDjangoHashers.contains(getQualifiedName(atom)))
.forEach(atom -> addIssue(atom, MESSAGE));9fe3950 to
fec5807
Compare
…les execution (#216) GitOrigin-RevId: c7c8ff947ad8efbb3f6d243ed1bf399ac64ba1b5
No description provided.