tektoncd / triggers

Event triggering with Tekton!
Apache License 2.0
545 stars 416 forks source link

Handle validation when value for runAsGroup and runAsUser is empty #1747

Closed savitaashture closed 1 day ago

savitaashture commented 4 days ago

Changes

As part of https://github.com/tektoncd/triggers/pull/1747/commits/48f257d9cc8539c9e05ad51536f403d43c43c96e and https://github.com/tektoncd/triggers/pull/1747/commits/add787c2d667ae8222d73d6a3257b7c703a49fed

As part of https://github.com/tektoncd/triggers/pull/1747/commits/848ccb06b94069ef7eb181737ebc67568c1f8ceb

Submitter Checklist

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

Release Notes

* Added new field default-run-as-non-root to config-defaults-triggers configmap so that RunAsNonRoot can be now configured through CM
tekton-robot commented 4 days ago

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

File Old Coverage New Coverage Delta
pkg/apis/config/default.go 88.9% 94.1% 5.2
tekton-robot commented 4 days ago

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

File Old Coverage New Coverage Delta
pkg/apis/config/default.go 88.9% 94.1% 5.2
pkg/reconciler/eventlistener/resources/container.go 100.0% 93.1% -6.9
pkg/reconciler/eventlistener/resources/custom.go 94.1% 93.3% -0.8
pkg/reconciler/eventlistener/resources/deployment.go 100.0% 98.4% -1.6
savitaashture commented 4 days ago

I think "0" shouldn't be allowed in both the vanilla k8s and OpenShift.

I think "0" shouldn't be allowed in both the vanilla k8s and OpenShift.

@khrm actually in doc and all it sayd 0 is valid and its a root but i tried it on kind and see a below error

      waiting:
        message: 'container''s runAsUser breaks non-root policy (pod: "el-github-listener-5878566fb4-hqt5r_default(086e7204-f323-499c-90a2-4b7e0e277e2d)",
          container: event-listener)'
        reason: CreateContainerConfigError

It might be because we have

    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        drop:
        - ALL
      runAsGroup: 0
      runAsNonRoot: true
      runAsUser: 0
      seccompProfile:
        type: RuntimeDefault

runAsNonRoot: true and setting 0 :thinking:


Alright i did verify runAsUser: 0 is failing because runAsNonRoot: true but 0 is valid and we cannot stop users to provide those value

khrm commented 4 days ago

Do we allow setting runAsNonRoot as false? If yes, then it might be a valid value.

savitaashture commented 4 days ago

Do we allow setting runAsNonRoot as false? If yes, then it might be a valid value.

Yes make sense handled here https://github.com/tektoncd/triggers/pull/1747/commits/848ccb06b94069ef7eb181737ebc67568c1f8ceb

tekton-robot commented 4 days ago

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

File Old Coverage New Coverage Delta
pkg/apis/config/default.go 88.9% 91.7% 2.8
pkg/reconciler/eventlistener/resources/container.go 100.0% 93.1% -6.9
pkg/reconciler/eventlistener/resources/custom.go 94.1% 93.3% -0.8
pkg/reconciler/eventlistener/resources/deployment.go 100.0% 98.4% -1.6
savitaashture commented 4 days ago

/test

savitaashture commented 4 days ago

@dibyom PR is ready to review PTAL thank you

tekton-robot commented 4 days ago

@savitaashture: The /test command needs one or more targets. The following commands are available to trigger required jobs:

The following commands are available to trigger optional jobs:

Use /test all to run all jobs.

In response to [this](https://github.com/tektoncd/triggers/pull/1747#issuecomment-2211194962): >/test Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
tekton-robot commented 4 days ago

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

File Old Coverage New Coverage Delta
pkg/apis/config/default.go 88.9% 88.2% -0.7
tekton-robot commented 4 days ago

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

File Old Coverage New Coverage Delta
pkg/apis/config/default.go 88.9% 88.2% -0.7
tekton-robot commented 1 day ago

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

File Old Coverage New Coverage Delta
pkg/apis/config/default.go 88.9% 88.2% -0.7
savitaashture commented 1 day ago

/test tekton-triggers-unit-tests

savitaashture commented 1 day ago

/test tekton-triggers-unit-tests

savitaashture commented 1 day ago

Let's rebase these. @savitaashture We can merge the PR then.

@khrm Done Its ready now

tekton-robot commented 1 day ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: khrm

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

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/tektoncd/triggers/blob/main/OWNERS)~~ [khrm] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
vdemeester commented 1 day ago

/lgtm