build icon indicating copy to clipboard operation
build copied to clipboard

Add securityContext of ReadOnlyRootFilesystem to steps

Open hasanawad94 opened this issue 6 months ago • 8 comments

Changes

Explicitly set readOnlyRootFilesystem to true for taskruns according to security best practice.

Submitter Checklist

  • [x] Includes tests if functionality changed/was added
  • [ ] Includes docs if changes are user-facing
  • [ ] Set a kind label on this PR
  • [x] Release notes block has been filled in, or marked NONE

See the contributor guide for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

NONE

hasanawad94 avatar May 13 '25 11:05 hasanawad94

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign apoorvajagtap for approval. For more information see the Code Review Process.

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

openshift-ci[bot] avatar May 13 '25 11:05 openshift-ci[bot]

Fixing tests after adding the default value

hasanawad94 avatar May 13 '25 12:05 hasanawad94

/retest

hasanawad94 avatar May 13 '25 13:05 hasanawad94

@hasanawad94: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

openshift-ci[bot] avatar May 13 '25 13:05 openshift-ci[bot]

/ok-to-test

sayan-biswas avatar May 13 '25 22:05 sayan-biswas

@sayan-biswas: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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-sigs/prow repository.

openshift-ci[bot] avatar May 13 '25 22:05 openshift-ci[bot]

Currently working on Image processing part

hasanawad94 avatar May 18 '25 15:05 hasanawad94

Working on the bundle part now

hasanawad94 avatar May 21 '25 17:05 hasanawad94

Thanks for the review @SaschaSchwarze0 ! I'm currently making the directories configurable through environment variables to ensure the solution is both flexible and easy to configure.

Regarding the /shared-home directory it conflicts with the new security settings, so I'm considering redirecting HOME to a writable location to resolve that issue.

As for the build strategies, I'm still evaluating the best approach there.

hasanawad94 avatar May 27 '25 09:05 hasanawad94

@SaschaSchwarze0 Could you please take a look at the current progress? I’m still in the process of verifying that redirecting /shared-home to a volume doesn’t cause any regressions.

Here’s a summary of the changes made so far:

  • Image Processing (Trivy): Trivy was previously writing its cache and temporary files to the root filesystem. This has been redirected to a mounted volume.
  • Waiter Container: It was writing a lockfile to the root filesystem. This has now been reconfigured to write to a volume.
  • Git Container: Writes to /tmp have been redirected to a volume instead of the root filesystem.
  • Bundle Container: It was using the root filesystem in its configured working directory. This too has been redirected to use a volume.

hasanawad94 avatar May 29 '25 15:05 hasanawad94

Made minimal changes to match the requirements and to make the review easier. @SaschaSchwarze0 would you kindly have a look now. I have removed the /shared-home directory after making the Home directory configurable to a writable volume that also has .ssh and .docker as like it was for the /shared-home on the rootfs.

hasanawad94 avatar Jun 10 '25 09:06 hasanawad94

@SaschaSchwarze0 tests are a bit flaky here since they were passing before modifying the commit message

hasanawad94 avatar Jun 11 '25 09:06 hasanawad94

Hey @SaschaSchwarze0 I did a manual testing of using a git private key with buildah strategy using managed push with the changes and the buildrun was successful.

hasanawad94 avatar Jun 27 '25 09:06 hasanawad94

@SaschaSchwarze0 You think we can get this into v0.17 as a better security practice ? Summary of changes :

  • Home directory volume has been added to each container (not shared)
  • Volume for trivy to work with
  • Volumes for buildstrategies to use instead of writing to the rootfs (tmp,home)

hasanawad94 avatar Jul 25 '25 09:07 hasanawad94

@SaschaSchwarze0 I want to break this pr into smaller parts to make the review easier

hasanawad94 avatar Jul 30 '25 14:07 hasanawad94