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

FIPS Compliance: Refactor Entrypoint, Remove zap Dependency & Update Build Checks #8544

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

PuneetPunamiya
Copy link
Member

@PuneetPunamiya PuneetPunamiya commented Jan 31, 2025

  • The Pipelines entrypoint is the only remaining component of Pipelines that is not yet FIPS compliant. It needs to be compiled statically, but currently, it includes crypto symbols
  • Hence, to make Tekton Pipelines FIPS compliant, the entrypoint command is a key step in this effort. Since it is statically compiled, we must ensure that cryptographic symbols are removed from the entrypoint binary.
  • The patch includes following changes
    • Removes zap and dependency where k8s API are included
    • Moves pipelines types to apis/pipeline/v1/types
    • Refactor and split metrics and adds disable_tls flag
    • Adds a build check in Github Actions CI Workflow

Fixes: #8531 (one part of the issue)

Changes

  • This patch uses logging with the standard library instead of using zap to ensure that we are not pulling in too many indirect dependencies into the entrypoint through the uber-go/zap module
  • The corev1 API package is now split because it imports crypto-related functions
  • Add a build tag disable_tls to conditionally exclude crypto related dependencies

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Jan 31, 2025
@tekton-robot tekton-robot requested review from dibyom and jerop January 31, 2025 05:23
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 31, 2025
@PuneetPunamiya
Copy link
Member Author

/kind-cleanup

@PuneetPunamiya PuneetPunamiya force-pushed the remove-zap-logger-from-entrypoint branch 2 times, most recently from b4c40b2 to d2c70d5 Compare January 31, 2025 05:40
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 88.1% 87.7% -0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 88.1% 87.5% -0.6

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 88.1% 87.5% -0.6

@PuneetPunamiya
Copy link
Member Author

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@PuneetPunamiya: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage

Use /test all to run all jobs.

In response to this:

/test check-pr-has-kind-label

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@PuneetPunamiya
Copy link
Member Author

/retest

@PuneetPunamiya
Copy link
Member Author

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@PuneetPunamiya: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage

Use /test all to run all jobs.

In response to this:

/test check-pr-has-kind-label

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@PuneetPunamiya
Copy link
Member Author

/test all

@PuneetPunamiya
Copy link
Member Author

/kind cleanup

@tekton-robot tekton-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jan 31, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 88.1% 87.5% -0.6

@@ -311,7 +307,8 @@ func (e Entrypointer) Go() error {
resultPath = e.ResultsDirectory
}
if err := e.readResultsFromDisk(ctx, resultPath, result.TaskRunResultType); err != nil {
logger.Fatalf("Error while handling results: %s", err)
slog.Error("Error while substituting step artifacts: ", slog.Any("error", err))
return err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why log.Fatalf is replaced with logger.Fatalf in other places, but why are slog.Error used in these two instances?

Copy link
Member Author

@PuneetPunamiya PuneetPunamiya Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good catch, I did use log.Fatalf but the issue was it was giving golang lint error as log.Fatalf will exit, and defer cancel() will not run, hence I did use slog.Error

@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 4, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 11.9% 14.3% 2.3
cmd/entrypoint/spire.go Do not exist 0.0%
pkg/apis/config/feature_flags.go 95.1% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifact_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/artifact_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/artifact_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 81.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/results_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/results_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/results_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 35.5%
pkg/entrypoint/entrypointer.go 88.1% 90.2% 2.2
pkg/entrypoint/spire.go Do not exist 0.0%
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4
pkg/termination/message/messae.go Do not exist 0.0%
pkg/termination/message/messae.go Do not exist 0.0%

@PuneetPunamiya PuneetPunamiya force-pushed the remove-zap-logger-from-entrypoint branch from 11834ef to d2c70d5 Compare February 4, 2025 09:35
@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 4, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 88.1% 87.5% -0.6

@PuneetPunamiya
Copy link
Member Author

/retest

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/entrypoint/runner.go 86.2% 82.8% -3.4
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifacts_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/result_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/entrypoint/entrypointer.go 88.1% 87.6% -0.5
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PuneetPunamiya it doesn't compile with disable_tls 🤔

go build -tags disable_tls ./cmd/entrypoint
# github.com/tektoncd/pipeline/pkg/apis/version
pkg/apis/version/featureflags_validation.go:24:39: undefined: config.ValidateEnabledAPIFields
# github.com/tektoncd/pipeline/pkg/apis/pipeline/v1
pkg/apis/pipeline/v1/container_validation.go:35:28: undefined: config.ValidateEnabledAPIFields
pkg/apis/pipeline/v1/container_validation.go:45:28: undefined: config.ValidateEnabledAPIFields
pkg/apis/pipeline/v1/container_validation.go:49:30: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/container_validation.go:62:15: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/matrix_types.go:296:39: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/param_types.go:156:14: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/param_types.go:332:23: undefined: substitution.ExtractArrayIndexingParamsExpressions
pkg/apis/pipeline/v1/param_types.go:334:31: undefined: substitution.ExtractIndexString
pkg/apis/pipeline/v1/param_types.go:583:34: undefined: substitution.StripStarVarSubExpression
pkg/apis/pipeline/v1/param_types.go:663:35: undefined: substitution.ValidateWholeArrayOrObjectRefInStringVariable
pkg/apis/pipeline/v1/param_types.go:663:35: too many errors

)

const (
TektonHermeticEnvVar = "TEKTON_HERMETIC"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is duplicated between here and pkg/pod or did we move it from pkg/pod to here ?
Ideally, if it's duplicated, we would need to move it to a constant package that we can import without having other packages imported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is duplicated
When you said we need to move it to a constant package you mean under pkd/pod/constants ?

@PuneetPunamiya
Copy link
Member Author

@PuneetPunamiya it doesn't compile with disable_tls 🤔

go build -tags disable_tls ./cmd/entrypoint
# github.com/tektoncd/pipeline/pkg/apis/version
pkg/apis/version/featureflags_validation.go:24:39: undefined: config.ValidateEnabledAPIFields
# github.com/tektoncd/pipeline/pkg/apis/pipeline/v1
pkg/apis/pipeline/v1/container_validation.go:35:28: undefined: config.ValidateEnabledAPIFields
pkg/apis/pipeline/v1/container_validation.go:45:28: undefined: config.ValidateEnabledAPIFields
pkg/apis/pipeline/v1/container_validation.go:49:30: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/container_validation.go:62:15: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/matrix_types.go:296:39: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/param_types.go:156:14: undefined: config.FromContextOrDefaults
pkg/apis/pipeline/v1/param_types.go:332:23: undefined: substitution.ExtractArrayIndexingParamsExpressions
pkg/apis/pipeline/v1/param_types.go:334:31: undefined: substitution.ExtractIndexString
pkg/apis/pipeline/v1/param_types.go:583:34: undefined: substitution.StripStarVarSubExpression
pkg/apis/pipeline/v1/param_types.go:663:35: undefined: substitution.ValidateWholeArrayOrObjectRefInStringVariable
pkg/apis/pipeline/v1/param_types.go:663:35: too many errors

These errors are because of spire package, and those things are handled in @jkhelil pr #8548, hence it gives the above errors

@vdemeester
Copy link
Member

These errors are because of spire package, and those things are handled in @jkhelil pr #8548, hence it gives the above errors

So we need to wait for #8548 to be merged right ?

/hold

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2025
@PuneetPunamiya PuneetPunamiya force-pushed the remove-zap-logger-from-entrypoint branch 2 times, most recently from f73b726 to 54b6e02 Compare March 3, 2025 17:58
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifacts_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/result_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/entrypoint/entrypointer.go 88.0% 87.5% -0.5
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifacts_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/result_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/entrypoint/entrypointer.go 88.0% 87.5% -0.5
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4

@PuneetPunamiya PuneetPunamiya force-pushed the remove-zap-logger-from-entrypoint branch from 54b6e02 to 2b76a2d Compare March 4, 2025 12:10
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifacts_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/result_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/entrypoint/entrypointer.go 88.0% 87.5% -0.5
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4

@PuneetPunamiya PuneetPunamiya force-pushed the remove-zap-logger-from-entrypoint branch from 2b76a2d to e6ffdb9 Compare March 4, 2025 12:26
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifacts_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/result_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/entrypoint/entrypointer.go 88.0% 87.5% -0.5
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4

@vdemeester
Copy link
Member

/retest

@PuneetPunamiya PuneetPunamiya force-pushed the remove-zap-logger-from-entrypoint branch from e6ffdb9 to fd1176e Compare March 4, 2025 13:23
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/entrypoint/runner.go 86.2% 84.5% -1.7
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifacts_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/result_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/entrypoint/entrypointer.go 88.0% 87.5% -0.5
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4

@PuneetPunamiya
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 4, 2025
go-version-file: "go.mod"
- name: build
run: |
go build -v -tags "disable_spire,disable_tls" ./cmd/entrypoint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maye be we can check the build for tls symbols ?
go tool nm bin/entrypoint | grep -E 'tls'
Or may be we need to check for crypto once Vibhav PR is merged
go tool nm bin/entrypoint | grep -E 'crypto|tls'

@PuneetPunamiya PuneetPunamiya changed the title Remove the use of go.uber.org/zap in entrypoint's dependent packages and uses log/slog FIPS Compliance: Refactor Entrypoint, Remove zap Dependency & Update Build Checks Mar 10, 2025
Signed-off-by: PuneetPunamiya <[email protected]>
This will help to verify the build for entrypoint
using `disable_tls` and `disable_spire` flags

Signed-off-by: PuneetPunamiya <[email protected]>
@PuneetPunamiya PuneetPunamiya force-pushed the remove-zap-logger-from-entrypoint branch from fd1176e to e627e0d Compare March 12, 2025 05:37
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/entrypoint/runner.go 82.8% 84.5% 1.7
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.1
pkg/apis/config/metrics.go 78.3% 77.3% -1.0
pkg/apis/config/metrics_tls.go Do not exist 100.0%
pkg/apis/pipeline/v1/types/artifacts_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/param_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/result_types.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/resultsref.go Do not exist 0.0%
pkg/apis/pipeline/v1/types/when_types.go Do not exist 0.0%
pkg/entrypoint/entrypointer.go 88.0% 87.5% -0.5
pkg/substitution/replacements.go Do not exist 100.0%
pkg/substitution/substitution.go 87.6% 86.2% -1.4

@jkhelil
Copy link
Member

jkhelil commented Mar 12, 2025

/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jkhelil
To complete the pull request process, please assign abayer after the PR has been reviewed.
You can assign the PR to them by writing /assign @abayer in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesnt merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Making pipeline (and entrypoint) FIPS complitant
6 participants