Skip to content

Update HashExpressionProcessors.java#6170

Open
JoanJaraBosch wants to merge 4 commits intovividus-framework:masterfrom
JoanJaraBosch:origin/3950
Open

Update HashExpressionProcessors.java#6170
JoanJaraBosch wants to merge 4 commits intovividus-framework:masterfrom
JoanJaraBosch:origin/3950

Conversation

@JoanJaraBosch
Copy link
Copy Markdown

@JoanJaraBosch JoanJaraBosch commented Oct 2, 2025

Summary by CodeRabbit

  • New Features
    • Added HMAC support to hash expressions, enabling key-based hashing alongside existing algorithms.
    • Added a 3-argument form (key + algorithm + input) to compute HMAC digests, returning hex-encoded results.
    • Improved validation and error messages when a key is required, while preserving existing non-HMAC behavior.

@JoanJaraBosch JoanJaraBosch requested a review from a team as a code owner October 2, 2025 07:18
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 2, 2025

Walkthrough

Adds HMAC support to hash expression processors by introducing a 3-argument calculateHash(key, algorithm, input) that computes HMAC when requested and standard hashing otherwise. The 2-argument calculateHash now rejects HMAC algorithms. A helper for HMAC computation and related imports are added. Non-HMAC and file-hash behavior remain unchanged.

Changes

Cohort / File(s) Summary
Hash expression processors
vividus/src/main/java/org/vividus/expression/HashExpressionProcessors.java
- Added 3-arg calculateHash(key, algorithm, input) with HMAC support and fallback to standard hashing
- Updated 2-arg calculateHash to disallow HMAC and throw IllegalArgumentException
- Introduced internal calculateHmac helper using Java crypto and hex encoding
- Added imports for HMAC and hex utilities
- Retained existing non-HMAC and file-hash behavior

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant U as Caller
    participant H as HashExpressionProcessors
    participant C as Java Crypto (Mac)
    Note over U,H: calculateHash(key, algorithm, input)

    U->>H: calculateHash(key, algorithm, input)
    alt algorithm is HMAC-*
        H->>H: calculateHmac(key, algorithm, input)
        H->>C: init Mac("Hmac<Alg>"), doFinal(input)
        C-->>H: raw bytes
        H->>H: hex-encode
        H-->>U: hmacHex
    else non-HMAC algorithm
        H->>H: standard hash(input)
        H-->>U: hashHex
    end
Loading
sequenceDiagram
    autonumber
    participant U as Caller
    participant H as HashExpressionProcessors
    Note over U,H: calculateHash(algorithm, input)

    U->>H: calculateHash(algorithm, input)
    alt algorithm is HMAC-*
        H-->>U: throw IllegalArgumentException (use 3-arg)
    else non-HMAC algorithm
        H->>H: standard hash(input)
        H-->>U: hashHex
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump my paw on hashing ground,
Now HMAC’s in, with keys around!
A whisk of Mac, a hexy shine,
Two args? Not for HMAC time.
Three hops later, secrets stay—
I nibble bytes and hash the day. 🐇🔐

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title simply states that the file was updated without specifying the substantive change, so it does not convey the main enhancement of adding HMAC support to the hash processor. Please revise the title to clearly describe the key change, for example “Add HMAC support to HashExpressionProcessors.calculateHash” so readers immediately understand the purpose of the update.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7db939d and 57f9d65.

📒 Files selected for processing (1)
  • vividus/src/main/java/org/vividus/expression/HashExpressionProcessors.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
vividus/src/main/java/org/vividus/expression/HashExpressionProcessors.java (1)
vividus-util/src/main/java/org/vividus/util/ResourceUtils.java (1)
  • ResourceUtils (35-229)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8d182 and 7db939d.

📒 Files selected for processing (1)
  • vividus/src/main/java/org/vividus/expression/HashExpressionProcessors.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
vividus/src/main/java/org/vividus/expression/HashExpressionProcessors.java (1)
vividus-util/src/main/java/org/vividus/util/ResourceUtils.java (1)
  • ResourceUtils (35-229)

Comment thread vividus/src/main/java/org/vividus/expression/HashExpressionProcessors.java Outdated
…cessors.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@JoanJaraBosch
Copy link
Copy Markdown
Author

hello @valfirst , @draker94 and @vkepin can you review it and tell me if it is ok or not and in case it is ok, merge it?

@valfirst
Copy link
Copy Markdown
Collaborator

valfirst commented Oct 6, 2025

@JoanJaraBosch the build is failed

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