bazelbuild/bazel

Allow repository rules to perform integrity checks

Open

#15,759 建立於 2022年6月28日

在 GitHub 查看
 (4 留言) (0 反應) (2 負責人)Java (4,465 fork)batch import
P2help wantedteam-ExternalDepstype: feature request

倉庫指標

Star
 (25,384 star)
PR 合併指標
 (平均合併 22天 20小時) (30 天內合併 77 個 PR)

描述

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

貢獻者指南