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

Add spoc run command #1534

Merged
merged 1 commit into from
Mar 10, 2023
Merged

Add spoc run command #1534

merged 1 commit into from
Mar 10, 2023

Conversation

saschagrunert
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

This allows to run a seccomp profile for a custom command or binary.

Which issue(s) this PR fixes:

Refers to #1482

Does this PR have test?

Yes

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

Added `spoc run` command for experimental testing of seccomp profiles.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 9, 2023
@saschagrunert
Copy link
Member Author

@kubernetes-sigs/security-profiles-operator-maintainers PTAL

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 10, 2023
@JAORMX
Copy link
Contributor

JAORMX commented Mar 10, 2023

/lgtm cancel

Let's wait for another maintainer to review.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 10, 2023
Comment on lines +44 to +45
SetupSeccomp(*specs.LinuxSeccomp) (*configs.Seccomp, error)
InitSeccomp(*configs.Seccomp) (int, error)
Copy link
Member

Choose a reason for hiding this comment

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

It would be great if we could have a more generic API, in which we could send different types of security profile enforcer (seccomp, apparmor, selinux, etc..). But as this is internal, we can do that at a later stage.

Comment on lines +73 to +82
log.Print("Setting up seccomp")
libConfig, err := r.SetupSeccomp(runtimeSpecConfig)
if err != nil {
return fmt.Errorf("convert profile: %w", err)
}

log.Print("Load seccomp profile")
if _, err := r.InitSeccomp(libConfig); err != nil {
return fmt.Errorf("init profile: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

More for a follow-up: I am not sure the difference between Init and Setup. For other enforcers, maybe things like Init and Load, or Init and Enforce.

Assuming that the former initialises the enforcer and the latter actually applies it to the target application/process.

@pjbgf
Copy link
Member

pjbgf commented Mar 10, 2023

Great idea and implementation! Who needs ChatGPT when @saschagrunert is around! 🦾 🚀

Adding a hold in case other folks may want to comment before the merge.

/lgtm
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 10, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 10, 2023
This allows to run a seccomp profile for a custom command or binary.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 10, 2023
Copy link
Contributor

@ccojocar ccojocar left a comment

Choose a reason for hiding this comment

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

Great work!

I am wondering if is not more appropriate to name this command "validate" instead of "run" since this seems more inline with the purpose of the command.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 10, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ccojocar, JAORMX, saschagrunert

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JAORMX,ccojocar,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@saschagrunert
Copy link
Member Author

Awesome, yeah we can follow-up on the other topics since I'm also planning to push more docs and testing around the features. I just updated the PR to propagate the correct exit code via spoc run.

@saschagrunert
Copy link
Member Author

/unhold

Thanks for all the reviews!

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 10, 2023
@k8s-ci-robot k8s-ci-robot merged commit 75c1592 into kubernetes-sigs:main Mar 10, 2023
@saschagrunert saschagrunert deleted the run branch March 10, 2023 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants