-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add disable_spire build tag for entrypoint command
- Loading branch information
Showing
8 changed files
with
193 additions
and
23 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
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,43 @@ | ||
//go:build !disable_spire | ||
|
||
/* | ||
Copyright 2025 The Tekton 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. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
|
||
"github.com/tektoncd/pipeline/pkg/spire" | ||
"github.com/tektoncd/pipeline/pkg/spire/config" | ||
) | ||
|
||
var ( | ||
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification") | ||
socketPath = flag.String("spire_socket_path", "unix:///spiffe-workload-api/spire-agent.sock", "Experimental: The SPIRE agent socket for SPIFFE workload API.") | ||
) | ||
|
||
func initializeSpireAPI() spire.EntrypointerAPIClient { | ||
if enableSpire != nil && *enableSpire && socketPath != nil && *socketPath != "" { | ||
log.Println("SPIRE is enabled in this build, enableSpire is supported") | ||
spireConfig := config.SpireConfig{ | ||
SocketPath: *socketPath, | ||
} | ||
return spire.NewEntrypointerAPIClient(&spireConfig) | ||
} | ||
return nil | ||
} |
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,47 @@ | ||
//go:build disable_spire | ||
|
||
/* | ||
Copyright 2025 The Tekton 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. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"log" | ||
"os" | ||
|
||
"github.com/tektoncd/pipeline/pkg/result" | ||
) | ||
|
||
var ( | ||
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification") | ||
) | ||
|
||
// EntrypointerAPIClient interface maps to the spire entrypointer API to interact with spire | ||
type EntrypointerAPIClient interface { | ||
Close() error | ||
// Sign returns the signature material to be put in the RunResult to append to the output results | ||
Sign(ctx context.Context, results []result.RunResult) ([]result.RunResult, error) | ||
} | ||
|
||
func initializeSpireAPI() EntrypointerAPIClient { | ||
if enableSpire != nil && *enableSpire { | ||
log.Fatal("Error: SPIRE is disabled in this build, but enableSpire was set to true. Please recompile with SPIRE support.") | ||
os.Exit(1) | ||
} | ||
return nil | ||
} |
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,15 @@ | ||
## Introduction | ||
FIPS compliance requires compiling the project with a Go FIPS-compliant compiler (e.g., golang-fips) and using dynamic linking. | ||
|
||
This approach works for most binaries in tektoncd/pipeline, except for the entrypoint, which must be statically compiled to ensure it runs in any environment, regardless of library locations or versions. To mark a statically compiled binary as FIPS compliant, we must eliminate cryptographic symbols (crypto/*, golang.org/x/crypto, etc.). | ||
|
||
To achieve this, we need compile-time options to disable TLS, SPIRE, and any network-related functionality. | ||
|
||
This document provides instructions on compiling the entrypoint command to ensure FIPS compliance. | ||
|
||
## Disable SPIRE during Build | ||
To disable SPIRE during the build process, use the following command | ||
|
||
```shell | ||
CGO_ENABLED=0 go build -tags disable_spire -o bin/entrypoint ./cmd/entrypoint | ||
``` |
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,38 @@ | ||
//go:build !disable_spire | ||
|
||
/* | ||
Copyright 2025 The Tekton 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. | ||
*/ | ||
|
||
package entrypoint | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/tektoncd/pipeline/pkg/result" | ||
"github.com/tektoncd/pipeline/pkg/spire" | ||
) | ||
|
||
// EntrypointerAPIClient defines the interface for SPIRE operations | ||
type EntrypointerAPIClient interface { | ||
spire.EntrypointerAPIClient | ||
} | ||
|
||
func signResults(ctx context.Context, api EntrypointerAPIClient, results []result.RunResult) ([]result.RunResult, error) { | ||
if api == nil { | ||
return nil, nil | ||
} | ||
return api.Sign(ctx, results) | ||
} |
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,34 @@ | ||
//go:build disable_spire | ||
|
||
/* | ||
Copyright 2025 The Tekton 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. | ||
*/ | ||
|
||
package entrypoint | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/tektoncd/pipeline/pkg/result" | ||
) | ||
|
||
// EntrypointerAPIClient defines the interface for SPIRE operations | ||
type EntrypointerAPIClient interface { | ||
Sign(ctx context.Context, results []result.RunResult) ([]result.RunResult, error) | ||
} | ||
|
||
func signResults(ctx context.Context, api EntrypointerAPIClient, results []result.RunResult) ([]result.RunResult, error) { | ||
return nil, nil | ||
} |