Skip to content

Commit 89973d4

Browse files
committed
chore: build fips compliant binaries
On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
1 parent 55c5581 commit 89973d4

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

charts/control-plane-operator/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ spec:
8080
fieldRef:
8181
fieldPath: metadata.namespace
8282
{{- end }}
83+
- name: GODEBUG
84+
value: "fips140={{ .Values.fips.mode }}"
8385
{{- with .Values.init.env }}
8486
{{- toYaml . | nindent 12 }}
8587
{{- end }}
@@ -177,6 +179,8 @@ spec:
177179
valueFrom:
178180
fieldRef:
179181
fieldPath: spec.serviceAccountName
182+
- name: GODEBUG
183+
value: "fips140={{ .Values.fips.mode }}"
180184
{{- with .Values.manager.env }}
181185
{{- toYaml . | nindent 12 }}
182186
{{- end }}

charts/control-plane-operator/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ rbac:
148148
role:
149149
rules: []
150150

151+
fips:
152+
mode: off # controls GODEBUG=fips140 setting. Set to either off, on, or only (refer to https://go.dev/doc/security/fips140#fips-140-3-mode)
153+
151154
nodeSelector: {}
152155

153156
tolerations: []

cmd/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"crypto/fips140"
2021
"embed"
2122
"flag"
2223
"os"
@@ -129,6 +130,13 @@ func main() {
129130

130131
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
131132

133+
// needs to be run after ctrl.SetLogger has been called, so we can log
134+
if fips140.Enabled() {
135+
setupLog.Info("Running in FIPS 140-3 compliant mode")
136+
} else {
137+
setupLog.Info("Running in non-FIPS-compliant mode")
138+
}
139+
132140
setupContext := context.Background()
133141

134142
setupClient, err := client.New(ctrl.GetConfigOrDie(), client.Options{Scheme: schemes.Local})

hack/common/build-binary.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ echo "> Building binaries ..."
1212
echo "> Building binary for component '$comp' ($pf) ..." | indent 1
1313
os=${pf%/*}
1414
arch=${pf#*/}
15-
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -a -o bin/${comp}-${os}.${arch} cmd/main.go | indent 2
15+
CGO_ENABLED=0 GOFIPS140=v1.0.0 GOOS=$os GOARCH=$arch go build -a -o bin/${comp}-${os}.${arch} cmd/main.go | indent 2
1616
done
1717
done
1818
)

0 commit comments

Comments
 (0)