Skip to content

Commit 9bf7def

Browse files
fips: otelcol binaries for linux and windows (#5378)
1 parent b1524a0 commit 9bf7def

File tree

7 files changed

+250
-2
lines changed

7 files changed

+250
-2
lines changed

.github/workflows/otelcol-fips.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: "otelcol-fips"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
paths:
9+
- '.github/workflows/otelcol-fips.yml'
10+
- 'cmd/otelcol/**'
11+
- 'internal/**'
12+
- 'pkg/**'
13+
- 'tests/**'
14+
- 'Makefile'
15+
- 'Makefile.Common'
16+
- 'go.mod'
17+
- 'go.sum'
18+
- '!**.md'
19+
- '!internal/buildscripts/**'
20+
21+
concurrency:
22+
group: otelcol-fips-${{ github.event.pull_request.number || github.ref }}
23+
cancel-in-progress: true
24+
25+
env:
26+
GO_VERSION: "1.22.7"
27+
28+
jobs:
29+
otelcol-fips:
30+
runs-on: ${{ fromJSON('["ubuntu-20.04", "otel-arm64"]')[matrix.GOARCH == 'arm64'] }}
31+
strategy:
32+
matrix:
33+
include:
34+
- GOOS: linux
35+
GOARCH: amd64
36+
- GOOS: linux
37+
GOARCH: arm64
38+
- GOOS: windows
39+
GOARCH: amd64
40+
fail-fast: false
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
- uses: actions/setup-go@v5
46+
with:
47+
go-version: ${{ env.GO_VERSION }}
48+
cache-dependency-path: '**/go.sum'
49+
- run: make otelcol-fips
50+
env:
51+
GOOS: ${{ matrix.GOOS }}
52+
GOARCH: ${{ matrix.GOARCH }}
53+
- uses: actions/upload-artifact@v4
54+
with:
55+
name: otelcol-fips-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
56+
path: ./bin/*
57+
58+
win-binary-test:
59+
runs-on: windows-2022
60+
needs: [ otelcol-fips ]
61+
strategy:
62+
matrix:
63+
FIPSMODE: [ "1", "0" ]
64+
fail-fast: false
65+
steps:
66+
- uses: actions/download-artifact@v4
67+
with:
68+
name: otelcol-fips-windows-amd64
69+
path: ./bin
70+
- run: Set-ItemProperty -Path HKLM:\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy -Name Enabled -Value ${{ matrix.FIPSMODE }}
71+
- run: ./bin/otelcol-fips_windows_amd64.exe --version
72+
id: run-otelcol
73+
continue-on-error: true
74+
- run: echo "FIPS enabled, started successfully"
75+
if: matrix.FIPSMODE == '1' && steps.run-otelcol.outcome == 'success'
76+
- run: throw "FIPS enabled, should not have failed"
77+
if: matrix.FIPSMODE == '1' && steps.run-otelcol.outcome == 'failure'
78+
- run: echo "FIPS disabled, failed successfully"
79+
if: matrix.FIPSMODE == '0' && steps.run-otelcol.outcome == 'failure'
80+
- run: throw "FIPS disabled, should have failed"
81+
if: matrix.FIPSMODE == '0' && steps.run-otelcol.outcome == 'success'

.gitlab-ci.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,40 @@ compile:
311311
- bin/otelcol_*
312312
- bin/migratecheckpoint_*
313313

314+
otelcol-fips:
315+
image: '${DOCKER_CICD_REPO}/ci-container/golang-1.22:3.4.0'
316+
extends:
317+
- .trigger-filter
318+
stage: build
319+
needs: []
320+
parallel:
321+
matrix:
322+
- GOOS: linux
323+
GOARCH: amd64
324+
TAG: main
325+
- GOOS: linux
326+
GOARCH: arm64
327+
TAG: arm
328+
- GOOS: windows
329+
GOARCH: amd64
330+
TAG: main
331+
tags:
332+
- $TAG
333+
id_tokens: # http://go/gitlab-17
334+
CI_JOB_JWT:
335+
aud: $CICD_VAULT_ADDR
336+
script:
337+
- *docker-reader-role
338+
- |
339+
if [[ -n "${CI_COMMIT_TAG:-}" ]]; then
340+
make otelcol-fips VERSION=${CI_COMMIT_TAG} DOCKER_REPO=${DOCKER_HUB_REPO}
341+
else
342+
make otelcol-fips DOCKER_REPO=${DOCKER_HUB_REPO}
343+
fi
344+
artifacts:
345+
paths:
346+
- bin/otelcol-fips_*
347+
314348
libsplunk:
315349
extends: .trigger-filter
316350
stage: build
@@ -437,9 +471,10 @@ sign-exe:
437471
retry: 2
438472
needs:
439473
- compile
474+
- otelcol-fips
440475
parallel:
441476
matrix:
442-
- TARGET: [otelcol]
477+
- TARGET: [otelcol, otelcol-fips]
443478
variables:
444479
ARTIFACT: bin/${TARGET}_windows_amd64.exe
445480
SIGN_TYPE: WIN
@@ -1299,6 +1334,7 @@ github-release:
12991334
stage: github-release
13001335
dependencies:
13011336
- compile
1337+
- otelcol-fips
13021338
- libsplunk
13031339
- sign-exe
13041340
- sign-osx
@@ -1312,6 +1348,7 @@ github-release:
13121348
script:
13131349
- mkdir -p dist/assets
13141350
- cp bin/otelcol_linux_* dist/assets/
1351+
- cp bin/otelcol-fips_linux_* dist/assets/
13151352
- cp instrumentation/dist/libsplunk_*.so dist/assets/
13161353
- cp dist/signed/* dist/assets/
13171354
- |

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
- (Splunk) Deprecate the jaegergrpc monitor ([#5428](https://github.com/signalfx/splunk-otel-collector/pull/5428))
88

9+
### 💡 Enhancements 💡
10+
11+
- (Splunk) Initial release of standalone collector binaries for Linux (amd64/arm64) and Windows (amd64) with FIPS 140-2 support. These are experimental (alpha) binaries, and it is not suitable to use them in production environments. ([#5378](https://github.com/signalfx/splunk-otel-collector/pull/5378)):
12+
- `otelcol-fips_linux_<amd64|arm64>`: Built with [`GOEXPERIMENT=boringcrypto`](https://go.dev/src/crypto/internal/boring/README) and [`crypto/tls/fipsonly`](https://go.dev/src/crypto/tls/fipsonly/fipsonly.go).
13+
- `otelcol-fips_windows_amd64.exe`: Built with [`GOEXPERIMENT=cngcrypto`](https://github.com/microsoft/go/blob/microsoft/main/eng/doc/fips/README.md) and [`requirefips`](https://github.com/microsoft/go/blob/microsoft/main/eng/doc/fips/README.md#build-option-to-require-fips-mode) (the collector will panic if FIPS is not enabled on the Windows host).
14+
- Smart Agent components are not currently supported.
15+
- Download the binaries from the list of assets below.
16+
917
## v0.110.0
1018

1119
This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.110.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.110.0) and the [opentelemetry-collector-contrib v0.110.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.110.0) releases where appropriate.

Makefile

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ BUILD_X1=-X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION)
3030
BUILD_X2=-X $(BUILD_INFO_IMPORT_PATH_CORE).Version=$(VERSION)
3131
BUILD_INFO=-ldflags "${BUILD_X1} ${BUILD_X2}"
3232
BUILD_INFO_TESTS=-ldflags "-X $(BUILD_INFO_IMPORT_PATH_TESTS).Version=$(VERSION)"
33+
CGO_ENABLED?=0
3334

3435
JMX_METRIC_GATHERER_RELEASE=$(shell cat internal/buildscripts/packaging/jmx-metric-gatherer-release.txt)
3536
SKIP_COMPILE=false
@@ -135,13 +136,14 @@ generate-metrics:
135136
.PHONY: otelcol
136137
otelcol:
137138
go generate ./...
138-
GO111MODULE=on CGO_ENABLED=0 go build -trimpath -o ./bin/otelcol_$(GOOS)_$(GOARCH)$(EXTENSION) $(BUILD_INFO) ./cmd/otelcol
139+
GO111MODULE=on CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -o ./bin/otelcol_$(GOOS)_$(GOARCH)$(EXTENSION) $(BUILD_INFO) ./cmd/otelcol
139140
ifeq ($(OS), Windows_NT)
140141
$(LINK_CMD) .\bin\otelcol$(EXTENSION) .\bin\otelcol_$(GOOS)_$(GOARCH)$(EXTENSION)
141142
else
142143
$(LINK_CMD) otelcol_$(GOOS)_$(GOARCH)$(EXTENSION) ./bin/otelcol$(EXTENSION)
143144
endif
144145

146+
145147
.PHONY: migratecheckpoint
146148
migratecheckpoint:
147149
go generate ./...
@@ -241,3 +243,29 @@ install-test-tools:
241243
integration-test-split: install-test-tools
242244
@set -e; cd tests && gotesplit --total=$(GOTESPLIT_TOTAL) --index=$(GOTESPLIT_INDEX) ./... -- -p 1 $(BUILD_INFO_TESTS) --tags=integration -v -timeout 5m -count 1
243245

246+
.PHONY: otelcol-fips
247+
otelcol-fips:
248+
ifeq ($(GOOS), linux)
249+
ifeq ($(filter $(GOARCH), amd64 arm64),)
250+
$(error GOOS=$(GOOS) GOARCH=$(GOARCH) not supported)
251+
endif
252+
$(eval BUILD_INFO = -ldflags "${BUILD_X1} ${BUILD_X2} -linkmode=external -extldflags=-static")
253+
else ifeq ($(GOOS), windows)
254+
ifeq ($(filter $(GOARCH), amd64),)
255+
$(error GOOS=$(GOOS) GOARCH=$(GOARCH) not supported)
256+
endif
257+
$(eval EXTENSION = .exe)
258+
else
259+
$(error GOOS=$(GOOS) GOARCH=$(GOARCH) not supported)
260+
endif
261+
docker buildx build --pull \
262+
--tag otelcol-fips-builder-$(GOOS)-$(GOARCH) \
263+
--platform linux/$(GOARCH) \
264+
--build-arg DOCKER_REPO=$(DOCKER_REPO) \
265+
--build-arg BUILD_INFO='$(BUILD_INFO)' \
266+
--file cmd/otelcol/fips/build/Dockerfile.$(GOOS) ./
267+
@docker rm -f otelcol-fips-builder-$(GOOS)-$(GOARCH) >/dev/null 2>&1 || true
268+
@mkdir -p ./bin
269+
docker create --platform linux/$(GOARCH) --name otelcol-fips-builder-$(GOOS)-$(GOARCH) otelcol-fips-builder-$(GOOS)-$(GOARCH) true >/dev/null
270+
docker cp otelcol-fips-builder-$(GOOS)-$(GOARCH):/src/bin/otelcol_$(GOOS)_$(GOARCH)$(EXTENSION) ./bin/otelcol-fips_$(GOOS)_$(GOARCH)$(EXTENSION)
271+
@docker rm -f otelcol-fips-builder-$(GOOS)-$(GOARCH) >/dev/null
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ARG DOCKER_REPO=docker.io
2+
ARG GO_VERSION=1.22.7
3+
FROM ${DOCKER_REPO}/golang:${GO_VERSION}
4+
5+
# https://splunk.atlassian.net/wiki/x/qYqRDfs
6+
ENV BORING_SHA="c1dd71f0ea77e385796db11102c461896ee0824825c773979751983e2bf49912"
7+
ENV BORING_PATH="src/crypto/internal/boring/syso/goboringcrypto_linux_amd64.syso"
8+
RUN echo "$BORING_SHA" "$( go env GOROOT )/${BORING_PATH}" | sha256sum --check || ( echo "$BORING_PATH SHA256 doesn't match $BORING_SHA" && exit 1 )
9+
10+
# install toolchain to build a statically linked binary with cgo enabled
11+
RUN apt-get update && \
12+
apt-get install -y --no-install-recommends file musl-dev musl-tools
13+
14+
COPY cmd /src/cmd
15+
COPY internal /src/internal
16+
COPY pkg /src/pkg
17+
COPY Makefile /src/
18+
COPY Makefile.Common /src/
19+
COPY go.mod /src/
20+
COPY go.sum /src/
21+
22+
ARG TARGETARCH
23+
ARG BUILD_INFO
24+
ENV GOOS=linux
25+
ENV GOARCH=${TARGETARCH}
26+
ENV GOEXPERIMENT=boringcrypto
27+
ENV GOMODCACHE=/go/pkg/mod
28+
ENV CGO_ENABLED=1
29+
ENV CC=musl-gcc
30+
31+
WORKDIR /src
32+
RUN --mount=type=cache,target=${GOMODCACHE} make otelcol BUILD_INFO="${BUILD_INFO}"
33+
34+
# check the binary
35+
RUN file ./bin/otelcol_${GOOS}_${GOARCH} | grep -i "statically linked" || ( echo "the binary is not statically linked" && exit 1 )
36+
RUN go version ./bin/otelcol_${GOOS}_${GOARCH} | grep "X:${GOEXPERIMENT}"
37+
RUN go tool nm ./bin/otelcol_${GOOS}_${GOARCH} > symbols
38+
RUN grep -i "fipsonly" symbols
39+
RUN grep -m5 "_Cfunc__goboringcrypto" symbols
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG GO_VERSION=1.22.7
2+
FROM mcr.microsoft.com/oss/go/microsoft/golang:${GO_VERSION}
3+
4+
ARG TARGETARCH
5+
6+
# install toolchain for cgo
7+
RUN apt-get update && \
8+
apt-get install -y --no-install-recommends gcc-mingw-w64
9+
10+
COPY cmd /src/cmd
11+
COPY internal /src/internal
12+
COPY pkg /src/pkg
13+
COPY Makefile /src/
14+
COPY Makefile.Common /src/
15+
COPY go.mod /src/
16+
COPY go.sum /src/
17+
18+
ARG BUILD_INFO
19+
ENV GOOS=windows
20+
ENV GOARCH=${TARGETARCH}
21+
ENV GOEXPERIMENT=cngcrypto
22+
ENV GOMODCACHE=/go/pkg/mod
23+
ENV CGO_ENABLED=1
24+
ENV CC=x86_64-w64-mingw32-gcc
25+
ENV CXX=x86_64-w64-mingw32-g++
26+
ENV GOFLAGS="-tags=requirefips"
27+
ENV EXTENSION=.exe
28+
29+
WORKDIR /src
30+
RUN --mount=type=cache,target=${GOMODCACHE} make otelcol BUILD_INFO="${BUILD_INFO}"
31+
32+
# check the binary
33+
RUN go version ./bin/otelcol_${GOOS}_${GOARCH}${EXTENSION} | grep "X:${GOEXPERIMENT}"
34+
RUN go tool nm ./bin/otelcol_${GOOS}_${GOARCH}${EXTENSION} > symbols
35+
RUN grep -m5 "github.com/microsoft/go-crypto-winnative" symbols

cmd/otelcol/main_fipsonly.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright Splunk, Inc.
2+
// Copyright The OpenTelemetry Authors
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
//go:build linux && boringcrypto && cgo && (amd64 || arm64)
17+
18+
package main
19+
20+
import _ "crypto/tls/fipsonly"

0 commit comments

Comments
 (0)