Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.3.0] Ignore hash string casing #18414

Merged
merged 3 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.build.lib.bazel.repository.downloader;

import com.google.common.base.Ascii;
import com.google.common.hash.HashCode;
import com.google.devtools.build.lib.bazel.repository.cache.RepositoryCache.KeyType;
import java.util.Base64;
Expand Down Expand Up @@ -44,7 +45,7 @@ public static Checksum fromString(KeyType keyType, String hash) throws InvalidCh
if (!keyType.isValid(hash)) {
throw new InvalidChecksumException(keyType, hash);
}
return new Checksum(keyType, HashCode.fromString(hash));
return new Checksum(keyType, HashCode.fromString(Ascii.toLowerCase(hash)));
}

/** Constructs a new Checksum from a hash in Subresource Integrity format. */
Expand Down
16 changes: 16 additions & 0 deletions src/test/shell/bazel/external_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,22 @@ EOF
assert_contains "test content" "${base_external_path}/test_dir/test_file"
}

function test_http_archive_upper_case_sha() {
cat >> $(create_workspace_with_default_repos WORKSPACE) <<EOF
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = 'test_zstd_repo',
url = 'file://$(rlocation io_bazel/src/test/shell/bazel/testdata/zstd_test_archive.tar.zst)',
sha256 = '12B0116F2A3C804859438E102A8A1D5F494C108D1B026DA9F6CA55FB5107C7E9',
build_file_content = 'filegroup(name="x", srcs=glob(["*"]))',
)
EOF
bazel build @test_zstd_repo//...

base_external_path=bazel-out/../external/test_zstd_repo
assert_contains "test content" "${base_external_path}/test_dir/test_file"
}

function test_http_archive_no_server() {
cat >> $(create_workspace_with_default_repos WORKSPACE) <<EOF
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Expand Down