-
Notifications
You must be signed in to change notification settings - Fork 1
feat(allowedpaths): prepend /host to symlink targets in containers #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
863a9b3
feat(allowedpaths): prepend /host to symlink targets in containers
matt-dz c553417
feat(allowedpaths): prepend host mount prefix to symlink targets in c…
matt-dz d05ae76
feat(allowedpaths): add HostPrefix option and scenario test for conta…
matt-dz abd098f
test(allowedpaths): add container host prefix scenario tests
matt-dz 277fd7c
fix(allowedpaths): always prepend host prefix in container mode
matt-dz ea52030
fix(tests): skip containerized scenario tests on Windows
matt-dz 885371c
fix(allowedpaths): normalize host prefix in SetHostPrefix
matt-dz 05e1891
docs(allowedpaths): document why host prefix is always prepended
matt-dz f4ebd48
fix(interp): make HostPrefix order-independent
matt-dz cf58cb9
test(interp): verify HostPrefix works in any option order
matt-dz 45ac08b
refactor: rename GetHostPrefix to HostPrefix, avoid double-loading sc…
matt-dz fd33dcd
fix(tests): skip HostPrefix tests on Windows
matt-dz 202abe0
refactor(allowedpaths): make containerization user-configurable
matt-dz 614609e
fix(allowedpaths): skip host prefix for relative symlinks already und…
matt-dz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
48 changes: 48 additions & 0 deletions
48
tests/scenarios/shell/allowed_paths/container_host_prefix_file_commands.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| description: File-reading commands work through container symlinks with host-absolute targets | ||
| # skip: container host-prefix symlink resolution is an rshell-specific feature | ||
| skip_assert_against_bash: true | ||
| containerized: true | ||
| setup: | ||
| files: | ||
| - path: host/var/log/pods/app/0.log | ||
| content: | | ||
| line1 | ||
| line2 | ||
| line3 | ||
| line4 | ||
| line5 | ||
| - path: host/var/log/containers/app.log | ||
| symlink: /var/log/pods/app/0.log | ||
| input: | ||
| allowed_paths: ["host/var/log"] | ||
| script: |+ | ||
| echo "=== cat ===" | ||
| cat host/var/log/containers/app.log | ||
| echo "=== head ===" | ||
| head -n 2 host/var/log/containers/app.log | ||
| echo "=== tail ===" | ||
| tail -n 2 host/var/log/containers/app.log | ||
| echo "=== wc ===" | ||
| wc -l host/var/log/containers/app.log | ||
| echo "=== grep ===" | ||
| grep line3 host/var/log/containers/app.log | ||
| expect: | ||
| stdout: |+ | ||
| === cat === | ||
| line1 | ||
| line2 | ||
| line3 | ||
| line4 | ||
| line5 | ||
| === head === | ||
| line1 | ||
| line2 | ||
| === tail === | ||
| line4 | ||
| line5 | ||
| === wc === | ||
| 5 host/var/log/containers/app.log | ||
| === grep === | ||
| line3 | ||
| stderr: |+ | ||
| exit_code: 0 |
22 changes: 22 additions & 0 deletions
22
tests/scenarios/shell/allowed_paths/container_host_prefix_grep.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| description: grep works through container symlinks with host-absolute targets | ||
| # skip: container host-prefix symlink resolution is an rshell-specific feature | ||
| skip_assert_against_bash: true | ||
| containerized: true | ||
| setup: | ||
| files: | ||
| - path: host/var/log/pods/app/0.log | ||
| content: | | ||
| INFO starting up | ||
| ERROR something broke | ||
| INFO recovered | ||
| - path: host/var/log/containers/app.log | ||
| symlink: /var/log/pods/app/0.log | ||
| input: | ||
| allowed_paths: ["host/var/log"] | ||
| script: |+ | ||
| grep ERROR host/var/log/containers/app.log | ||
| expect: | ||
| stdout: |+ | ||
| ERROR something broke | ||
| stderr: |+ | ||
| exit_code: 0 |
19 changes: 19 additions & 0 deletions
19
tests/scenarios/shell/allowed_paths/container_host_prefix_ls.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| description: ls can list files through container symlinks with host-absolute targets | ||
| # skip: container host-prefix symlink resolution is an rshell-specific feature | ||
| skip_assert_against_bash: true | ||
| containerized: true | ||
| setup: | ||
| files: | ||
| - path: host/var/log/pods/pod-abc/0.log | ||
| content: "pod log\n" | ||
| - path: host/var/log/containers/app.log | ||
| symlink: /var/log/pods/pod-abc/0.log | ||
| input: | ||
| allowed_paths: ["host/var/log"] | ||
| script: |+ | ||
| ls host/var/log/containers/ | ||
| expect: | ||
| stdout: |+ | ||
| app.log | ||
| stderr: |+ | ||
| exit_code: 0 |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.