Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DRA FIPS artifacts to package pipeline #4574

Merged
merged 13 commits into from
Mar 25, 2025
Merged
54 changes: 54 additions & 0 deletions .buildkite/pipeline.package.mbp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@ steps:
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"

- label: "Package FIPS x86_64 snapshot"
if: "build.env('VERSION_QUALIFIER') == null"
key: "package-fips-x86-64-snapshot"
command: ".buildkite/scripts/package.sh snapshot"
env:
FIPS: "true"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"

- label: "Package FIPS x86_64 staging"
key: "package-fips-x86-64-staging"
command: |
source .buildkite/scripts/version_qualifier.sh
.buildkite/scripts/package.sh staging
env:
FIPS: "true"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"

- label: "Package aarch64 snapshot"
if: "build.env('VERSION_QUALIFIER') == null"
key: "package-arm-snapshot"
Expand All @@ -47,6 +70,29 @@ steps:
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.2xlarge"

- label: "Package FIPS aarch64 snapshot"
if: "build.env('VERSION_QUALIFIER') == null"
key: "package-fips-arm-snapshot"
command: ".buildkite/scripts/package.sh snapshot"
env:
FIPS: "true"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.2xlarge"

- label: "Package FIPS aarch64 staging"
key: "package-fips-arm-staging"
command: |
source .buildkite/scripts/version_qualifier.sh
.buildkite/scripts/package.sh staging
env:
FIPS: "true"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.2xlarge"

- label: "DRA snapshot"
if: "${FILE_EXISTS_IN_REPO} && build.env('VERSION_QUALIFIER') == null"
key: "dra-snapshot"
Expand All @@ -58,8 +104,12 @@ steps:
depends_on:
- step: "package-x86-64-snapshot"
allow_failure: false
- step: "package-fips-x86-64-snapshot"
allow_failure: false
- step: "package-arm-snapshot"
allow_failure: false
- step: "package-fips-arm-snapshot"
allow_failure: false

- label: "DRA release staging"
# we don't usually build staging from the main branch, but we exceptionally allow it for prereleases
Expand All @@ -76,5 +126,9 @@ steps:
depends_on:
- step: "package-x86-64-staging"
allow_failure: false
- step: "package-fips-x86-64-staging"
allow_failure: false
- step: "package-arm-staging"
allow_failure: false
- step: "package-fips-arm-staging"
allow_failure: false
4 changes: 4 additions & 0 deletions .buildkite/scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ if [[ ${PLATFORM_TYPE} == "arm" || ${PLATFORM_TYPE} == "aarch64" ]]; then
PACKAGES="docker"
fi

if [[ ${FIPS} == "true" ]]; then
export FIPS=true
fi

add_bin_path
with_go
with_mage
Expand Down
6 changes: 3 additions & 3 deletions .buildkite/scripts/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
set -euo pipefail

FLEET_SERVER_VERSION=${1:?"Fleet Server version is needed"}
FILE_PREFIX="build/distributions/fleet-server-${FLEET_SERVER_VERSION}-"

PLATFORM_FILES=(darwin-aarch64.tar.gz darwin-x86_64.tar.gz linux-arm64.tar.gz linux-x86_64.tar.gz windows-x86_64.zip)
if [ "$FIPS" = "true" ] ; then
PLATFORM_FILES=(linux-arm64-fips.tar.gz linux-x86_64-fips.tar.gz)
PLATFORM_FILES=(linux-arm64.tar.gz linux-x86_64.tar.gz)
FILE_PREFIX="build/distributions/fleet-server-fips-${FLEET_SERVER_VERSION}-"
fi

#make release

FILE_PREFIX="build/distributions/fleet-server-${FLEET_SERVER_VERSION}-"

RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.fips
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ RUN addgroup --gid 1000 fleet-server && \
USER fleet-server

COPY --chown=fleet-server:fleet-server --chmod=644 fleet-server.yml /etc/fleet-server.yml
COPY --chown=fleet-server:fleet-server --chmod=555 --from=builder /go/src/github.com/elastic/fleet-server/build/binaries/fleet-server-${VERSION}-${TARGETOS:-linux}-*-fips/fleet-server /usr/bin/fleet-server
COPY --chown=fleet-server:fleet-server --chmod=555 --from=builder /go/src/github.com/elastic/fleet-server/build/binaries/fleet-server-fips-${VERSION}-${TARGETOS:-linux}-*/fleet-server /usr/bin/fleet-server

ENV GOFIPS=1
ENV GODEBUG=fips140=on

CMD [ "/usr/bin/fleet-server", "-c", "/etc/fleet-server.yml" ]
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ else
VERSION=${DEFAULT_VERSION}
endif

DOCKER_IMAGE?=docker.elastic.co/fleet-server/fleet-server
DOCKER_PLATFORMS ?= linux/amd64 linux/arm64
# defing the docker image tag used for stand-alone fleet-server images
# only want to define the tag if none is specified, this allows an invocation like
Expand All @@ -61,11 +62,7 @@ DOCKER_IMAGE_TAG?=${VERSION}
ifeq "${DEV}" "true"
DOCKER_IMAGE_TAG:=${DOCKER_IMAGE_TAG}-dev
endif
ifeq "${FIPS}" "true"
DOCKER_IMAGE_TAG:=${DOCKER_IMAGE_TAG}-fips
endif
endif
DOCKER_IMAGE?=docker.elastic.co/fleet-server/fleet-server

PLATFORM_TARGETS=$(addprefix release-, $(PLATFORMS))
COVER_TARGETS=$(addprefix cover-, $(PLATFORMS))
Expand Down Expand Up @@ -94,10 +91,11 @@ GOFIPSEXPERIMENT?=
FIPSSUFFIX=
ifeq "${FIPS}" "true"
BUILDER_IMAGE=fleet-server-fips-builder:${GO_VERSION}
DOCKER_IMAGE:=docker.elastic.co/fleet-server/fleet-server-fips
STANDALONE_DOCKERFILE=Dockerfile.fips
PLATFORMS = linux/amd64 linux/arm64
gobuildtags += requirefips
GOFIPSEXPERIMENT=GOEXPERIMENT=systemcrypto
GOFIPSEXPERIMENT=GOEXPERIMENT=systemcrypto CGO_ENABLED=1
FIPSSUFFIX=-fips
endif

Expand Down Expand Up @@ -148,7 +146,7 @@ $(COVER_TARGETS): cover-%: ## - Build a binary with the -cover flag for integrat
$(eval $@_GO_ARCH := $(lastword $(subst /, ,$(lastword $(subst cover-, ,$@)))))
$(eval $@_ARCH := $(TARGET_ARCH_$($@_GO_ARCH)))
$(eval $@_BUILDMODE:= $(BUILDMODE_$($@_OS)_$($@_GO_ARCH)))
GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -cover -coverpkg=./... -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" $($@_BUILDMODE) -o build/cover/fleet-server-$(VERSION)-$($@_OS)-$($@_ARCH)$(FIPSSUFFIX)/fleet-server$(if $(filter windows,$($@_OS)),.exe,) .
GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -cover -coverpkg=./... -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" $($@_BUILDMODE) -o build/cover/fleet-server$(FIPSSUFFIX)-$(VERSION)-$($@_OS)-$($@_ARCH)/fleet-server$(if $(filter windows,$($@_OS)),.exe,) .

.PHONY: clean
clean: ## - Clean up build artifacts
Expand Down Expand Up @@ -263,7 +261,7 @@ $(PLATFORM_TARGETS): release-%:
$(eval $@_GO_ARCH := $(lastword $(subst /, ,$(lastword $(subst release-, ,$@)))))
$(eval $@_ARCH := $(TARGET_ARCH_$($@_GO_ARCH)))
$(eval $@_BUILDMODE:= $(BUILDMODE_$($@_OS)_$($@_GO_ARCH)))
GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" $($@_BUILDMODE) -o build/binaries/fleet-server-$(VERSION)-$($@_OS)-$($@_ARCH)$(FIPSSUFFIX)/fleet-server .
GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" $($@_BUILDMODE) -o build/binaries/fleet-server$(FIPSSUFFIX)-$(VERSION)-$($@_OS)-$($@_ARCH)/fleet-server .
@$(MAKE) OS=$($@_OS) ARCH=$($@_ARCH) package-target

.PHONY: build-docker
Expand Down Expand Up @@ -307,8 +305,8 @@ else ifeq ($(OS)-$(ARCH),darwin-arm64)
@tar -C build/binaries -zcf build/distributions/fleet-server-$(VERSION)-$(OS)-aarch64.tar.gz fleet-server-$(VERSION)-$(OS)-aarch64
@cd build/distributions && sha512sum fleet-server-$(VERSION)-$(OS)-aarch64.tar.gz > fleet-server-$(VERSION)-$(OS)-aarch64.tar.gz.sha512
else
@tar -C build/binaries -zcf build/distributions/fleet-server-$(VERSION)-$(OS)-$(ARCH)$(FIPSSUFFIX).tar.gz fleet-server-$(VERSION)-$(OS)-$(ARCH)$(FIPSSUFFIX)
@cd build/distributions && sha512sum fleet-server-$(VERSION)-$(OS)-$(ARCH)$(FIPSSUFFIX).tar.gz > fleet-server-$(VERSION)-$(OS)-$(ARCH)$(FIPSSUFFIX).tar.gz.sha512
@tar -C build/binaries -zcf build/distributions/fleet-server$(FIPSSUFFIX)-$(VERSION)-$(OS)-$(ARCH).tar.gz fleet-server$(FIPSSUFFIX)-$(VERSION)-$(OS)-$(ARCH)
@cd build/distributions && sha512sum fleet-server$(FIPSSUFFIX)-$(VERSION)-$(OS)-$(ARCH).tar.gz > fleet-server$(FIPSSUFFIX)-$(VERSION)-$(OS)-$(ARCH).tar.gz.sha512
endif

build-releaser: ## - Build a Docker image to run make package including all build tools
Expand Down
8 changes: 4 additions & 4 deletions dev-tools/e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ ARG ELASTIC_AGENT_IMAGE # e.g. docker.elastic.co/cloud-release/elastic-agent-clo

FROM --platform=linux/amd64 ${ELASTIC_AGENT_IMAGE} as elastic_agent_amd64
ARG STACK_VERSION # e.g. 8.5.0-SNAPSHOT
ARG FLEET_SUFFIX # e.g. -linux-x86_64
ARG FLEET_FIPS="" # should be -fips if a fips distribution will be used
ARG VCS_REF_SHORT # e.g. abc123
ONBUILD COPY --chmod=0755 --chown=elastic-agent cover/fleet-server-${STACK_VERSION}${FLEET_SUFFIX}/fleet-server \
ONBUILD COPY --chmod=0755 --chown=elastic-agent cover/fleet-server${FLEET_FIPS}-${STACK_VERSION}-linux-x86_64/fleet-server \
./data/elastic-agent-${VCS_REF_SHORT}/components/fleet-server

FROM --platform=linux/arm64 ${ELASTIC_AGENT_IMAGE} as elastic_agent_arm64
ARG STACK_VERSION # e.g. 8.5.0-SNAPSHOT
ARG FLEET_SUFFIX # e.g. -linux-x86_64
ARG FLEET_FIPS="" # should be -fips if a fips distribution will be used
ARG VCS_REF_SHORT # e.g. abc123
ONBUILD COPY --chmod=0755 --chown=elastic-agent cover/fleet-server-${STACK_VERSION}${FLEET_SUFFIX}/fleet-server \
ONBUILD COPY --chmod=0755 --chown=elastic-agent cover/fleet-server${FLEET_FIPS}-${STACK_VERSION}-linux-arm64/fleet-server \
./data/elastic-agent-${VCS_REF_SHORT}/components/fleet-server

FROM elastic_agent_${TARGETARCH}
9 changes: 3 additions & 6 deletions dev-tools/e2e/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@ VCS_REF=$(docker inspect -f '{{index .Config.Labels "org.label-schema.vcs-ref"}}

CUSTOM_IMAGE_TAG=${STACK_VERSION}-e2e-${COMMIT}-$(date +%s)

FLEET_SUFFIX="-linux-x86_64"
if [[ "$GOARCH" == "arm64" ]]; then
FLEET_SUFFIX="-linux-arm64"
fi
FLEET_FIPS=""
if [[ "$FIPS" == "true" ]]; then
FLEET_SUFFIX="${FLEET_SUFFIX}-fips"
FLEET_FIPS="-fips"
fi

docker build \
-f $REPO_ROOT/dev-tools/e2e/Dockerfile \
--build-arg ELASTIC_AGENT_IMAGE=$BASE_IMAGE \
--build-arg STACK_VERSION=${FLEET_VERSION} \
--build-arg FLEET_SUFFIX=${FLEET_SUFFIX} \
--build-arg FLEET_FIPS=${FLEET_FIPS} \
--build-arg VCS_REF_SHORT=${VCS_REF:0:6} \
--platform linux/$GOARCH \
-t ${CI_ELASTIC_AGENT_DOCKER_IMAGE}:${CUSTOM_IMAGE_TAG} \
Expand Down
8 changes: 4 additions & 4 deletions docs/fips.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The following make commands have different behaviour when FIPS is enabled:
A Multipass VM created with `FIPS=true make multipass` is able to compile FIPS enabled golang programs, but is not able to run them.
When you try to run one the following error occurs:
```
GOFIPS=1 ./bin/fleet-server -c fleet-server.yml
GODEBUG=fips140=on ./bin/fleet-server -c fleet-server.yml
panic: opensslcrypto: can't enable FIPS mode for OpenSSL 3.0.13 30 Jan 2024: openssl: FIPS mode not supported by any provider

goroutine 1 [running]:
Expand Down Expand Up @@ -92,14 +92,14 @@ activate = 1
default_properties = fips=yes
```

4. Run the program with the `OPENSSL_CONF=openssl.cnf` and `GOFIPS=1` env vars, i.e.,
4. Run the program with the `OPENSSL_CONF=openssl.cnf` and `GODEBUG=fips140=on` env vars, i.e.,
```
OPENSSL_CONF=./openssl.cnf GOFIPS=1 ./bin/fleet-server -c fleet-server.yml
OPENSSL_CONF=./openssl.cnf GODEBUG=fips140=on ./bin/fleet-server -c fleet-server.yml
23:48:47.871 INF Boot fleet-server args=["-c","fleet-server.yml"] commit=55104f6f ecs.version=1.6.0 exe=./bin/fleet-server pid=65037 ppid=5642 service.name=fleet-server service.type=fleet-server version=9.0.0
i...
```

## Usage

A FIPS enabled binary should be ran with the env var `GOFIPS=1` set.
A FIPS enabled binary should be ran with the env var `GODEBUG=fips140=on` set.
The system/image is required to have a FIPS compliant provider available.
2 changes: 1 addition & 1 deletion testing/e2e/fips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (suite *FIPSStandAlone) SetupSuite() {
arch = "x86_64"
}
// NOTE the path checked is hardcoded to linux as we currently only support linux for FIPS builds
path, err := filepath.Abs(filepath.Join("..", "..", "build", "cover", fmt.Sprintf("fleet-server-%s-SNAPSHOT-linux-%s-fips", version.DefaultVersion, arch), binaryName))
path, err := filepath.Abs(filepath.Join("..", "..", "build", "cover", fmt.Sprintf("fleet-server-fips-%s-SNAPSHOT-linux-%s", version.DefaultVersion, arch), binaryName))
suite.Require().NoError(err)
suite.binaryPath = path
_, err = os.Stat(suite.binaryPath)
Expand Down