-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add audited copy (cp) command #68
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
Open
ielshal
wants to merge
2
commits into
main
Choose a base branch
from
ibrahim/implemenet-copy-command-into-kubectl-rexec
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
22f5266 to
17a06a7
Compare
|
17a06a7 to
7b37706
Compare
7b37706 to
f895e6a
Compare
f895e6a to
aedf702
Compare
aedf702 to
5e606bb
Compare
- Enforce strict security: block uploads and path traversal - Add comprehensive tests and docs
5e606bb to
732c4f1
Compare
f317146 to
6d9ea55
Compare
6d9ea55 to
5753cf2
Compare
|
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.



Summary
We are using rexec for recorded access for containers inside k8s clusters. For webapps and jobs we also need copy functionality. Since kubectl cp depends on exec, we implemented our own copy using rexec.
Security Reasons: Only copying FROM pods is supported (download only). Copying TO pods is intentionally disabled for security reasons.
Changes in this PR
kubectl rexec cpfor audited file transfers (download only)Unit Testing
Manual Testing
Setup Test Environment
Test Cases
1. Basic Exec
2. File Download
3. Directory Download
4. Multi-Container Pod
5. Upload Blocked (Security)
Audit Logs
kubectl -n kube-system logs -l app=rexec --tail=5 {"level":"info","facility":"audit","user":"kubernetes-admin","session":"oneoff","command":"tar cf - -C /tmp -- download.txt","time":"2026-01-23T14:43:04Z"} {"level":"info","facility":"audit","user":"kubernetes-admin","session":"oneoff","command":"sh -c mkdir -p /tmp/testdir/sub && echo \"file1\" > /tmp/testdir/file1.txt && echo \"file2\" > /tmp/testdir/sub/file2.txt","time":"2026-01-23T14:43:30Z"} {"level":"info","facility":"audit","user":"kubernetes-admin","session":"oneoff","command":"tar cf - -C /tmp -- testdir","time":"2026-01-23T14:43:34Z"} {"level":"info","facility":"audit","user":"kubernetes-admin","session":"oneoff","command":"sh -c echo \"from c2\" > /tmp/test.txt","time":"2026-01-23T14:44:29Z"} {"level":"info","facility":"audit","user":"kubernetes-admin","session":"oneoff","command":"tar cf - -C /tmp -- test.txt","time":"2026-01-23T14:44:34Z"}Cleanup
Fixed issue:
As mentioned we are introducing new feature so nothing to be fixed, the idea is to implement kubectl cp using rexec.