Skip to content

Commit 9fe8bb9

Browse files
committed
Add new tool package_validator validates RUNPATHS
package_validator enforces that we do not produce an DEB/RPM package with ELF files that cannot resolve their own dependencies. CMK-31459 Change-Id: I5b1cd1f5b793fb0f4c15cb78a27807e90d0a1ec3
1 parent bf40c6c commit 9fe8bb9

40 files changed

Lines changed: 9537 additions & 0 deletions

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ include("//bazel/module:rust/site.MODULE.bazel")
728728

729729
include("//bazel/module:rust/host.MODULE.bazel")
730730

731+
include("//bazel/module:rust/tools.MODULE.bazel")
732+
731733
include("//bazel/module:gazelle/go.MODULE.bazel")
732734

733735
include("//bazel/module:js.MODULE.bazel")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# tools_crates is for developer tools and test utilities that run on the host.
2+
# Unlike site_crates and host_crates, each tool is its own standalone Cargo
3+
# workspace and uses its own Cargo.lock. tools_crates keeps a single Bazel
4+
# lockfile for all such tools.
5+
tools_crates = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
6+
tools_crates.from_cargo(
7+
name = "tools_crates",
8+
cargo_lockfile = "//tests/packaging/package_validator:Cargo.lock",
9+
lockfile = "//:tools.Cargo.lock.bazel",
10+
manifests = ["//tests/packaging/package_validator:Cargo.toml"],
11+
supported_platform_triples = ["x86_64-unknown-linux-gnu"],
12+
)
13+
use_repo(tools_crates, "tools_crates")
14+
tools_crates.splicing_config(
15+
repositories = ["tools_crates"],
16+
resolver_version = "2",
17+
)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2+
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
3+
load("@tools_crates//:defs.bzl", "aliases", "all_crate_deps")
4+
5+
rust_library(
6+
name = "package_validator_lib",
7+
srcs = glob(
8+
["src/**/*.rs"],
9+
exclude = ["src/main.rs"],
10+
),
11+
aliases = aliases(),
12+
crate_name = "package_validator",
13+
edition = "2021",
14+
proc_macro_deps = all_crate_deps(proc_macro = True),
15+
deps = all_crate_deps(),
16+
)
17+
18+
rust_binary(
19+
name = "package_validator",
20+
srcs = [
21+
"src/args.rs",
22+
"src/main.rs",
23+
],
24+
aliases = aliases(),
25+
edition = "2021",
26+
proc_macro_deps = all_crate_deps(proc_macro = True),
27+
visibility = ["//visibility:public"],
28+
deps = all_crate_deps() + [":package_validator_lib"],
29+
)
30+
31+
rust_test(
32+
name = "unit_tests",
33+
size = "small",
34+
aliases = aliases(),
35+
crate = ":package_validator_lib",
36+
data = glob(["fixtures/**"]),
37+
proc_macro_deps = all_crate_deps(proc_macro = True),
38+
deps = all_crate_deps() + ["@rules_rust//tools/runfiles"],
39+
)
40+
41+
rust_test(
42+
name = "integration_tests",
43+
size = "small",
44+
srcs = ["tests/integration_test.rs"],
45+
aliases = aliases(),
46+
crate_name = "integration_test",
47+
data = glob(["fixtures/**"]),
48+
edition = "2021",
49+
proc_macro_deps = all_crate_deps(proc_macro = True),
50+
deps = all_crate_deps() + [
51+
":package_validator_lib",
52+
"@rules_rust//tools/runfiles",
53+
],
54+
)
55+
56+
build_test(
57+
name = "build_test",
58+
targets = [":package_validator"],
59+
)

0 commit comments

Comments
 (0)