Skip to content

Commit

Permalink
fix: actually verify payload digest when needed. (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
NGTmeaty authored Sep 14, 2024
1 parent fd03901 commit 7c0b7a6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ func verifyPayloadDigest(record *warc.Record, filepath string) (errorsCount int,
errorsCount++
return errorsCount, valid
}

if payloadDigest != payloadDigestSplitted[1] {
logger.Error("payload digests do not match", "file", filepath, "recordID", record.Header.Get("WARC-Record-ID"), "expected", payloadDigestSplitted[1], "got", payloadDigest)
valid = false
errorsCount++
return errorsCount, valid
}
} else if payloadDigestSplitted[0] == "sha256" {
payloadDigest := warc.GetSHA256Base16(resp.Body)
if payloadDigest == "ERROR" {
Expand All @@ -226,6 +233,13 @@ func verifyPayloadDigest(record *warc.Record, filepath string) (errorsCount int,
errorsCount++
return errorsCount, valid
}

if payloadDigest != payloadDigestSplitted[1] {
logger.Error("payload digests do not match", "file", filepath, "recordID", record.Header.Get("WARC-Record-ID"), "expected", payloadDigestSplitted[1], "got", payloadDigest)
valid = false
errorsCount++
return errorsCount, valid
}
} else {
logger.Error("WARC-Payload-Digest is not SHA1 or SHA256", "file", filepath, "recordID", record.Header.Get("WARC-Record-ID"))
valid = false
Expand Down

0 comments on commit 7c0b7a6

Please sign in to comment.