Make docker pull detect plugin content and error out.#25582
Make docker pull detect plugin content and error out.#25582aaronlehmann merged 1 commit intomoby:masterfrom
docker pull detect plugin content and error out.#25582Conversation
|
Got a golint failure; |
22cceae to
c3c1569
Compare
There was a problem hiding this comment.
bit unsure about "cannot be pulled in this manner", perhaps
invalid manifest type for image. Use `docker plugin install`
but not really satisfied with that one @sfsmithcha perhaps you have a suggestion?
There was a problem hiding this comment.
What about
target is a plugin manifest. Use `docker plugin install` to install plugins.
|
Tested this and it resolves the issue I saw, so LGTM (pending vendoring, and possibly better suggestions for the error) |
There was a problem hiding this comment.
if m, ok := manifest.(*schema2.DeserializedManifest); ok { m.Manifest.Config.MediaType } ?
c3c1569 to
f757b03
Compare
We should add some general purpose protection for this as well. Thankfully it doesn't panic the daemon but only the HTTP request. But we should consider anything returned by registry as potentially malicious and always validate it. |
f757b03 to
394c17f
Compare
|
Vendoring change at distribution/distribution#1901 |
There was a problem hiding this comment.
I believe only schema2.MediaTypeConfig is expected value here. Wondering if we could just throw an error of an expected configuration type if that is not seen. Ping @aaronlehmann
There was a problem hiding this comment.
I think the plugin stuff extends this with an additional media type?
There was a problem hiding this comment.
It does, but it has it's own pull method. It is invalid to pull a plugin type here. My preference for the code would be rather than having to have this part of the code know about plugins, just have it check for the configuration types it expects, in this case schema2.MediaTypeConfig
There was a problem hiding this comment.
I tried this approach before blacklisting plugins. The problem is that docker pull official Hub images such busybox, python, ubuntu has mediatype set to "application/octet-stream" and not the expected schema2.MediaTypeConfig ("application/vnd.docker.container.image.v1+json").
distribution/distribution#1621 seems relevant.
There was a problem hiding this comment.
That we know about. At some point we will have to be restrictive in the supported values. If it fails then we can assess whether it is legitimate and we should make a code change or whether the manifest needs to be recreated. We accept the application/octet-stream because we know there were many manifests mistakenly created with it and that at the time when they were created the only supported value is application/vnd.docker.container.image.v1+json.
For this change in particular, since now there are multiple possible types, I think it makes sense to define what is supported and have a special case for that one distribution bug.
There was a problem hiding this comment.
@anusha-ragunathan to me it more about separation of the code. This code should not be pulling plugins, and it really doesn't even need to know about anything that is a non-image. Having the whitelist would also negate the need of having the v0 version defined in distribution since the code change can be isolated to the image pull logic.
There was a problem hiding this comment.
We can make these sort of updates later, I am fine with it like this fo rnow
There was a problem hiding this comment.
@dmcgowan: distribution knowing about the plugin mediatype should be okay. Are you concerned purely because it is in v0 and will be okay to include it in distribution once we have a stable v1 manifest spec? Also, I agree that code separation is ideal but the above workaround to detecting the container image mediatype feels hackish. What if there are other mediatypes that we are not aware of, but qualify as a good container image today. Then this change will break a lot of users. That's why blacklisting is safe, since it wont break a thing.
There was a problem hiding this comment.
I think we need to add something in distribution to handle this sort of filtering and offering a "media type" separate from the version, so we can test to see if the media type is indeed an image rather than something else. I will create an issue in distribution to track this.
|
ping @aaronlehmann @dmcgowan what's the status here? |
|
Upstream merged |
|
@dmcgowan My ¢0.02, i don't quite see why the plugin media type has to be in the distribution repo. It should be orthogonal. |
|
@tiborvass I agree, but we would like to have the definition for all the known media types for the schema2 manifest in the |
|
Distribution vendor at #25841 |
394c17f to
c0f8da4
Compare
|
@dmcgowan Distribution changes are vendored in. PTAL. |
|
LGTM |
|
re-LGTM, ping @aaronlehmann @tiborvass |
There was a problem hiding this comment.
I'm surprised golint allowed these not to be commented individually. golint generally requires exported constants to have comments. Are we somehow running golint incorrectly?
There was a problem hiding this comment.
golint allows to put one comment on top of const if we want to be lazy (and if there is no comment on any constant).
Signed-off-by: Anusha Ragunathan <[email protected]>
c0f8da4 to
9b6dcc8
Compare
|
LGTM |
- What I did
Make
docker pulldetect plugin mediatype and error out.In this process, also add the plugin media type to distribution package.
- How I did it
Detect using manifest config's mediatype.
- How to verify it
docker pull tiborvass/no-remove fails; before this change it panics.
Signed-off-by: Anusha Ragunathan [email protected]
Fixes #23752