Skip to content

🐛 fix parameter verifications in HMAC method - #439

Merged
ianardee merged 1 commit into
mainfrom
hmac-fixes
Sep 7, 2026
Merged

ianardee merged 1 commit into
mainfrom
hmac-fixes

Conversation

@ianardee

@ianardee ianardee commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Description

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires a change to the official Guide documentation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The HMAC validation updates still allow whitespace-only secret keys and include avoidable dead/culture-sensitive casing logic that should be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR tightens and expands HMAC signature validation behavior in BaseLocalResponse and updates the unit tests around local response parsing and job/error response parsing metadata to better reflect expected behavior.

Changes:

  • Adjusts IsValidHmacSignature parameter checks and adds additional HMAC validation cases in unit tests (null/empty/uppercase signature).
  • Updates XML documentation strings around local response constructors.
  • Refactors/renames several unit tests and updates [Trait] / [Fact(DisplayName=...)] metadata for clearer categorization.
File summaries
File Description
tests/Mindee.UnitTests/V2/Parsing/LocalResponseTest.cs Adds more IsValidHmacSignature assertions (null/empty/uppercase) and renames test methods.
tests/Mindee.UnitTests/V2/Parsing/JobTest.cs Updates test categorization metadata and moves helper method for readability.
tests/Mindee.UnitTests/V2/Parsing/ErrorResponseTest.cs Adds test categorization metadata and improves test display name.
src/Mindee/Parsing/BaseLocalResponse.cs Updates constructor XML docs and tightens HMAC signature validation logic.
Review details

Suppressed comments (2)

src/Mindee/Parsing/BaseLocalResponse.cs:133

  • The expectedSignature == "" guard is unreachable with the current GetHmacSignature implementation (it always returns a non-empty hex string). Keeping this branch adds dead code and makes the method harder to reason about.
            string expectedSignature = GetHmacSignature(secretKey);
            if (expectedSignature == "")
                return false;

src/Mindee/Parsing/BaseLocalResponse.cs:136

  • signature.ToLower() is culture-sensitive; for a header value that should be ASCII/hex, normalize using ToLowerInvariant() to avoid any locale-dependent behavior.
            byte[] actualBytes = Encoding.UTF8.GetBytes(signature.ToLower());
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Mindee/Parsing/BaseLocalResponse.cs Outdated
Comment thread src/Mindee/Parsing/BaseLocalResponse.cs
Comment thread tests/Mindee.UnitTests/V2/Parsing/LocalResponseTest.cs
@ianardee
ianardee force-pushed the hmac-fixes branch 2 times, most recently from 66d24a6 to be54dae Compare September 7, 2026 11:22
@ianardee ianardee changed the title 🐛 fix paramter verifications in HMAC method 🐛 fix parameter verifications in HMAC method Sep 7, 2026
@ianardee
ianardee merged commit 2c15ca8 into main Sep 7, 2026
28 checks passed
@ianardee
ianardee deleted the hmac-fixes branch September 7, 2026 14:11
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