Skip to content

Don't skip symlinks during local source upload - #355

Open
dollierp wants to merge 1 commit into
shipwright-io:mainfrom
dollierp:symlinks
Open

Don't skip symlinks during local source upload#355
dollierp wants to merge 1 commit into
shipwright-io:mainfrom
dollierp:symlinks

Conversation

@dollierp

@dollierp dollierp commented Nov 6, 2025

Copy link
Copy Markdown

Changes

Don't skip symlinks during local source upload

/kind bug

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • 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

Content from symlinks is included during local source upload

@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 6, 2025
@openshift-ci openshift-ci Bot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 6, 2025

@IrvingMg IrvingMg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

Overall, LGTM. I left a couple of comments. It would also be nice to have unit tests for at least basic cases, as the changes are related to the core functionality of the upload command.

Comment thread pkg/shp/streamer/tar.go Outdated
Comment thread pkg/shp/streamer/util.go
Copilot AI review requested due to automatic review settings April 6, 2026 13:28
@dollierp

dollierp commented Apr 6, 2026

Copy link
Copy Markdown
Author

Hi @IrvingMg,

Thanks for your review.

I updated the PR with new changes trying to address your remarks.

Regards,

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where symlinks were being skipped during local source uploads. Previously, the tar helper would skip any file that wasn't a regular file (including symlinks, directories, and other special file types). The changes now allow symlinks to be included in the tar archive while still skipping unsupported file types.

Changes:

  • Modified skipPath function to exclude symlinks from being skipped (allowing them to be processed)
  • Added symlink handling in writeFileToTar to read symlink targets, detect if they point outside the source directory, and properly set the tar header linkname
  • Added isSymlinkTargetOutsideOfDir function to check if symlink targets escape the source directory and warn appropriately
  • Updated test to verify that symlinks are captured in the tar archive
  • Fixed documentation from "buildrun" to "build" command references

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/shp/streamer/tar.go Modified skipPath condition to allow symlinks through filtering
pkg/shp/streamer/util.go Added symlink handling logic with safety check for targets pointing outside source directory
pkg/shp/streamer/tar_test.go Enhanced test to verify symlinks are included in tar output
pkg/shp/cmd/build/upload.go Fixed documentation typo from "buildrun" to "build"
docs/shp_build_upload.md Updated documentation examples to match corrected command

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/shp/streamer/util.go Outdated
@dollierp
dollierp requested a review from IrvingMg April 6, 2026 13:37
@IrvingMg

IrvingMg commented Apr 8, 2026

Copy link
Copy Markdown
Member

Hi @dollierp, thanks for the changes.

There’s one more Copilot comment, could you take a look?

@dollierp

dollierp commented Apr 8, 2026

Copy link
Copy Markdown
Author

Hi @IrvingMg,

I updated the PR to make Copilot happy.

Let me know if something else is missing.

Regards.

@IrvingMg IrvingMg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks again for the changes. I left a couple more comments.

Comment thread pkg/shp/streamer/util.go Outdated
Comment thread test/symlink/symlink_inside_tree Outdated
@pull-request-size pull-request-size Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 9, 2026
@dollierp
dollierp requested a review from Copilot April 9, 2026 18:06
@dollierp

dollierp commented Apr 9, 2026

Copy link
Copy Markdown
Author

Hi @IrvingMg,

I tried to address your latest remarks and updated the PR.

Regards,

@dollierp
dollierp requested a review from IrvingMg April 9, 2026 19:03

@IrvingMg IrvingMg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the update, looks good overall. Just a few final comments from my side.

Comment thread pkg/shp/streamer/util.go
Comment thread pkg/shp/streamer/tar_test.go Outdated
Comment thread pkg/shp/streamer/tar_test.go Outdated
Comment thread pkg/shp/streamer/tar_test.go Outdated
@dollierp

Copy link
Copy Markdown
Author

Hi @IrvingMg,

I've tried to incorporate your latest feedback and have updated the pull request.

Regards,

@dollierp
dollierp requested a review from IrvingMg April 11, 2026 08:48

@IrvingMg IrvingMg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the changes! Overall /lgtm

@shipwright-io/approvers PTAL, this PR has been open for a while.

@IrvingMg

Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 22, 2026
@adambkaplan

Copy link
Copy Markdown
Member

/lgtm cancel

Due to failing lint check.

@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 22, 2026
@dollierp

Copy link
Copy Markdown
Author

Hi @adambkaplan,

I updated the PR to fix the \n lint issue.

Regards.

@adambkaplan

Copy link
Copy Markdown
Member

@dollierp one last item - please squash your commits using an interactive rebase, and provide a well written commit message.

Side note for @shipwright-io/contributors - we should add commit squashing and commit message guidance to our Contributor Guide.

@dollierp

Copy link
Copy Markdown
Author

Hi @adambkaplan,

I squashed the commits into a single one and improved its message to match the guidelines.

Regards,

@adambkaplan

Copy link
Copy Markdown
Member

/lgtm

Failed e2e test appears to be a flake. Re-running (which will gate merge until it passes).

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 23, 2026
@IrvingMg

Copy link
Copy Markdown
Member

@adambkaplan Could we retry the E2E job so that we can merge this PR?

@shipwright-io shipwright-io deleted a comment from openshift-ci Bot Jun 3, 2026
@sayan-biswas

Copy link
Copy Markdown
Contributor

/retest

@shipwright-io shipwright-io deleted a comment from openshift-ci Bot Jun 3, 2026
@sayan-biswas

Copy link
Copy Markdown
Contributor

/test all

@openshift-ci

openshift-ci Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

@sayan-biswas: No presubmit jobs available for shipwright-io/cli@main

Details

In response to this:

/test all

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.

@IrvingMg IrvingMg closed this Aug 22, 2026
@github-project-automation github-project-automation Bot moved this to Done in Issues Aug 22, 2026
@IrvingMg IrvingMg reopened this Aug 22, 2026
@openshift-ci openshift-ci Bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 22, 2026
@IrvingMg

Copy link
Copy Markdown
Member

Closing and reopening the PR to retrigger the checks.

Until now, the `shp build upload <build-name> /path` command would
silently discard symbolic links when walking through a local source
directory.

This is not backward compatible with the `oc start-build <build-name>
--from-dir=/path` command which supports symbolic links.

This change adds support for symbolic links to Shipwright cli to match
the legacy OpenShift build commands.

To prevent the type of vulnerability described by CWE-61 [1], an additional
security measure is implemented: an error is raised upon detecting a
symbolic link that points to a file outside the provided directory.

[1]: https://cwe.mitre.org/data/definitions/61.html

Signed-off-by: Denis Ollier <dollierp@redhat.com>
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2026
@IrvingMg

Copy link
Copy Markdown
Member

Rebased

@IrvingMg

Copy link
Copy Markdown
Member

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2026
@openshift-ci

openshift-ci Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants