Skip to content
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

tests: k8s: k8s-copy-file auto-generated policy #9051

Merged
merged 5 commits into from Feb 9, 2024

Conversation

danmihai1
Copy link
Contributor

Auto-generate policy for k8s-copy-file.bats.

Fixes: #9050

@katacontainersbot katacontainersbot added the size/large Task of significant size label Feb 7, 2024
1. Remove PullImageRequest because that is not used in the main
   branch. It was used in the CCv0 branch.

2. Add default false values for the remaining Kata Agent ttrpc
   requests.

These changes don't change the functionality of the auto generated
Policy, but they help with easier understanding the Policy text and
the logging from the Rego rules.

Fixes: kata-containers#9049

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
For example, Kata CI's k8s-copy-file.bats transfers files between the
Host and the Guest using "kubectl exec", and that results in
CloseStdinRequest being called from the Host.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
Additional logging from the ExecProcessRequest rules, for easier
debugging.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
@ChengyuZhu6
Copy link
Member

minor nit in the forth commit 😉: tests: k8s: addional policy testing utilities > tests: k8s: additional policy testing utilities

1. add_requests_to_policy_settings allows one or more ttrpc requests
   from the Host to the Guest. Example:

add_requests_to_policy_settings "${policy_settings_dir}" \
   "ReadStreamRequest" "WriteStreamRequest"

2. add_copy_from_host_to_policy_settings allows executing on the Guest
   the commands initiated behind the scenes by "kubectl cp" from the
   Host to the Guest. Example:

add_copy_from_host_to_policy_settings "${policy_settings_dir}"

3. add_copy_from_guest_to_policy_settings allows executing on the Guest
   the commands initiated behind the scenes by "kubectl cp" from the
   Guest to the Host. Example:

add_copy_from_guest_to_policy_settings "${policy_settings_dir}" \
   "/tmp/file.txt"

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
Auto-generate policy for k8s-copy-file.bats.

Fixes: kata-containers#9050

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
@danmihai1
Copy link
Contributor Author

minor nit in the forth commit 😉: tests: k8s: addional policy testing utilities > tests: k8s: additional policy testing utilities

Fixed - thanks!

@danmihai1
Copy link
Contributor Author

/test

Copy link
Member

@ChengyuZhu6 ChengyuZhu6 left a comment

Choose a reason for hiding this comment

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

LGTM ! Thanks @danmihai1

@danmihai1 danmihai1 merged commit a054462 into kata-containers:main Feb 9, 2024
297 of 302 checks passed
@danmihai1 danmihai1 deleted the danmihai1/k8s-copy-file branch March 29, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test size/large Task of significant size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests: k8s: add auto-generated Policy to k8s-copy-file.bats
5 participants