[SECURITY] Fix CodeQL SM02196: suppress weak-hash warnings in negative test#204
Merged
elantiguamsft merged 1 commit intoJun 22, 2026
Conversation
…e test CodeQL flagged MD5.Create() and SHA1.Create() on line 145 of CoseHashEnvelopeTests.cs (cs/weak-crypto, SDL sdl-required). The test SignatureMatchesRejectsLegacyDigestAlgorithms deliberately uses MD5 and SHA1 as inputs to verify the library rejects legacy digest algorithms -- replacing them with SHA2 would defeat the purpose of the test. Added a trailing // CodeQL [SM02196] suppression matching the repo convention (see CoseSignTool/SignCommand.cs:1265 and 1307).
JeromySt
approved these changes
Jun 17, 2026
elantiguamsft
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Two CodeQL SM02196 ("Weak cryptography", SDL
sdl-required, important severity) findings flag the same line inCoseIndirectSignature.Tests/CoseHashEnvelopeTests.cs:145:SHA1.Create()(col 81-94)MD5.Create()(col 66-78)Why suppression, not replacement
The test is named
SignatureMatchesRejectsLegacyDigestAlgorithmsand is parameterized on[TestCase("md5")] [TestCase("sha1")]. Its explicit purpose is to verify the library rejects MD5 and SHA1 as payload digest algorithms. Replacing them with SHA2 would defeat the test entirely —SignatureMatcheswould returntrueinstead offalseand the assertion would invert.Change
One line, suppression-only:
The trailing
// CodeQL [SM02196] ...format matches the repo's existing convention (seeCoseSignTool/SignCommand.cs:1265and L1307).Validation
Documentation
cs/weak-crypto