bazelbuild/bazel

Allow repository rules to perform integrity checks

Open

#15,759 opened on Jun 28, 2022

View on GitHub
 (4 comments) (0 reactions) (2 assignees)Java (4,465 forks)batch import
P2help wantedteam-ExternalDepstype: feature request

Repository metrics

Stars
 (25,384 stars)
PR merge metrics
 (Avg merge 22d 20h) (77 merged PRs in 30d)

Description

Description of the feature request:

Repository rules should be able to perform integrity checks or calculate the integrity of files.

Something like:

# where ctx is repository_ctx

integrity = ctx.calculate_integrity(file = "some_file.txt")

# the format of the integrity object could be:
integrity == struct(
    sha1 = "",
    sha256 = "",
    sha384 = "",
    sha512 = "",
)

ctx.verify_integrity(
    file = "some_file.txt",
    integrity = "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC",
)

Alternatively, there could be just one ctx.integrity function which will both calculate and verify depending on whether the integrity attribute is given?

What underlying problem are you trying to solve with this feature?

There are cases where resources cannot be fetched over HTTP and external tools must be used. In such case, it would be nice to have a native way to verify integrity without having to rely on the host to have sha256sum, openssl, etc installed.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

5.2.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

Not much.

https://github.com/bazelbuild/bazel/issues/7323

Any other information, logs, or outputs that you want to share?

No response

Contributor guide