SONARJAVA-6939 Make S4426 key sizes configurable via rule property - #6147
Conversation
This comment has been minimized.
This comment has been minimized.
- Add minimumKeySizes @RuleProperty (format: "RSA:4096,AES:256") that patches the defaults — only listed algorithms are overridden, others keep their default values - Add EC:224 to defaults; EC via KeyPairGenerator.initialize(int) is now also checked alongside the existing ECGenParameterSpec path - Extract default key sizes, parsing, and EC curve pattern into CryptographicKeySizeConfiguration in sonar-analyzer-commons. Real version number will be bumped after analyzer-commons' release. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
9c9c619 to
c4dc49f
Compare
Code Review 👍 Approved with suggestions 2 closed / 3 findings🟡 Medium risk · Configurable cryptographic key-size thresholds change security-analysis behavior across algorithms Adds configurable key size thresholds for rule S4426 via a 💡 Quality: defaultValue shows full list but semantics are patch-only📄 java-checks/src/main/java/org/sonar/java/checks/security/CryptographicKeySizeCheck.java:49-54 The property advertises Leave the parameter empty by default so the displayed value only contains user overrides, and spell out the defaults plus the patch semantics in the description✅ 2 closed✅ Bug: pom pins analyzer-commons to unreleased 2.33-SNAPSHOT
Closed: Edge Case: minimumKeySizes parsed per file with no error handling
🤖 Prompt for agentsReview coverage🧪 Functional validation No results 📋 Rules No rules evaluated 🤖 Auto-approval Not enabled · Set up OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
| effectiveKeySizeMap = CryptographicKeySizeConfiguration.effectiveKeySizes(minimumKeySizes); | ||
| } | ||
| return effectiveKeySizeMap; | ||
| } |
There was a problem hiding this comment.
Checked CryptographicKeySizeConfiguration.parseKeySizes in analyzer-commons — you're right. Malformed pairs like RSA:abc or RSA=4096 are caught internally (NumberFormatException is swallowed, and entries that don't split into exactly 2 parts are just skipped), so nothing ever throws out of the visitor. The "throws per file" part of the finding doesn't hold. The remaining point — invalid entries are silently dropped with no diagnostic — is a deliberate design choice in analyzer-commons rather than a bug here, so no code change needed on this point.
|




The related changes in analyzer-commons is visible here.