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

Makefile(ticdc): support build cdc in fips mode #9961

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ else ifeq (${OS}, "darwin")
CGO := 1
endif

GOBUILD := CGO_ENABLED=$(CGO) $(GO) build $(BUILD_FLAG) -trimpath $(GOVENDORFLAG)
BUILD_FLAG =
GOEXPERIMENT=
ifeq ("${ENABLE_FIPS}", "1")
BUILD_FLAG = -tags boringcrypto
GOEXPERIMENT = GOEXPERIMENT=boringcrypto
CGO = 1
endif
GOBUILD := $(GOEXPERIMENT) CGO_ENABLED=$(CGO) $(GO) build $(BUILD_FLAG) -trimpath $(GOVENDORFLAG)
GOBUILDNOVENDOR := CGO_ENABLED=0 $(GO) build $(BUILD_FLAG) -trimpath
GOTEST := CGO_ENABLED=1 $(GO) test -p $(P) --race --tags=intest
GOTESTNORACE := CGO_ENABLED=1 $(GO) test -p $(P)
Expand Down Expand Up @@ -155,7 +162,7 @@ build-cdc-with-failpoint: ## Build cdc with failpoint enabled.
$(FAILPOINT_DISABLE)

cdc:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc ./cmd/cdc/main.go
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc ./cmd/cdc

kafka_consumer:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/cdc_kafka_consumer ./cmd/kafka-consumer/main.go
Expand Down
27 changes: 27 additions & 0 deletions cmd/cdc/fips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2020 PingCAP, Inc.
//
// 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,
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build boringcrypto
// +build boringcrypto

package main

import (
_ "crypto/tls/fipsonly"
//
"github.com/pingcap/tiflow/pkg/version"
)

func init() {
version.ReleaseVersion += "-fips"
}
1 change: 1 addition & 0 deletions pkg/version/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func SanitizeVersion(v string) string {
return v
}
v = versionHash.ReplaceAllLiteralString(v, "")
v = strings.TrimSuffix(v, "-fips")
v = strings.TrimSuffix(v, "-dirty")
return strings.TrimPrefix(v, "v")
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/version/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ func TestCompareVersion(t *testing.T) {
dirtyVersion := semver.New(SanitizeVersion("v6.3.0-dirty"))
require.Equal(t, 1, dirtyVersion.Compare(*MinTiCDCVersion))
require.Equal(t, 0, dirtyVersion.Compare(*semver.New("6.3.0")))

dirtyVersionWithFIPS := semver.New(SanitizeVersion("v6.3.0-dirty-fips"))
require.Equal(t, 1, dirtyVersionWithFIPS.Compare(*MinTiCDCVersion))
require.Equal(t, 0, dirtyVersionWithFIPS.Compare(*semver.New("6.3.0")))
}

func TestReleaseSemver(t *testing.T) {
Expand Down
Loading