Skip to content

refactor: Potential fixes for 5 code quality findings in src/aes.rs#808

Merged
Pr0methean merged 7 commits into
masterfrom
ai-findings-autofix/src-aes.rs
May 4, 2026
Merged

refactor: Potential fixes for 5 code quality findings in src/aes.rs#808
Pr0methean merged 7 commits into
masterfrom
ai-findings-autofix/src-aes.rs

Conversation

@Pr0methean

Copy link
Copy Markdown
Member

This PR applies 5/5 suggestions from code quality AI findings.

Pr0methean and others added 5 commits May 3, 2026 17:28
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
@Pr0methean Pr0methean changed the title Potential fixes for 5 code quality findings refactor: Potential fixes for 5 code quality findings in src/aes.rs May 4, 2026

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

This PR applies 5 code quality improvements to src/aes.rs. Most changes are working improvements to code clarity and correctness:

Working improvements:

  • Simplified module path reference (line 38)
  • Simplified Zeroizing type from Box<[u8]> to Vec<u8> (line 208)
  • Enhanced error reporting in AesReader::validate (lines 224-228)
  • Replaced assert! with debug_assert! and added explicit runtime check (lines 302-311)

⚠️ Issue found:

  • Inconsistent error handling (line 387): The writer discards HMAC initialization error details while the reader includes them, making debugging inconsistent

Recommendation: Address the error handling inconsistency before merge to maintain consistent debugging capabilities across the codebase.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread src/aes.rs
@Pr0methean
Pr0methean marked this pull request as ready for review May 4, 2026 00:30
@Pr0methean
Pr0methean enabled auto-merge May 4, 2026 00:30
@Pr0methean Pr0methean added this to the 9.0.0 milestone May 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request simplifies internal types by using Zeroizing<Vec> instead of boxed slices and cleans up path references. It also updates error handling for HMAC initialization and replaces a hard assertion with a runtime check for finalized states. Feedback indicates that the new check for finalized HMACs is redundant due to existing control flow logic. Additionally, a regression was identified where error details were removed from an HMAC initialization failure message, creating inconsistency with other improvements in the same PR.

Comment thread src/aes.rs
Comment on lines 302 to 311
);
if self.finalized {
return Err(Error::new(
ErrorKind::InvalidData,
"Tried to use an already finalized HMAC",
));
}
self.finalized = true;

// Zip uses HMAC-Sha1-80, which only uses the first half of the hash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The debug_assert! and the subsequent if self.finalized check are redundant. Because of the early return at line 284 (if self.data_remaining == 0 { return Ok(0); }), this block is only reachable the first time self.data_remaining reaches zero during a read call. At that point, self.finalized is guaranteed to be false. Any subsequent calls to read will return at line 284 before reaching this logic.

Comment thread src/aes.rs
@Pr0methean Pr0methean mentioned this pull request May 4, 2026
2 tasks
@Pr0methean
Pr0methean added this pull request to the merge queue May 4, 2026
Merged via the queue into master with commit 789ecfa May 4, 2026
133 checks passed
@Pr0methean
Pr0methean deleted the ai-findings-autofix/src-aes.rs branch May 4, 2026 10:59
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.

1 participant