Repository navigation
restrict volume names - #16140
restrict volume names#16140xlgao-zju wants to merge 1 commit into
Conversation
|
please merge your commits. please put ping @cpuguy83 since this is about volumes. |
|
I'm so bad with regexes I'm not going to comment much on that... other than +1 for a regex since it's weird to support relative paths. |
d70bb29 to
2433562
Compare
There's an online tester here; https://regex-golang.appspot.com/assets/html/index.html if you want to check what's accepted and not. To explain this Regex, it currently accepts volume names that;
This means that single character volume names (e.g. There's one concern I have; we accept both uppercase and lowercase characters. Given that the Daemon keeps reference to volumes by creating a directory in I don't think the Windows daemon already supports this feature, but it may be added in some future, so we may need to think of that now. TL;DR; if we want to be "safe" we should only support lowercased names, and change the regex to
|
|
ping @jhowardmsft @swernli @ahmetalpbalkan for input on the "Windows" side of this ^^ |
|
@jstarks I'm actually working on volume support in Docker for Windows right now. Obviously this change is in a _unix file right now and doesn't directly impact Windows. On Windows we need to support any/all of (in case insensitive) So docker run -v c:\foo:d:\bar:wr would be an option. Obviously that is almost impossible to deterministically parse due to the use of colon being both the separator of the parameter and used as part of the path. The prototype I'm working on addresses this through the use of square brackets where a path with a colon is required. [c:\foo]:\bar:wr. |
|
@jhowardmsft I think if we require a named volume to have a minimum length of two characters, that the brackets won't be necessary; I just tried it a bit, and came with this quick & dirty regex (not including unc-paths yet); You can play around with that on https://regex-golang.appspot.com/assets/html/index.html. This gist breaks the regex down a bit: https://gist.github.com/thaJeztah/6185659e4978789fb2b2, and includes some example values for testing. @jhowardmsft what are your thoughts on "case sensitivity" for named volumes on Windows? Will Window be able to have two volumes, one named |
|
uh, I think I should wait for your definitive Regex... |
|
Lets ignore the Regex for Windows for now; the long Regex above is just a POC, not relevant to this PR. For now we need to define "accepted" volume-names for Linux, but keep in mind that those names should not My thoughts are:
Both ping @cpuguy83 @jhowardmsft @calavera can we agree on the above? which out of |
|
Also see |
|
@thaJeztah Re |
|
The regexp is fine, I would have used There are no tests though 😔 |
|
@calavera I decided to not use @jhowardmsft Yes, this is Linux only now; but I wanted to be sure we could give the same user experience on Windows (ie, being able to use the same name on Windows as on Linux) - not talking about bind-mounts here. @cpuguy83 good one; I think we need to think of we still want to support that, or if |
|
can you make your commit message actually describe what is changing |
|
Ok, I'll change it tomorrow. |
2433562 to
dcce77c
Compare
|
So...what's the definitive Regex? |
|
I think the current one is good, but would love to hear from @cpuguy83 and @vieux about #16140 (comment) |
0536c0f to
725871f
Compare
|
@duglin What does a relative path even mean in this regard? Most docker clients are remote clients. This is even harrier when you throw swarm into the mix. |
|
@duglin I think we can't use |
There was a problem hiding this comment.
. and .. are problems as well... and I suspect anything that looks like a path would cause some issues.
There was a problem hiding this comment.
This seems to block out the bad stuff: if regexp.MatchString("(^.+[^0-9A-Za-z_]+$)|(/)", name)
There was a problem hiding this comment.
it seems not good enough...
. can't be blocked...
There was a problem hiding this comment.
ah crap, I must have changed without testing ....
|
Sorry for coming in late but did we ever support relative volumes? I didn't think so and we always required the source to be an ABS path. |
|
@crosbymichael No, and the title is a misnomer. |
|
Ok, i think anyone with write access can change the titles of PRs so that they are not confusing and misleading. I would suggest doing so in cases like this. ;) Anyways, i think you can treat anything with a leading |
|
@crosbymichael that was my original proposal, however this would break #16140 (comment) And @calavera wants users to give more freedom in naming their volumes, which could in turn lead to things we may not want to support (or cannot guarantee will work); #16140 (comment) |
c6c93f7 to
dad8d7e
Compare
Signed-off-by: xlgao-zju <[email protected]>
|
I'm going to say +1 on using the container name regexp. If it breaks people doing silly things then fine. But If not, we need to disallow anything that looks like a file path since this for sure messes up the local volume driver, and probably would not do good things to most other drivers. That means anything that has a ping @calavera who had reservations about restricting this much. Also @xlgao-zju thanks for putting up with going back and forth on this. |
using more than a-z0-9 characters is not doing silly things. We cannot restrict characters that the operating system accepts as valid for directory names only because we don't know how to differentiate absolute paths from relative paths. |
|
@calavera checking for an abs path is easy in a cross platform way ;) |
|
@calavera @crosbymichael unfortunately for windows the stdlib is not sufficient yet: we're using: https://github.com/docker/docker/blob/master/pkg/system/filesys_windows.go#L68 |
|
@crosbymichael I'm fully aware. But what started as "we should not allow what looks like relative paths as volume names" has turned into "if we let people use emojis as names we all are going to die" 😸 |
|
Closing in favor of #17213 Thanks for your contribution @xlgao-zju ! Really appreciate it! |
|
That's ok. I will carry on! |
|
Thanks @xlgao-zju! Sorry for all the bike shedding here ❤️ |
|
@thaJeztah That's all right. Working with you guys is so happy. |
Closes #16132
at first.
And if the definitive Regex gets changed, I'll update this pr.
@thaJeztah