Repository navigation
Add a foreign layer URL host whitelist - #1829
Conversation
Current coverage is 52.47%@@ master #1829 diff @@
==========================================
Files 120 120
Lines 10506 10499 -7
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 6243 5509 -734
- Misses 3429 4249 +820
+ Partials 834 741 -93
|
|
seems inline with #1825 so 👍 (haven't done code-review yet) |
| foreignlayer: | ||
| hostwhitelist: [EXAMPLE.COM, .example.net] | ||
|
|
||
| Set `hostwhitelist` to an empty list (`[]`) to reject all foreign-layer |
There was a problem hiding this comment.
could you just add an enabled: <bool> under the foreignlayer section instead? (more explicit and easier for testing)
There was a problem hiding this comment.
Certainly. And in that case, panicking on an empty whitelist seems appropriate.
There was a problem hiding this comment.
Let's use the term allowed.
There was a problem hiding this comment.
Or better yet:
foreignlayer:
hosts:
allow:
- www.foo.com
- example.com
There was a problem hiding this comment.
Happy to follow either this proposal or @RichardScothern's proposal of whitelist.
|
This feature shouldn't be called "Foreign Layers". The concept of a foreign layer is reserved to the docker engine, as the layer is foreign to docker. The registry doesn't care. This just influences the valid urls that a registry will accept in the manifest. |
|
Can we take care of enabling/disabling the whole foreign layer story/feature as part of this PR? Related to point 3) in #1825 Is it feasible in this PR? seems likely to me, just an Quoting poing 3) from #1825:
|
|
|
||
| // ForeignLayerHostWhitelist tests whether the host is allowed in foreign layer URLs. | ||
| func (reg *registry) ForeignLayerHostAllowed(host string) bool { | ||
| if reg.foreignLayerHostWhitelist == nil { |
There was a problem hiding this comment.
the knob I'm talking about can cleanly take care of this check also - instead of checking for the presence of a whitelist, we can check if foreign layers are enabled at all and exit early here
I'm happy follow maintainer guidance on an appropriate name. I don't think I have enough perspective to propose an alternative. Except for "Not Foreign Layers". 💥 |
@RichardScothern proposed the same and I'm planning to implement it. |
ty |
|
@nwt This is validating manifest urls: A few things:
|
|
@stevvooe: I implemented this: I changed |
|
I meant to have disabled (or enabled) as a way to fully opt-out this features. It seems what you did doesn't cleanly achieve that, does it? |
|
@runcom: All pushes of foreign layer manifests will be rejected with this in your config: Were you asking for something different? |
|
That's somehow fine ti me, i was hoping for such a flag to be more global but if it still accomplishes fully opt-out than I'll leave those decisions to others about where that disable flag should be. |
| Validation struct { | ||
| Manifests struct { | ||
| URLs struct { | ||
| Allowed *string `yaml:"allowed,omitempty"` |
|
@stevvooe +1 |
| disabled: false | ||
| manifests: | ||
| urls: | ||
| allow: ^https?://([^/]+\.)*example\.com/ |
There was a problem hiding this comment.
I think these examples need to be a list.
|
LGTM There are a few nits about getting the defaults backwards compatible. Great addition, @nwt! |
Until we have some experience hosting foreign layer manifests, the Hub operators wish to limit foreign layers on Hub. To that end, this change adds registry configuration options to restrict the URLs that may appear in pushed manifests. Signed-off-by: Noah Treuhaft <[email protected]>
|
@stevvooe: 61e5803 addresses comments on 153c2f2.
I'm not thrilled with how I handled |
Will it still allow manifests without urls? That is somewhat the purpose. For example, if one configures the following: All manifests with urls would be blocked, while others would be allowed. Let's say we unrolled these into an ordered set of operations. By default, with all empy This would give us default closed operation when the URL is empty. We insert all allows before denies: ALLOW always has precedent: These are matched such that if the rule matches, we return the operation. For This only becomes problematic when we have a more specific deny than an allow: So, even though we deny Typically, this issue is dealt with using priorities, but that is overbuilt for this purpose. It is probably better to favor ALLOW for this purpose but arguments can go either way. TL; DR Having |
Yes, manifests without URLs are always allowed regardless of what appears under |
|
LGTM |
2 similar comments
|
LGTM |
|
LGTM |
|
Holding off on merging while we discuss a missing API test.. |
|
Fixes a pre-existing condition and coming in a PR. |
Until we have some experience hosting foreign layer manifests, the Hub
operators wish to limit foreign layers on Hub to those hosted by
Microsoft. To that end, this change adds a registry configuration option
to whitelist hosts that may appear in foreign layer URLs of pushed
manifests, and it modifies manifest validation to reject pushes
containing foreign layer URLs whose host is not whitelisted.
Signed-off-by: Noah Treuhaft [email protected]