Validate file hashes using the configured hash algorithm - #1539
Open
Arpit Jain (arpitjain099) wants to merge 1 commit into
Open
Arpit Jain (arpitjain099) wants to merge 1 commit into
Arpit Jain (arpitjain099) wants to merge 1 commit into
Conversation
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This branch has not been deployed
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.
Summary
ConcurrentSha256HashValidatoralways pulls the SHA256 checksum out ofInternalSbomFileInfo, butFileHasherhashes files with whatever-HashAlgorithmthe caller passed. Validate an SBOM whose files only carry SHA1 checksums with-HashAlgorithm sha1and both sides come back null,string.Equals(null, null, ...)returns true, and every file is reported as validated without a single byte being compared.I hit this with a tampered file and a SHA1-only manifest. Before the change
validate ... -HashAlgorithm sha1printedResult: SuccesswithFilesSuccessfulCount: 1; after it, the same run reportsFailurewithFilesFailedCount: 1, and an untampered copy of the same tree still passes.Changes
IConfigurationin the validator and look upconfiguration.HashAlgorithm, falling back to SHA256 when it is not set.HashValidatoralready takes the configuration this way.SbomValidationWorkflowFactory.The class name still says Sha256 and is now misleading. I left it alone to keep the diff reviewable, happy to rename it in this PR if you would rather.
dotnet test test/Microsoft.Sbom.Api.Testsis green, 369 passed.