Unverified Commit 0d5f3d9c authored by weisd's avatar weisd Committed by GitHub
Browse files

Enhanced Checksum Support and Content Validation (#371)



* add content md5,sha256 check

* fix(s3s-fs):add  checksum_crc64nvme

* Update crates/s3s-e2e/src/basic.rs

Co-authored-by: default avatarCopilot <175728472+Copilot@users.noreply.github.com>

* Update crates/s3s-e2e/Cargo.toml

Co-authored-by: default avatarCopilot <175728472+Copilot@users.noreply.github.com>

* Update crates/s3s-e2e/Cargo.toml

Co-authored-by: default avatarCopilot <175728472+Copilot@users.noreply.github.com>

* fix(s3s-fs):add  checksum_crc64nvme

* fix(s3s-e2e):multipart upload remove checksum

* fix(s3s-e2e):multipart upload remove checksum

---------

Co-authored-by: default avatarCopilot <175728472+Copilot@users.noreply.github.com>
parent 4ba8c5c6
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ impl S3 for FileSystem {
            checksum_crc32c: checksum.checksum_crc32c,
            checksum_sha1: checksum.checksum_sha1,
            checksum_sha256: checksum.checksum_sha256,
            checksum_crc64nvme: checksum.checksum_crc64nvme,
            ..Default::default()
        };
        Ok(S3Response::new(output))
@@ -472,6 +473,7 @@ impl S3 for FileSystem {
            key,
            metadata,
            content_length,
            content_md5,
            ..
        } = input;

@@ -530,6 +532,16 @@ impl S3 for FileSystem {

        let md5_sum = hex(md5_hash.finalize());

        if let Some(content_md5) = content_md5 {
            let content_md5 = base64_simd::STANDARD
                .decode_to_vec(content_md5)
                .map_err(|_| s3_error!(InvalidArgument))?;
            let content_md5 = hex(content_md5);
            if content_md5 != md5_sum {
                return Err(s3_error!(BadDigest, "content_md5 mismatch"));
            }
        }

        let checksum = checksum.finalize();

        if let Some(trailers) = req.trailing_headers {
@@ -589,6 +601,7 @@ impl S3 for FileSystem {
            checksum_crc32c: checksum.checksum_crc32c,
            checksum_sha1: checksum.checksum_sha1,
            checksum_sha256: checksum.checksum_sha256,
            checksum_crc64nvme: checksum.checksum_crc64nvme,
            ..Default::default()
        };
        Ok(S3Response::new(output))
Loading