Skip to content

test(java): add BouncyCastle digest edge-case coverage#419

Open
sachin9058 wants to merge 2 commits into
cbomkit:mainfrom
sachin9058:test/bouncycastle-digest-edge-cases
Open

test(java): add BouncyCastle digest edge-case coverage#419
sachin9058 wants to merge 2 commits into
cbomkit:mainfrom
sachin9058:test/bouncycastle-digest-edge-cases

Conversation

@sachin9058
Copy link
Copy Markdown
Contributor

This PR adds explicit regression coverage for additional BouncyCastle digest implementations that were already registered through BcDigests but did not have dedicated tests.

Added coverage

  • WhirlpoolDigest
  • TigerDigest
  • RIPEMD160Digest

What changed

  • Added BcDigestEdgeCasesTestFile with digest instantiations and detection assertions

  • Added BcDigestEdgeCasesTest

  • Verified detection and translation metadata for:

    • digest functionality
    • digest size
    • block size (where applicable)
    • iteration information (where applicable)

Validation

mvn -pl java -Dtest=BcDigestEdgeCasesTest test
mvn test -pl java

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

Signed-off-by: Sachin Kumar <sachinkumar905846@gmail.com>
@sachin9058 sachin9058 requested a review from a team as a code owner May 20, 2026 15:19
Copilot AI review requested due to automatic review settings May 20, 2026 15:19
@sachin9058
Copy link
Copy Markdown
Contributor Author

@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 BcDigests.

Covered digests:

  • WhirlpoolDigest
  • TigerDigest
  • RIPEMD160Digest

The focus is on improving explicit edge-case coverage and validating translation metadata without changing existing behavior.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +61 to +87
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants