Skip to content

Commit b5eeaab

Browse files
authored
Merge branch 'tektoncd:main' into main
2 parents d207271 + 5b082b1 commit b5eeaab

File tree

29 files changed

+335
-92
lines changed

29 files changed

+335
-92
lines changed

.github/workflows/ci.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
5151
with:
5252
version: v1.64.6
53+
only-new-issues: true
5354
args: --timeout=10m
5455
- name: yamllint
5556
run: |

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
# Prefix the list here with "+" to use these queries and those in the config file.
7171
# queries: ./path/to/local/query, your-org/your-repo/queries@main
7272

73-
- uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
73+
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
7474
with:
7575
path: |
7676
~/.cache/go-build

.github/workflows/woke.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Get changed files
2121
id: changed-files
22-
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6
22+
uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8 # v45.0.7
2323
with:
2424
write_output_files: true
2525
files: |

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ repos:
1818
exclude: "(.*_test.go|^examples\/v1\/pipelineruns\/beta\/isolated-workspaces.yaml$)"
1919
- repo: local
2020
hooks:
21+
- id: lint-yaml
22+
name: "Lint YAML files"
23+
entry: bash -c 'yamllint -c .yamllint $(find . -path ./vendor -prune -o -type f -regex ".*y[a]ml" -print)'
24+
language: system
25+
types: [yaml]
2126
- id: lint-go
2227
name: "Run make golangci-lint"
2328
entry: make

cmd/entrypoint/main.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ import (
2929
"time"
3030

3131
"github.com/tektoncd/pipeline/cmd/entrypoint/subcommands"
32-
featureFlags "github.com/tektoncd/pipeline/pkg/apis/config"
3332
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
3433
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
3534
"github.com/tektoncd/pipeline/pkg/credentials"
3635
"github.com/tektoncd/pipeline/pkg/credentials/dockercreds"
3736
"github.com/tektoncd/pipeline/pkg/credentials/gitcreds"
3837
"github.com/tektoncd/pipeline/pkg/entrypoint"
3938
"github.com/tektoncd/pipeline/pkg/platforms"
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 (
@@ -131,13 +126,7 @@ func main() {
131126
}
132127
}
133128

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

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

cmd/entrypoint/spire.go

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
"log"
24+
25+
"github.com/tektoncd/pipeline/pkg/spire"
26+
"github.com/tektoncd/pipeline/pkg/spire/config"
27+
)
28+
29+
var (
30+
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification")
31+
socketPath = flag.String("spire_socket_path", "unix:///spiffe-workload-api/spire-agent.sock", "Experimental: The SPIRE agent socket for SPIFFE workload API.")
32+
)
33+
34+
func initializeSpireAPI() spire.EntrypointerAPIClient {
35+
if enableSpire != nil && *enableSpire && socketPath != nil && *socketPath != "" {
36+
log.Println("SPIRE is enabled in this build, enableSpire is supported")
37+
spireConfig := config.SpireConfig{
38+
SocketPath: *socketPath,
39+
}
40+
return spire.NewEntrypointerAPIClient(&spireConfig)
41+
}
42+
return nil
43+
}

cmd/entrypoint/spire_disable.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
"flag"
24+
"log"
25+
"os"
26+
27+
"github.com/tektoncd/pipeline/pkg/result"
28+
)
29+
30+
var (
31+
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification")
32+
)
33+
34+
// EntrypointerAPIClient interface maps to the spire entrypointer API to interact with spire
35+
type EntrypointerAPIClient interface {
36+
Close() error
37+
// Sign returns the signature material to be put in the RunResult to append to the output results
38+
Sign(ctx context.Context, results []result.RunResult) ([]result.RunResult, error)
39+
}
40+
41+
func initializeSpireAPI() EntrypointerAPIClient {
42+
if enableSpire != nil && *enableSpire {
43+
log.Fatal("Error: SPIRE is disabled in this build, but enableSpire was set to true. Please recompile with SPIRE support.")
44+
os.Exit(1)
45+
}
46+
return nil
47+
}

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:

go.mod

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
module github.com/tektoncd/pipeline
22

33
go 1.22.7
4-
54
toolchain go1.23.4
65

76
require (
87
github.com/Microsoft/go-winio v0.6.2 // indirect
98
github.com/ahmetb/gen-crd-api-reference-docs v0.3.1-0.20220720053627-e327d0730470 // Waiting for https://github.com/ahmetb/gen-crd-api-reference-docs/pull/43/files to merge
109
github.com/cloudevents/sdk-go/v2 v2.15.2
1110
github.com/go-git/go-git/v5 v5.13.2
12-
github.com/google/go-cmp v0.6.0
11+
github.com/google/go-cmp v0.7.0
1312
github.com/google/go-containerregistry v0.20.2
1413
github.com/google/uuid v1.6.0
1514
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -30,8 +29,8 @@ require (
3029
gomodules.xyz/jsonpatch/v2 v2.4.0
3130
k8s.io/api v0.31.6
3231
k8s.io/apimachinery v0.31.6
33-
k8s.io/client-go v0.31.4
34-
k8s.io/code-generator v0.31.4
32+
k8s.io/client-go v0.31.6
33+
k8s.io/code-generator v0.31.6
3534
k8s.io/klog v1.0.0
3635
k8s.io/kube-openapi v0.0.0-20240808142205-8e686545bdb8
3736
knative.dev/pkg v0.0.0-20250117084104-c43477f0052b
@@ -40,12 +39,12 @@ require (
4039

4140
require (
4241
code.gitea.io/sdk/gitea v0.20.0
43-
github.com/go-jose/go-jose/v3 v3.0.3
42+
github.com/go-jose/go-jose/v3 v3.0.4
4443
github.com/goccy/kpoward v0.1.0
4544
github.com/google/cel-go v0.23.2
4645
github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20240108195214-a0658aa1d0cc
4746
github.com/sigstore/sigstore/pkg/signature/kms/aws v1.8.15
48-
github.com/sigstore/sigstore/pkg/signature/kms/azure v1.8.12
47+
github.com/sigstore/sigstore/pkg/signature/kms/azure v1.8.15
4948
github.com/sigstore/sigstore/pkg/signature/kms/gcp v1.8.15
5049
github.com/sigstore/sigstore/pkg/signature/kms/hashivault v1.8.15
5150
go.opentelemetry.io/otel v1.34.0
@@ -79,7 +78,7 @@ require (
7978
dario.cat/mergo v1.0.0 // indirect
8079
fortio.org/safecast v1.0.0 // indirect
8180
github.com/42wim/httpsig v1.2.1 // indirect
82-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 // indirect
81+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 // indirect
8382
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 // indirect
8483
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
8584
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.3.0 // indirect

go.sum

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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+
}

0 commit comments

Comments
 (0)