test(java): add BouncyCastle digest edge-case coverage#419
Conversation
Signed-off-by: Sachin Kumar <sachinkumar905846@gmail.com>
|
@san-zrl Hi! I continued investigating BouncyCastle edge cases and opened a follow-up PR adding explicit regression coverage for additional digest implementations already registered through Covered digests:
The focus is on improving explicit edge-case coverage and validating translation metadata without changing existing behavior. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds new edge-case regression tests for Bouncy Castle digest detection/translation, validating that specific Digest implementations are mapped into the expected MessageDigest model nodes.
Changes:
- Added a JUnit test (
BcDigestEdgeCasesTest) that verifies detection store values and translated node structure for multiple BC digests. - Added a Sonar test input file (
BcDigestEdgeCasesTestFile) containing “Noncompliant” markers for Whirlpool, Tiger, and RIPEMD-160 digests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| java/src/test/java/com/ibm/plugin/rules/detection/bc/signer/BcDigestEdgeCasesTest.java | New unit test asserting expected detection + translation outputs for several BC digest implementations. |
| java/src/test/files/rules/detection/bc/signer/BcDigestEdgeCasesTestFile.java | New verifier input file creating findings for Whirlpool/Tiger/RIPEMD160 digests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (findingId == 0) { | ||
| /* | ||
| * Detection Store | ||
| */ | ||
| assertThat(detectionStore).isNotNull(); | ||
| assertThat(detectionStore.getDetectionValues()).hasSize(1); | ||
| assertThat(detectionStore.getDetectionValueContext()).isInstanceOf(DigestContext.class); | ||
| IValue<Tree> value0 = detectionStore.getDetectionValues().get(0); | ||
| assertThat(value0).isInstanceOf(ValueAction.class); | ||
| assertThat(value0.asString()).isEqualTo("WhirlpoolDigest"); | ||
|
|
||
| /* | ||
| * Translation | ||
| */ | ||
| assertThat(nodes).hasSize(1); | ||
|
|
||
| // MessageDigest | ||
| INode messageDigestNode = nodes.get(0); | ||
| assertThat(messageDigestNode.getKind()).isEqualTo(MessageDigest.class); | ||
| assertThat(messageDigestNode.getChildren()).hasSize(4); | ||
| assertThat(messageDigestNode.asString()).isEqualTo("Whirlpool"); | ||
|
|
||
| // Digest under MessageDigest | ||
| INode digestNode = messageDigestNode.getChildren().get(Digest.class); | ||
| assertThat(digestNode).isNotNull(); | ||
| assertThat(digestNode.getChildren()).isEmpty(); | ||
| assertThat(digestNode.asString()).isEqualTo("DIGEST"); |
Signed-off-by: Sachin Kumar <sachinkumar905846@gmail.com>
This PR adds explicit regression coverage for additional BouncyCastle digest implementations that were already registered through
BcDigestsbut did not have dedicated tests.Added coverage
WhirlpoolDigestTigerDigestRIPEMD160DigestWhat changed
Added
BcDigestEdgeCasesTestFilewith digest instantiations and detection assertionsAdded
BcDigestEdgeCasesTestVerified detection and translation metadata for:
Validation
Notes
The digest implementations were already registered in
BcDigests, but explicit edge-case coverage for these variants was missing. This PR focuses only on regression coverage and does not modify existing translation behavior.Related: #31