Allow repository rules to perform integrity checks
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the feature request:
Repository rules should be able to perform integrity checks or calculate the integrity of files.
Something like:
```starlark
# 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
Assessment
This issue has not been assessed yet.