Thank you for the warm welcome and for SonarQube! I have upgraded the SonarQube version to 9.9.0.65466 and can confirm that the issue still persists and is reproducible. I have also attached screenshots of SonarQube results and docker details here for your convenience.
Hey @Amit_Seal_Ami,
Thanks for reporting this issue.
Due to some limitations discussed in this ticket, S5547 does not look into the result of method calls (and I am not sure that we want to resolve expressions that include variables whose initialization we need to inspect).
However, because KeyGenerator is part of the standard library, we already have rules that cover the use of weak ciphers for key generation (eg S4426).
Does SonarQube raise other security issues on the snippet of code you submitted?
SonarQube does not report any other warnings. All the warnings counts are 0, when we checked.
To provide more context about what I am about to ask, my team is conducting academic research on Java Cryptographic API-related misuse. As you and Leonardo_Pilastri mentioned, there are several design decisions and philosophies in SonarQube that results in the false negatives I reported:
The analyzer avoids evaluating non-constant identifiers, even if they are statically determinable, which is motivated by,
SonarQube’s priority to not raise FPs.
Based on these, we have the following questions:
What factors motivated SonarQube to prioritize not raising FPs in this specific context, i.e., by not analyzing for non-constant identifiers?
Do you prioritize not raising FP for all four Clean Code attributes (Quality, Security, Maintainability, and Reliability) equally, or are there variations? For example, in this case, you mentioned that analyzing non-constant identifiers may raise FPs, but it is still worth investigating to reduce false negatives. Is this somewhat of an exception because it is related to security?
Are there any additional factors you consider when prioritizing the trade-off between FP and FN?
What’s the threshold SonarQube aims for when it comes to maintaining the percentage of FP, if there is any (even if informally)?
Please let us know what you think. Thanks again for your very valuable insight!