Repository navigation
[ABLD-525] Prevent bogus FIPS builds through Bazel - #59511
Conversation
### What does this PR do? Make every `--enable-bazel` build task refuse FIPS, whether requested through `--fips-mode`, the `fips` flavor or, for the cluster agent, `GOEXPERIMENT=boringcrypto`, instead of producing a non-FIPS binary. ### Motivation FIPS builds through `--enable-bazel` have been silently non-FIPS: they only add the `fips` flavor's build tags, while Bazel keeps upstream Go, `deps/go.MODULE.bazel` registering its toolchains ahead of `msgo`'s. For instance, building the secret-generic-connector with `--enable-bazel --fips-mode` yields a binary tagged `requirefips` with upstream Go and no OpenSSL backend, while the cluster-agent and `privateactionrunner` Bazel routes drop the FIPS request altogether. No CI job builds FIPS through `--enable-bazel`, and CI's symbol checks guard the shipped binaries, but nothing stopped a developer from producing such a binary. ### Describe how you validated your changes Checked that: - `installer.build`, `security-agent.build`, `cws-instrumentation.build` and `secret-generic-connector.build` with `--enable-bazel --fips-mode`, `otel-agent.build`, `process-agent.build` and `privateactionrunner.build` with `--enable-bazel --flavor fips`, and `cluster-agent.build --enable-bazel` with `GOEXPERIMENT=boringcrypto` fail fast, - `secret-generic-connector.build --enable-bazel` still builds, - `dda inv -- -e linter.python` and `dda inv -- -e invoke-unit-tests.run` for `omnibus` and `cluster_agent_helpers` pass. ### Additional Notes The cluster agent keys on `GOEXPERIMENT=boringcrypto`, since that is how its FIPS jobs request BoringCrypto.
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
The patch is correct. The new guards reject the unsupported FIPS build options before invoking Bazel, while preserving existing non-FIPS build paths. No actionable issues were found. Validation was limited to static review.
--enable-bazel cannot honor FIPS
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
The patch is correct. The new guards reject unsupported FIPS requests before invoking Bazel, while preserving existing non-FIPS build paths. No actionable issues were found. Validation was limited to code inspection; builds and tests were not run.
This comment has been minimized.
This comment has been minimized.
Static quality checks✅ Please find below the results from static quality gates 32 successful checks with minimal change (< 2 KiB)
|
--enable-bazel cannot honor FIPS### What does this PR do? Make the target platform's `//bazel/platforms:fips` constraint the only way to request a FIPS build, the FIPS platforms selecting the `msgo` SDK through their own `flags`, instead of the `fips` value of `//packages/agent:flavor`. To that end: - give `//bazel/platforms:crypto` a `:standard` default value, which `linux_default` now requires, so that it never overlaps `linux_fips`, - key `//packages/agent:fips` (formerly `fips_flavor`), `linux_fips` and the per-platform FIPS settings, as well as `@openssl`'s, on the constraint, - drop `fips` from the `//packages/agent:flavor` values, - name FIPS packages from the constraint in `package_naming.bzl`, - have the omnibus build helpers pass `--platforms=//bazel/platforms:<os>_<arch>_fips` instead of the flavor, - register a test toolchain for FIPS targets, so that `bazel test` works on FIPS platforms, - remove the macOS FIPS platforms, which no product uses. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal of `--enable-bazel` FIPS builds, which depends on it. ### Motivation `bazel build --platforms=//bazel/platforms:linux_x86_64_fips` built a non-FIPS binary, the platform's `:fips` constraint selecting nothing, while `--//packages/agent:flavor=fips` selected the FIPS build tags but kept the upstream Go SDK, silently producing a non-FIPS binary, which #59511 had to refuse. #58511 made `msgo` a Bazel toolchain, selected by `--@rules_go//go/toolchain:sdk_name=msgo`, so a FIPS platform can now carry both the constraint and that toolchain choice, making FIPS a property of the target platform only. ### Describe how you validated your changes Checked that, for `//cmd/agent:agent`: - `linux_x86_64_fips` builds with `msgo`, with the `requirefips` and `goexperiment.systemcrypto` tags, and `windows_x86_64_fips` with `msgo` and `goexperiment.systemcrypto` only, as the tasks do, - `linux_x86_64` and `windows_x86_64` keep the upstream SDK without these tags, - `linux_arm64_fips` selects `msgo`, checked on a pure-Go target since this x86-64 host has no arm64 C toolchain. Also checked that: - `//cmd/agent`, `//cmd/dogstatsd`, `//cmd/installer`, `//cmd/loader`, `//packages/agent/linux:debian`, `//packages/agent/dependencies`, `//packages/agent/product` and `@openssl//:openssl` analyze without ambiguous `select()` on `linux_x86_64` and `linux_x86_64_fips`, and `//cmd/agent`, `//cmd/dogstatsd` and `@openssl//:openssl` on `windows_x86_64` and `windows_x86_64_fips`, - `bazel test` passes on `//pkg/ebpf:verify_generated_files` with `--platforms=//bazel/platforms:linux_x86_64_fips`, - `//packages/rules` tests pass, the FIPS product names now coming from the constraint. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, native since Bazel 8, because deriving it from the constraint would take patching `go_transition`, `go_binary` using the only incoming transition a rule can have, or duplicating rules_go's `toolchain()` matrix. `linux_default` and `linux_fips` are made disjoint by the `:standard` default rather than by `select()` specialization, which doesn't see through the `config_setting_group` that `linux_default` uses since the `recorder` flavor. Passing the retired `--//packages/agent:flavor=fips` now fails the analysis of packaging targets, and leaves a bare Go binary consistently non-FIPS. The `package_naming.bzl` tests transition to a FIPS platform derived from the host, so that the host's C++ toolchain keeps resolving. The Python omnibus helper lower-cases `platform.machine()`, which is `AMD64` on Windows.
### What does this PR do? Make the target platform's `//bazel/platforms:fips` constraint the only way to request a FIPS build, the FIPS platforms selecting the `msgo` SDK through their own `flags`, instead of the `fips` value of `//packages/agent:flavor`. To that end: - key `//packages/agent:fips` (formerly `fips_flavor`), `linux_fips` and the per-platform FIPS settings, as well as `@openssl`'s, on the constraint, - drop `fips` from the `//packages/agent:flavor` values, - name FIPS packages from the constraint in `package_naming.bzl`, - have the omnibus build helpers pass `--platforms=//bazel/platforms:<os>_<arch>_fips` instead of the flavor, - register a test toolchain for FIPS targets, so that `bazel test` works on FIPS platforms, - remove the macOS FIPS platforms, which no product uses. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal of `--enable-bazel` FIPS builds, which depends on it. ### Motivation `bazel build --platforms=//bazel/platforms:linux_x86_64_fips` built a non-FIPS binary, the platform's `:fips` constraint selecting nothing, while `--//packages/agent:flavor=fips` selected the FIPS build tags but kept the upstream Go SDK, silently producing a non-FIPS binary, which #59511 had to refuse. #58511 made `msgo` a Bazel toolchain, selected by `--@rules_go//go/toolchain:sdk_name=msgo`, so a FIPS platform can now carry both the constraint and that toolchain choice, making FIPS a property of the target platform only. ### Describe how you validated your changes Checked that, for `//cmd/agent:agent`: - `linux_x86_64_fips` builds with `msgo`, with the `requirefips` and `goexperiment.systemcrypto` tags, and `windows_x86_64_fips` with `msgo` and `goexperiment.systemcrypto` only, as the tasks do, - `linux_x86_64` and `windows_x86_64` keep the upstream SDK without these tags, - `linux_arm64_fips` selects `msgo`, checked on a pure-Go target since this x86-64 host has no arm64 C toolchain. Also checked that: - `//cmd/agent`, `//cmd/dogstatsd`, `//cmd/installer`, `//cmd/loader`, `//packages/agent/linux:debian`, `//packages/agent/dependencies`, `//packages/agent/product` and `@openssl//:openssl` analyze without ambiguous `select()` on `linux_x86_64` and `linux_x86_64_fips`, and `//cmd/agent`, `//cmd/dogstatsd` and `@openssl//:openssl` on `windows_x86_64` and `windows_x86_64_fips`, - `bazel test` passes on `//pkg/ebpf:verify_generated_files` with `--platforms=//bazel/platforms:linux_x86_64_fips`, - `//packages/rules` tests pass, the FIPS product names now coming from the constraint. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, native since Bazel 8, because deriving it from the constraint would take patching `go_transition`, `go_binary` using the only incoming transition a rule can have, or duplicating rules_go's `toolchain()` matrix. `linux_fips` still takes precedence over `@platforms//os:linux` by `select()` specialization, as set up by #60181. Passing the retired `--//packages/agent:flavor=fips` now fails the analysis of packaging targets, and leaves a bare Go binary consistently non-FIPS. The `package_naming.bzl` tests transition to a FIPS platform derived from the host, so that the host's C++ toolchain keeps resolving. The Python omnibus helper lower-cases `platform.machine()`, which is `AMD64` on Windows.
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets.
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<arch>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<cpu>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting the #59511 refusal, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to refuse. Since #58511 made `msgo` a toolchain, a platform can carry both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The FIPS platforms set `sdk_name` through `platform(flags = ...)`, because deriving it from the constraint would take patching rules_go's `go_transition` or duplicating its `toolchain()` matrix. The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, #58511's `msgo` SDK building its OpenSSL backend without cgo through `ms_nocgo_opensslcrypto`, the default of `msgo` 1.27 (https://devblogs.microsoft.com/go/go-1-27-0-1-microsoft-build-now-available/), leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Prerequisites: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #59871 - #59875 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<cpu>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting #59511's guard against them, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to block. Since #58511 made `msgo` a toolchain, the platform now carries both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, #58511's `msgo` SDK building its OpenSSL backend without cgo through `ms_nocgo_opensslcrypto`, the default of `msgo` 1.27 (https://devblogs.microsoft.com/go/go-1-27-0-1-microsoft-build-now-available/), leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Groundwork: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #60181
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<cpu>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. :bulb: This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting #59511's guard against them, which will be addressed in: - #60204. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to block. Since #58511 made `msgo` a toolchain, the platform now carries both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, #58511's `msgo` SDK building its OpenSSL backend without cgo through `ms_nocgo_opensslcrypto`, the default of [`msgo` 1.27](https://devblogs.microsoft.com/go/go-1-27-0-1-microsoft-build-now-available/), leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Groundwork: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #60181 Co-authored-by: regis.desgroppes <[email protected]>
### What does this PR do? Give Linux FIPS Go binaries a RUNPATH to `$(INSTALL_DIR)/embedded/lib` with Go's `-r` in `dd_agent_go_binary`, so that `msgo` loads the embedded OpenSSL. Let `--enable-bazel` build tasks request FIPS through a `fips_backend` of `bazel()` and `build_binary_with_bazel`, which selects the FIPS target platform as `AGENT_FLAVOR=fips` already does, instead of failing as #59511 made them. This doesn't cover the installer's fallback to the stable version's libraries, which `tasks/installer.py` adds under `datadog-packages`. ### Motivation Bazel-built FIPS binaries had no RUNPATH, so `msgo` loaded the system OpenSSL, or panicked without one, which is why #59511 blocked FIPS `--enable-bazel` builds. Go's internal linker ignores the omnibus rpath, which `-r` restores, as #56351 does for the omnibus-built installer. ### Describe how you validated your changes - the FIPS installer, built without cgo, has `<install_dir>/embedded/lib` as `DT_RUNPATH` and loads `libcrypto.so.3` from there, falling back to the system one, - the FIPS agent, built with cgo, lists that directory first, and keeps it through `replace_prefix` in `--enable-bazel` agent builds, - non-FIPS binaries keep their RUNPATH, - `installer.build --enable-bazel --fips-backend msgo` and `process-agent.build --enable-bazel --flavor fips` build `msgo` FIPS binaries without `AGENT_FLAVOR`, while `--fips-backend boringcrypto` still fails. ### Additional Notes `agent.build`, `process-agent.build` and `otel-agent.build` pass their flavor's backend, the latter 2 no longer passing the `fips` flavor value #56440 retired.
### What does this PR do? Give Linux FIPS Go binaries a RUNPATH to their embedded libraries with Go's `-r` in `dd_agent_go_binary`, so that `msgo` loads the embedded OpenSSL. For "versioned" install directories, as under `datadog-packages`, have that RUNPATH fall back to the "stable" version's libraries, for the installer, which an upgrade runs _before its version is unpacked_. :bulb: This is the last prerequisite to lifting #59511's guard against Bazel-built FIPS binaries, which #60204 will do. ### Motivation Bazel-built FIPS binaries had no RUNPATH to the embedded libraries, so `msgo` `dlopen`ed OpenSSL from the default search path, loading the **system** one (or panicking without one). Omnibus' `CGO_LDFLAGS`, whose `-rpath` the external linker honors for cgo binaries, never reach Bazel, whose own rpath only lists its `$ORIGIN`-relative solib directories, while Go's internal linker, which cgo-less binaries go through, ignores such flags anyway. Go's `-r` sets the search path whichever linker writes it, as #56351 does for the omnibus-built installer, listing both directories since #57045's `patchelf --set-rpath` of the bootstrap copy **segfaults** on such a binary once stripped. ### Describe how you validated your changes - the FIPS installer has `<install_dir>/embedded/lib` as `DT_RUNPATH` and loads `libcrypto.so.3` from there, - in a versioned install directory, its RUNPATH then lists the stable version's libraries, from which it loads `libcrypto.so.3` when its own version lacks it, - the FIPS agent uses cgo for `rtloader`, so the external linker writes its rpath: those directories come first, then Bazel's solib ones, - `replace_prefix`, which `--enable-bazel` agent builds run, keeps `<install_dir>/embedded/lib` in that rpath, - non-FIPS binaries keep their RUNPATH. ### Additional Notes The RUNPATH comes from an `EMBEDDED_LIB_DIRS` make variable of `//bazel/rules/variables`, which already derives `AGENT_PACKAGE_VERSION` from the install directory.
### What does this PR do? Give Linux FIPS Go binaries a RUNPATH to their embedded libraries with Go's `-r` in `dd_agent_go_binary`, so that `msgo` loads the embedded OpenSSL. For "versioned" install directories, as under `datadog-packages`, have that RUNPATH fall back to the "stable" version's libraries, for the installer, which an upgrade runs _before its version is unpacked_. :bulb: This is the last prerequisite to lifting #59511's guard against Bazel-built FIPS binaries, which #60204 will do. ### Motivation Bazel-built FIPS binaries had no RUNPATH to the embedded libraries, so `msgo` `dlopen`ed OpenSSL from the default search path, loading the **system** one (or panicking without one). Omnibus' `CGO_LDFLAGS`, whose `-rpath` the external linker honors for cgo binaries, never reach Bazel, whose own rpath only lists its `$ORIGIN`-relative solib directories, while Go's internal linker, which cgo-less binaries go through, ignores such flags anyway. Go's `-r` sets the search path whichever linker writes it, as #56351 does for the omnibus-built installer, listing both directories since #57045's `patchelf --set-rpath` of the bootstrap copy **segfaults** on such a binary once stripped. ### Describe how you validated your changes - the FIPS installer has `<install_dir>/embedded/lib` as `DT_RUNPATH` and loads `libcrypto.so.3` from there, - in a versioned install directory, its RUNPATH then lists the stable version's libraries, from which it loads `libcrypto.so.3` when its own version lacks it, - the FIPS agent uses cgo for `rtloader`, so the external linker writes its rpath: those directories come first, then Bazel's solib ones, - `replace_prefix`, which `--enable-bazel` agent builds run, keeps `<install_dir>/embedded/lib` in that rpath, - non-FIPS binaries keep their RUNPATH. ### Additional Notes The RUNPATH comes from an `EMBEDDED_LIB_DIRS` make variable of `//bazel/rules/variables`, which already derives `AGENT_PACKAGE_VERSION` from the install directory.
…#60334) ### What does this PR do? Give Linux FIPS Go binaries a RUNPATH to their embedded libraries with Go's `-r` in `dd_agent_go_binary`, so that `msgo` loads the embedded OpenSSL. For "versioned" install directories, as under `datadog-packages`, have that RUNPATH fall back to the "stable" version's libraries, for the installer, which an upgrade runs _before its version is unpacked_. This is the last prerequisite to lifting #59511's guard against Bazel-built FIPS binaries, which #60204 will do. ### Motivation Bazel-built FIPS binaries had no RUNPATH to the embedded libraries, so `msgo` `dlopen`ed OpenSSL from the default search path, loading the **system** one (or panicking without one). Omnibus' `CGO_LDFLAGS`, whose `-rpath` the external linker honors for cgo binaries, never reach Bazel, whose own rpath only lists its `$ORIGIN`-relative solib directories, while Go's internal linker, which cgo-less binaries go through, ignores such flags anyway. Go's `-r` sets the search path whichever linker writes it, as #56351 does for the omnibus-built installer, listing both directories since #57045's `patchelf --set-rpath` of the bootstrap copy **segfaults** on such a binary: - NixOS/patchelf#146 - NixOS/patchelf#152 - NixOS/patchelf#446 - NixOS/patchelf#674 - NixOS/patchelf#672 - NixOS/patchelf#623 💡 the PR/commit is therefore meant to be reverted when `patchelf` no longer exhibits the issue. ### Describe how you validated your changes - the FIPS installer has `<install_dir>/embedded/lib` as `DT_RUNPATH` and loads `libcrypto.so.3` from there, - in a versioned install directory, its RUNPATH then lists the stable version's libraries, from which it loads `libcrypto.so.3` when its own version lacks it, - the FIPS agent uses cgo for `rtloader`, so the external linker writes its rpath: those directories come first, then Bazel's solib ones, - `replace_prefix`, which `--enable-bazel` agent builds run, keeps `<install_dir>/embedded/lib` in that rpath, - non-FIPS binaries keep their RUNPATH. ### Additional Notes The RUNPATH comes from an `EMBEDDED_LIB_DIRS` make variable of `//bazel/rules/variables`, which already derives `AGENT_PACKAGE_VERSION` from the install directory. Co-authored-by: regis.desgroppes <[email protected]>
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through a `fips_backend` of `bazel()` and `build_binary_with_bazel`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, including `go_build`'s, which then always runs `@rules_go//go`, the FIPS target platform selecting `msgo`. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. Explicit is better than implicit: the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. ### Describe how you validated your changes - `installer.build --enable-bazel --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--enable-bazel --flavor fips`, build `msgo` FIPS binaries without `AGENT_FLAVOR`, the FIPS target platform applying to both their `build` and `cquery`, - `--fips-backend boringcrypto` still fails, - `bazel()` selects the FIPS target platform for the `msgo` backend only, and fails on `AGENT_FLAVOR=fips` without it, as `dogstatsd.build` then shows, - `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds through `@rules_go//go` a binary with `msgo`'s OpenSSL backend, - the `bazel()` calls FIPS omnibus builds reach, which `go_build`, `schema.compress`, `build_libpcap` and the Windows resource helpers make, pass the build's backend. ### Additional Notes `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, `process-agent.build` and `otel-agent.build` no longer passing a `//packages/agent:flavor` their targets don't read, which `bazel()` adds from `AGENT_FLAVOR` anyway. `agent.build` also passes it to `rtloader.install-with-bazel`, so that local FIPS builds get FIPS `rtloader` and CPython. `build_binary_with_bazel` now rejects `boringcrypto`, which `go_build` keeps running through the upstream `go` tool. `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, omnibus' FIPS symbol check running `@rules_go//go tool nm` with the FIPS target platform its `omnibazel_flags` already carry.
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through a `fips_backend` of `bazel()` and `build_binary_with_bazel`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. Explicit is better than implicit: the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - `installer.build --enable-bazel --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--enable-bazel --flavor fips`, build `msgo` FIPS binaries without `AGENT_FLAVOR`, the FIPS target platform applying to both their `build` and `cquery`, - `--fips-backend boringcrypto` still fails, - `bazel()` selects the FIPS target platform for the `msgo` backend only, and fails on `AGENT_FLAVOR=fips` without it, as `dogstatsd.build` then shows, - `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds through `@rules_go//go` a binary with `msgo`'s OpenSSL backend, - the `bazel()` calls FIPS omnibus builds reach, which `go_build`, `schema.compress`, `build_libpcap`, `build_object_files` and the Windows resource helpers make, pass the build's backend. ### Additional Notes `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, `process-agent.build` and `otel-agent.build` no longer passing a `//packages/agent:flavor` their targets don't read, which `bazel()` adds from `AGENT_FLAVOR` anyway. `agent.build` also passes it to `rtloader.install-with-bazel`, so that local FIPS builds get FIPS `rtloader` and CPython. `build_binary_with_bazel` now rejects `boringcrypto`, which `go_build` keeps running through the upstream `go` tool. `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, omnibus' FIPS symbol check running `@rules_go//go tool nm` with the FIPS target platform its `omnibazel_flags` already carry.
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `secret-generic-connector.build --fips-backend boringcrypto`, as CI runs it, one with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `go_build` selects through `GOEXPERIMENT` alone, passing no backend, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `secret-generic-connector.build --fips-backend boringcrypto`, as CI runs it, one with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `go_build` selects through `GOEXPERIMENT` alone, passing no backend, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.for_bazel()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.strip_boringcrypto()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus _still_ sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than thrashing Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call _guessing_ it from the environment. Developers then get exactly what their CLI arguments request, without having to tweak environment variables. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.strip_boringcrypto()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode (#60204) 🫤 _Sorry for the number of touched files, hence of requested reviewers: this structural change is needed to guard against builds mixing non-FIPS, `msgo`-based FIPS and `boringcrypto`-based FIPS. The situation will gradually improve as subsequent `bazel()` calls get inlined as 1st-class targets in `BUILD.bazel` files, on the one hand, and as Bazel gets a proper Go SDK with `boringcrypto`, on the other hand._ ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus _still_ sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`[^1], which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than thrashing Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call _guessing_ it from the environment. Developers then get exactly what their CLI arguments request, without having to tweak environment variables. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.strip_boringcrypto()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm`[^1] with the FIPS target platform of its `omnibazel_flags`. [^1]: whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way `rules_go` means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk Co-authored-by: regis.desgroppes <[email protected]>
What does this PR do?
Make every
--enable-bazelbuild task refuse FIPS, whether requested through--fips-mode, thefipsflavor or, for the cluster agent,GOEXPERIMENT=boringcrypto, instead of producing a non-FIPS binary.Motivation
FIPS builds through
--enable-bazelhave been silently non-FIPS: they only add thefipsflavor's build tags, while Bazel keeps upstream Go,deps/go.MODULE.bazelregistering its toolchains ahead ofmsgo's.For instance, building the secret-generic-connector with
--enable-bazel --fips-modeyields a binary taggedrequirefipswith upstream Go and no OpenSSL backend, while the cluster-agent andprivateactionrunnerBazel routes drop the FIPS request altogether.No CI job builds FIPS through
--enable-bazel(yet), and CI's symbol checks guard the shipped binaries, but nothing else stopped from producing such an inconsistent binary in the first place.Describe how you validated your changes
Checked that:
installer.build,security-agent.build,cws-instrumentation.buildandsecret-generic-connector.buildwith--enable-bazel --fips-mode,otel-agent.build,process-agent.buildandprivateactionrunner.buildwith--enable-bazel --flavor fips, andcluster-agent.build --enable-bazelwithGOEXPERIMENT=boringcryptofail fast,secret-generic-connector.build --enable-bazelstill builds,dda inv -- -e linter.pythonanddda inv -- -e invoke-unit-tests.runforomnibusandcluster_agent_helperspass.Additional Notes
The cluster agent keys on
GOEXPERIMENT=boringcrypto, since that is how its FIPS jobs request BoringCrypto.