-
Notifications
You must be signed in to change notification settings - Fork 404
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 support for setting POSIX capabilities on the binary generated by Go #1098
Conversation
03e9ef9
to
603c08c
Compare
@cpanato Do you have an initial opinion on this PR? |
This change looks good! Sorry it's taken so long to review it. We'll want to regenerate the CLI docs to pass CI, and probably add docs to the website to describe how/why you'd use this. An e2e test that builds and runs Thanks for this contribution, and sorry again for taking so long to get to it. |
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #1098 +/- ##
==========================================
- Coverage 49.19% 47.54% -1.65%
==========================================
Files 44 45 +1
Lines 3653 3786 +133
==========================================
+ Hits 1797 1800 +3
- Misses 1624 1752 +128
- Partials 232 234 +2
|
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
4e32cdd
to
207568f
Compare
Definitely a feature I'm interested in. Is there any prior art here re: the UX of this flag? |
Answering my own question: I see that |
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@@ -177,3 +177,11 @@ func WithSBOMDir(dir string) Option { | |||
return nil | |||
} | |||
} | |||
|
|||
// WithPOSIXCapabilities is a functional option for overriding the POSIX capabilities encoded in the binary file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: How would you feel about WithPOSIXCapabilities(caps ...Cap)
so that callers don't have to wrap it in a []Cap
themselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because WithPOSIXCapabilities
overwrites the capabilities slice, I prefer the []Cap
argument.
...Cap
makes me think that the function will append the capabilities to the slice.
Maybe it's just me who thinks that. Please let me know if that is the case & I'll update the code.
type Cap int | ||
|
||
// POSIX-draft defined capabilities. | ||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd feel comfortable taking a dependency on https://pkg.go.dev/github.com/syndtr/gocapability instead of having to maintain our own copy here. Or if there's a better package to depend on, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that library does not have a good FromString
method that we can use.
I found that containerd defines its list of capabilities here: https://github.com/containerd/containerd/blob/v1.7.3/pkg/cap/cap_linux.go#L133-L187
& added some capabilities to the file to match their list.
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@imjasonh @jonjohnsonjr WDYT about the latest changes? Is this ready to be merged? |
This Pull Request is stale because it has been open for 90 days with |
To prevent an application from being swapped to disk, we use
mlock
(prevents writing private keys to disk).However, this requires the POSIX CAP_IPC_LOCK capability to be set on the binary file.
This PR adds the option to specify what capabilities to set on the binary file.
NOTE for reviewer:
Would it be possible to get some feedback on whether this feature would be accepted in ko (regardless of the implementation)?