Skip to content

fix: enforce path validation for push/attach and improve path traversal failure message for pull#988

Merged
qweeah merged 15 commits into
oras-project:mainfrom
suganyas:main
Jun 28, 2023
Merged

fix: enforce path validation for push/attach and improve path traversal failure message for pull#988
qweeah merged 15 commits into
oras-project:mainfrom
suganyas:main

Conversation

@suganyas

@suganyas suganyas commented Jun 26, 2023

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
I just tried to push an artifact file from linux environment from a absolute path or from different directory. The path is implicitly taken by the oras cli or oras sdk when I pushed it. Like the file was in a directory /home/vts/1/a.exe. and I pushed from /home/test. I am ok if the push fails stating me that the file is not in the current directory and for security reasons you have to be in same working directory. But the push passes and pull fails . So disallow is a much better option. I am sure when I used ORAS python SDK it did fail with error stating as here https://github.com/oras-project/oras-py/blob/209c9b98043a00d1b04789cc2967ca7021dc5b2e/oras/provider.py#L651 . The CLI should have same behaviour as SDK. Then push and pull are coherent. It can be a bad experience when push is ok and pull fails and when different people do it can be hard for people to understand why it fails and also cross platform can fail if it is not intentional

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #
#980
#983
#978
Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Screenshot showing the scenarios tested

Screenshot 2023-06-26 at 10 13 47 pm

@suganyas suganyas changed the title Fixes for default behaviour handling abs path in push and attach and improvise pull failure message Fixes for default behaviour handling abs path in oras push and attach and improvise oras pull failure message for path traversal Jun 26, 2023
@qweeah

qweeah commented Jun 27, 2023

Copy link
Copy Markdown
Contributor

Can you help rename the PR following the conventional commits? Thanks

@codecov-commenter

codecov-commenter commented Jun 27, 2023

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 36.84211% with 12 lines in your changes missing coverage. Please review.

Project coverage is 80.94%. Comparing base (bf33bb7) to head (ae964ec).
Report is 330 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/internal/option/packer.go 43.75% 6 Missing and 3 partials ⚠️
cmd/oras/root/pull.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #988      +/-   ##
==========================================
- Coverage   81.26%   80.94%   -0.33%     
==========================================
  Files          53       53              
  Lines        2776     2792      +16     
==========================================
+ Hits         2256     2260       +4     
- Misses        352      360       +8     
- Partials      168      172       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@suganyas suganyas changed the title Fixes for default behaviour handling abs path in oras push and attach and improvise oras pull failure message for path traversal fix: default behaviour handling abs path in oras push and attach and improvise oras pull failure message for path traversal Jun 27, 2023
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/root/pull.go Outdated
Comment thread cmd/oras/root/pull.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/root/pull.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
@qweeah qweeah changed the title fix: default behaviour handling abs path in oras push and attach and improvise oras pull failure message for path traversal fix: enforce path validation for push/attach and improve path traversal failure message for pull Jun 28, 2023

@qweeah qweeah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

suganyas and others added 11 commits June 28, 2023 08:39
…ttach

Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
@shizhMSFT shizhMSFT added this to the v1.1.0 milestone Jun 28, 2023
Comment thread cmd/oras/internal/option/packer.go Outdated
Comment thread cmd/oras/root/pull.go Outdated
Comment thread cmd/oras/internal/option/packer.go Outdated
suganyas and others added 3 commits June 28, 2023 19:50
Co-authored-by: Shiwei Zhang <shizh@microsoft.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Shiwei Zhang <shizh@microsoft.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Shiwei Zhang <shizh@microsoft.com>
Signed-off-by: suganyas <ssuganyatce@gmail.com>

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@qweeah qweeah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@qweeah qweeah merged commit 99c55ce into oras-project:main Jun 28, 2023
shizhMSFT added a commit to shizhMSFT/oras that referenced this pull request Aug 3, 2023
…al failure message for pull (oras-project#988)

Signed-off-by: suganyas <ssuganyatce@gmail.com>
Co-authored-by: Billy Zha <qweeah@gmail.com>
Co-authored-by: Shiwei Zhang <shizh@microsoft.com>
njelich added a commit to njelich/publish-feature that referenced this pull request Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

4 participants