-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fips: otelcol binaries for linux and windows
- Loading branch information
1 parent
8026a6f
commit 4ea0804
Showing
7 changed files
with
247 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: "otelcol-fips" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- '.github/workflows/otelcol-fips.yml' | ||
- 'cmd/otelcol/**' | ||
- 'internal/**' | ||
- 'pkg/**' | ||
- 'tests/**' | ||
- 'Makefile' | ||
- 'Makefile.Common' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- '!**.md' | ||
- '!internal/buildscripts/**' | ||
|
||
concurrency: | ||
group: otelcol-fips-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
GO_VERSION: "1.22.7" | ||
|
||
jobs: | ||
otelcol-fips: | ||
runs-on: ${{ fromJSON('["ubuntu-20.04", "otel-arm64"]')[matrix.GOARCH == 'arm64'] }} | ||
strategy: | ||
matrix: | ||
include: | ||
- GOOS: linux | ||
GOARCH: amd64 | ||
- GOOS: linux | ||
GOARCH: arm64 | ||
- GOOS: windows | ||
GOARCH: amd64 | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache-dependency-path: '**/go.sum' | ||
- run: make otelcol-fips | ||
env: | ||
GOOS: ${{ matrix.GOOS }} | ||
GOARCH: ${{ matrix.GOARCH }} | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: otelcol-fips-${{ matrix.GOOS }}-${{ matrix.GOARCH }} | ||
path: ./bin/* | ||
|
||
win-binary-test: | ||
runs-on: windows-2022 | ||
needs: [ otelcol-fips ] | ||
strategy: | ||
matrix: | ||
FIPSMODE: [ "1", "0" ] | ||
fail-fast: false | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: otelcol-fips-windows-amd64 | ||
path: ./bin | ||
- run: Set-ItemProperty -Path HKLM:\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy -Name Enabled -Value ${{ matrix.FIPSMODE }} | ||
- run: ./bin/otelcol-fips_windows_amd64.exe --version | ||
id: run-otelcol | ||
continue-on-error: true | ||
- run: echo "FIPS enabled, started successfully" | ||
if: matrix.FIPSMODE == '1' && steps.run-otelcol.outcome == 'success' | ||
- run: throw "FIPS enabled, should not have failed" | ||
if: matrix.FIPSMODE == '1' && steps.run-otelcol.outcome == 'failure' | ||
- run: echo "FIPS disabled, failed successfully" | ||
if: matrix.FIPSMODE == '0' && steps.run-otelcol.outcome == 'failure' | ||
- run: throw "FIPS disabled, should have failed" | ||
if: matrix.FIPSMODE == '0' && steps.run-otelcol.outcome == 'success' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ARG DOCKER_REPO=docker.io | ||
ARG GO_VERSION=1.22.7 | ||
FROM ${DOCKER_REPO}/golang:${GO_VERSION} | ||
|
||
# https://splunk.atlassian.net/wiki/x/qYqRDfs | ||
ENV BORING_SHA="c1dd71f0ea77e385796db11102c461896ee0824825c773979751983e2bf49912" | ||
ENV BORING_PATH="src/crypto/internal/boring/syso/goboringcrypto_linux_amd64.syso" | ||
RUN echo "$BORING_SHA" "$( go env GOROOT )/${BORING_PATH}" | sha256sum --check || ( echo "$BORING_PATH SHA256 doesn't match $BORING_SHA" && exit 1 ) | ||
|
||
# install toolchain to build a statically linked binary with cgo enabled | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends file musl-dev musl-tools | ||
|
||
COPY cmd /src/cmd | ||
COPY internal /src/internal | ||
COPY pkg /src/pkg | ||
COPY Makefile /src/ | ||
COPY Makefile.Common /src/ | ||
COPY go.mod /src/ | ||
COPY go.sum /src/ | ||
|
||
ARG TARGETARCH | ||
ARG BUILD_INFO | ||
ENV GOOS=linux | ||
ENV GOARCH=${TARGETARCH} | ||
ENV GOEXPERIMENT=boringcrypto | ||
ENV GOMODCACHE=/go/pkg/mod | ||
ENV CGO_ENABLED=1 | ||
ENV CC=musl-gcc | ||
|
||
WORKDIR /src | ||
RUN --mount=type=cache,target=${GOMODCACHE} make otelcol BUILD_INFO="${BUILD_INFO}" | ||
|
||
# check the binary | ||
RUN file ./bin/otelcol_${GOOS}_${GOARCH} | grep -i "statically linked" || ( echo "the binary is not statically linked" && exit 1 ) | ||
RUN go version ./bin/otelcol_${GOOS}_${GOARCH} | grep "X:${GOEXPERIMENT}" | ||
RUN go tool nm ./bin/otelcol_${GOOS}_${GOARCH} > symbols | ||
RUN grep -i "fipsonly" symbols | ||
RUN grep -m5 "_Cfunc__goboringcrypto" symbols |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ARG GO_VERSION=1.22.7 | ||
FROM mcr.microsoft.com/oss/go/microsoft/golang:${GO_VERSION} | ||
|
||
ARG TARGETARCH | ||
|
||
# install toolchain for cgo | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends gcc-mingw-w64 | ||
|
||
COPY cmd /src/cmd | ||
COPY internal /src/internal | ||
COPY pkg /src/pkg | ||
COPY Makefile /src/ | ||
COPY Makefile.Common /src/ | ||
COPY go.mod /src/ | ||
COPY go.sum /src/ | ||
|
||
ARG BUILD_INFO | ||
ENV GOOS=windows | ||
ENV GOARCH=${TARGETARCH} | ||
ENV GOEXPERIMENT=cngcrypto | ||
ENV GOMODCACHE=/go/pkg/mod | ||
ENV CGO_ENABLED=1 | ||
ENV CC=x86_64-w64-mingw32-gcc | ||
ENV CXX=x86_64-w64-mingw32-g++ | ||
ENV GOFLAGS="-tags=requirefips" | ||
ENV EXTENSION=.exe | ||
|
||
WORKDIR /src | ||
RUN --mount=type=cache,target=${GOMODCACHE} make otelcol BUILD_INFO="${BUILD_INFO}" | ||
|
||
# check the binary | ||
RUN go version ./bin/otelcol_${GOOS}_${GOARCH}${EXTENSION} | grep "X:${GOEXPERIMENT}" | ||
RUN go tool nm ./bin/otelcol_${GOOS}_${GOARCH}${EXTENSION} > symbols | ||
RUN grep -m5 "github.com/microsoft/go-crypto-winnative" symbols |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright Splunk, Inc. | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build linux && boringcrypto && cgo && (amd64 || arm64) | ||
|
||
package main | ||
|
||
import _ "crypto/tls/fipsonly" |