Skip to content

Commit 2a4dc09

Browse files
committed
add disable_spire build tag for entrypoint command
1 parent a3ee865 commit 2a4dc09

File tree

8 files changed

+180
-23
lines changed

8 files changed

+180
-23
lines changed

cmd/entrypoint/main.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ import (
3030

3131
"github.com/containerd/containerd/platforms"
3232
"github.com/tektoncd/pipeline/cmd/entrypoint/subcommands"
33-
featureFlags "github.com/tektoncd/pipeline/pkg/apis/config"
3433
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
3534
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
3635
"github.com/tektoncd/pipeline/pkg/credentials"
3736
"github.com/tektoncd/pipeline/pkg/credentials/dockercreds"
3837
"github.com/tektoncd/pipeline/pkg/credentials/gitcreds"
3938
"github.com/tektoncd/pipeline/pkg/entrypoint"
40-
"github.com/tektoncd/pipeline/pkg/spire"
41-
"github.com/tektoncd/pipeline/pkg/spire/config"
4239
"github.com/tektoncd/pipeline/pkg/termination"
4340
)
4441

@@ -59,9 +56,7 @@ var (
5956
onError = flag.String("on_error", "", "Set to \"continue\" to ignore an error and continue when a container terminates with a non-zero exit code."+
6057
" Set to \"stopAndFail\" to declare a failure with a step error and stop executing the rest of the steps.")
6158
stepMetadataDir = flag.String("step_metadata_dir", "", "If specified, create directory to store the step metadata e.g. /tekton/steps/<step-name>/")
62-
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification")
63-
socketPath = flag.String("spire_socket_path", "unix:///spiffe-workload-api/spire-agent.sock", "Experimental: The SPIRE agent socket for SPIFFE workload API.")
64-
resultExtractionMethod = flag.String("result_from", featureFlags.ResultExtractionMethodTerminationMessage, "The method using which to extract results from tasks. Default is using the termination message.")
59+
resultExtractionMethod = flag.String("result_from", entrypoint.ResultExtractionMethodTerminationMessage, "The method using which to extract results from tasks. Default is using the termination message.")
6560
)
6661

6762
const (
@@ -130,13 +125,7 @@ func main() {
130125
}
131126
}
132127

133-
var spireWorkloadAPI spire.EntrypointerAPIClient
134-
if enableSpire != nil && *enableSpire && socketPath != nil && *socketPath != "" {
135-
spireConfig := config.SpireConfig{
136-
SocketPath: *socketPath,
137-
}
138-
spireWorkloadAPI = spire.NewEntrypointerAPIClient(&spireConfig)
139-
}
128+
spireWorkloadAPI := initializeSpireAPI()
140129

141130
e := entrypoint.Entrypointer{
142131
Command: append(cmd, commandArgs...),

cmd/entrypoint/spire.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//go:build !disable_spire
2+
3+
/*
4+
Copyright 2025 The Tekton Authors
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package main
20+
21+
import (
22+
"flag"
23+
24+
"github.com/tektoncd/pipeline/pkg/spire"
25+
"github.com/tektoncd/pipeline/pkg/spire/config"
26+
)
27+
28+
var (
29+
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification")
30+
socketPath = flag.String("spire_socket_path", "unix:///spiffe-workload-api/spire-agent.sock", "Experimental: The SPIRE agent socket for SPIFFE workload API.")
31+
)
32+
33+
func initializeSpireAPI() spire.EntrypointerAPIClient {
34+
if enableSpire != nil && *enableSpire && socketPath != nil && *socketPath != "" {
35+
spireConfig := config.SpireConfig{
36+
SocketPath: *socketPath,
37+
}
38+
return spire.NewEntrypointerAPIClient(&spireConfig)
39+
}
40+
return nil
41+
}

cmd/entrypoint/spire_disable.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//go:build disable_spire
2+
3+
/*
4+
Copyright 2025 The Tekton Authors
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package main
20+
21+
import (
22+
"context"
23+
24+
"github.com/tektoncd/pipeline/pkg/result"
25+
)
26+
27+
// EntrypointerAPIClient interface maps to the spire entrypointer API to interact with spire
28+
type EntrypointerAPIClient interface {
29+
Close() error
30+
// Sign returns the signature material to be put in the RunResult to append to the output results
31+
Sign(ctx context.Context, results []result.RunResult) ([]result.RunResult, error)
32+
}
33+
34+
func initializeSpireAPI() EntrypointerAPIClient {
35+
return nil
36+
}

docs/developers/fips.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Introduction
2+
FIPS compliance requires compiling the project with a Go FIPS-compliant compiler (e.g., golang-fips) and using dynamic linking.
3+
4+
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.).
5+
6+
To achieve this, we need compile-time options to disable TLS, SPIRE, and any network-related functionality.
7+
8+
This document provides instructions on compiling the entrypoint command to ensure FIPS compliance.
9+
10+
## Disable SPIRE during Build
11+
To disable SPIRE during the build process, use the following command
12+
13+
```shell
14+
CGO_ENABLED=0 go build -tags disable_spire -o bin/entrypoint ./cmd/entrypoint
15+
```

docs/spire.md

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ When a TaskRun is created:
6161
1. The entrypointer receives an x509 SVID, containing the x509 certificate and associated private key.
6262
1. The entrypointer signs the results of the TaskRun and emits the signatures and x509 certificate to the TaskRun results for later verification.
6363

64+
## Enable SPIRE during Build
65+
Users can enable SPIRE support in Tekton Pipelines during the build process by using the following build tag:
66+
```shell
67+
CGO_ENABLED=0 go build -tags "!disable_spire" -o bin/entrypoint ./cmd/entrypoint
68+
```
69+
6470
## Enabling TaskRun result attestations
6571

6672
To enable TaskRun attestations:

pkg/entrypoint/entrypointer.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
"github.com/tektoncd/pipeline/pkg/internal/resultref"
3939
"github.com/tektoncd/pipeline/pkg/pod"
4040
"github.com/tektoncd/pipeline/pkg/result"
41-
"github.com/tektoncd/pipeline/pkg/spire"
4241
"github.com/tektoncd/pipeline/pkg/termination"
4342

4443
"github.com/google/cel-go/cel"
@@ -53,8 +52,9 @@ const (
5352
)
5453

5554
const (
56-
breakpointExitSuffix = ".breakpointexit"
57-
breakpointBeforeStepSuffix = ".beforestepexit"
55+
breakpointExitSuffix = ".breakpointexit"
56+
breakpointBeforeStepSuffix = ".beforestepexit"
57+
ResultExtractionMethodTerminationMessage = "termination-message"
5858
)
5959

6060
// DebugBeforeStepError is an error means mark before step breakpoint failure
@@ -147,7 +147,7 @@ type Entrypointer struct {
147147
// StepMetadataDir is the directory for a step where the step related metadata can be stored
148148
StepMetadataDir string
149149
// SpireWorkloadAPI connects to spire and does obtains SVID based on taskrun
150-
SpireWorkloadAPI spire.EntrypointerAPIClient
150+
SpireWorkloadAPI EntrypointerAPIClient
151151
// ResultsDirectory is the directory to find results, defaults to pipeline.DefaultResultPath
152152
ResultsDirectory string
153153
// ResultExtractionMethod is the method using which the controller extracts the results from the task pod.
@@ -444,13 +444,11 @@ func (e Entrypointer) readResultsFromDisk(ctx context.Context, resultDir string,
444444
})
445445
}
446446

447-
if e.SpireWorkloadAPI != nil {
448-
signed, err := e.SpireWorkloadAPI.Sign(ctx, output)
449-
if err != nil {
450-
return err
451-
}
452-
output = append(output, signed...)
447+
signed, err := signResults(ctx, e.SpireWorkloadAPI, output)
448+
if err != nil {
449+
return err
453450
}
451+
output = append(output, signed...)
454452

455453
// push output to termination path
456454
if e.ResultExtractionMethod == config.ResultExtractionMethodTerminationMessage && len(output) != 0 {

pkg/entrypoint/spire.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//go:build !disable_spire
2+
3+
/*
4+
Copyright 2025 The Tekton Authors
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package entrypoint
20+
21+
import (
22+
"context"
23+
24+
"github.com/tektoncd/pipeline/pkg/result"
25+
"github.com/tektoncd/pipeline/pkg/spire"
26+
)
27+
28+
// EntrypointerAPIClient defines the interface for SPIRE operations
29+
type EntrypointerAPIClient interface {
30+
spire.EntrypointerAPIClient
31+
}
32+
33+
func signResults(ctx context.Context, api EntrypointerAPIClient, results []result.RunResult) ([]result.RunResult, error) {
34+
if api == nil {
35+
return nil, nil
36+
}
37+
return api.Sign(ctx, results)
38+
}

pkg/entrypoint/spire_disabled.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//go:build disable_spire
2+
3+
/*
4+
Copyright 2025 The Tekton Authors
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package entrypoint
20+
21+
import (
22+
"context"
23+
24+
"github.com/tektoncd/pipeline/pkg/result"
25+
)
26+
27+
// EntrypointerAPIClient defines the interface for SPIRE operations
28+
type EntrypointerAPIClient interface {
29+
Sign(ctx context.Context, results []result.RunResult) ([]result.RunResult, error)
30+
}
31+
32+
func signResults(ctx context.Context, api EntrypointerAPIClient, results []result.RunResult) ([]result.RunResult, error) {
33+
return nil, nil
34+
}

0 commit comments

Comments
 (0)