-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 CLI flags for Swarm Service seccomp, AppArmor, and no-new-privileges #5698
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5698 +/- ##
==========================================
+ Coverage 59.51% 59.62% +0.11%
==========================================
Files 346 346
Lines 29379 29487 +108
==========================================
+ Hits 17486 17583 +97
- Misses 10923 10932 +9
- Partials 970 972 +2 |
cli/command/service/opts_test.go
Outdated
const testJson = `{ | ||
"json": "you betcha" | ||
} | ||
` |
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.
Looks like the linter complains on this one;
68.89 cli/command/service/opts_test.go:376:7: ST1003: const testJson should be testJSON (stylecheck)
68.89 const testJson = `{
68.89 ^
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.
Looks like this const is only used in the test below, so perhaps consider defining the const inside that test. Give that it's a very small JSON, perhaps put it on one line?
const testJSON = `{"json": "you betcha"}`
Oh; I guess that also means changing the file to be the same , well 😂
c1cec5b
to
b10de33
Compare
What is done:
What needs to be done still:
What I have up now is ready for review, even in its incomplete state, but not ready for merging. |
2ba8aa5
to
7832807
Compare
cli/command/service/opts.go
Outdated
// TODO(dperny): is it safe/secure to unconditionally read a file like | ||
// this? what if the file is REALLY BIG? is that a user problem for | ||
// passing a too-big file, or an us problem for ingesting it | ||
// unquestioningly? | ||
data, err := os.ReadFile(options.seccomp) |
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.
IMO it's the user's problem. The flag value is always a file path, except when it isn't; not reading a local file is the astonishing case. It's on them if the CLI process gets OOM-killed because they chose the wrong file.
That being said, interpreting any value aside from the special cases as a file path leaves no room to add new special cases, like additional seccomp modes. Adding a new special case would result in the flag --seccomp=foo
changing semantics from reading a local file to whatever the special case is --- a breaking change.
I suggest that only values containing a path separator character be interpreted as a path to a custom seccomp profile. That cleanly solves several problems at once.
- Loading a custom profile from a file is always explicit and unambiguous. Users wanting to use a profile located in the CWD would have to pass
--seccomp=./my-custom-profile.json
in much the same way that a shell user has to type./my-script.sh
to run an executable from the CWD. - All values not containing a slash or backslash character (aside from
default
andunconfined
) are reserved for future use.
cli/command/service/opts.go
Outdated
// TODO(dperny): return this, or return "unrecognized option" or some such? | ||
return nil, errors.Wrap(err, "unable to read seccomp custom profile 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.
Return this. The CLI understands the option and what the user requested. We should tell the user why reading the file failed so they can take corrective action: fix the typo in the file name, sort out file permissions, etc.
272aa4a
to
a5b78ec
Compare
Adds CLI flags for setting some security options on services: * --seccomp to set seccomp mode or custom profile * --apparmor to default or disable apparmor * --no-new-privileges, same as with containers Adds seccomp, apparmor, and no-new-privileges flags to docker compose for docker stack command Signed-off-by: Drew Erny <derny@mirantis.com>
a5b78ec
to
b66fa05
Compare
- What I did
Add 3 flags to the
docker service create
anddocker service update
CLI commands to support the security options in moby/moby#46386.--apparmor
allows setting AppArmor todefault
ordisabled
.--no-new-privileges
does what it says on the tin--seccomp
allows eitherdefault
,unconfined
, or a file name of a JSON file with a custom seccomp profile.- How I did it
Added CLI flags in the standard way. Mostly boilerplate.
- How to verify it
Added tests for the flags.
- Description for the changelog