Keep the Step SecurityContext when the StepAction has none - #10657
Open
arpitjain099 wants to merge 1 commit into
Open
Keep the Step SecurityContext when the StepAction has none#10657arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
resolveStepRef guards every merged field so that a StepAction only overrides the referencing Step where it actually sets a value, except SecurityContext, which is assigned unconditionally. A StepAction that leaves SecurityContext unset therefore replaces the Step's with nil, dropping settings such as runAsNonRoot and readOnlyRootFilesystem without any indication. StepActionSpec.SetDefaults only walks Params and Results, so nothing fills SecurityContext in before the merge. Guard the assignment the same way Command, Args, Script, Env, VolumeMounts and Results are already guarded, and add a case to TestGetStepActionsData covering a StepAction with no SecurityContext. Fixes tektoncd#10634 Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Collaborator
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
resolveStepRefmerges a resolved StepAction into the Step that referenced it, and every field is guarded so the StepAction only wins where it actually set something.SecurityContextis the exception:A StepAction that leaves
securityContextunset therefore overwrites the Step's with nil.StepActionSpec.SetDefaultsonly walksParamsandResults, so nothing fills it in before the merge and the nil really does reach the assignment.This guards it the same way
Command,Args,Script,Env,VolumeMountsandResultsalready are.Fixes #10634
/kind bug
/area api
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepExisting coverage kept the "StepAction sets a securityContext" direction (
step-action-with-security-context-overwritten); the new case is its sibling for the unset direction, withrunAsUser,runAsNonRootandreadOnlyRootFilesystemon the Step. Without the guard it fails:go build ./...,go vetandgo test ./pkg/reconciler/taskrun/...are clean.Release Notes