Skip to content

Validate volume names for the local driver. - #17213

Merged
calavera merged 2 commits into
moby:masterfrom
calavera:volume_driver_validate_name
Oct 21, 2015
Merged

calavera merged 2 commits into
moby:masterfrom
calavera:volume_driver_validate_name

Conversation

@calavera

Copy link
Copy Markdown
Contributor

Closes #16132
Closes #16140

@tiborvass

Copy link
Copy Markdown
Contributor

LGTM

Comment thread volume/local/local_test.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the regexp to match the container names, this should work now.

@calavera
calavera force-pushed the volume_driver_validate_name branch 4 times, most recently from aeaacbe to d74fead Compare October 20, 2015 18:24
@tiborvass

Copy link
Copy Markdown
Contributor

not fond of having it in utils package, but since we need this for 1.9 it's fine for now.

@tiborvass tiborvass added this to the 1.9.0 milestone Oct 20, 2015
@tiborvass tiborvass self-assigned this Oct 20, 2015

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ..?
Possible ...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the regular expression doesn't allow anything that doesn't start with a-zA-Z0-9, so testing that it's not a . covers those cases too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the test is to verify that we do indeed reject certain patterns, this should be independent of the implementation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @cpuguy83 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added those tests. Can you take another look?

@vdemeester

Copy link
Copy Markdown
Member

@calavera Why the utils package ? It's only related to package volume for now right ; so it could be in the volume package, for now. As @tiborvass not fond of a utils package.. you can put anything in there 😝.

@calavera

Copy link
Copy Markdown
Contributor Author

I'm not fond of that package either, that's not the only file there, fwiw, we already have a bunch of things in that utils package. I'm open to suggestions but I didn't want to introduce a new package only for this.

@vdemeester

Copy link
Copy Markdown
Member

@calavera ohh for real.. never saw the package lol.. need to open my eyes more 😸.
Then I'm with @tiborvass, let's go with it for 1.9.0 and maybe create an issue on "cleaning / moving things out of utils package" 😉

Comment thread errors/daemon.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status 400 Bad request is probably more appropriate here. 5XX errors are really for "server made a 'whoopsie'"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either is fine because at some point (after the errcode disucssions) we'll be looking at each error and making sure it has the right status code. But getting it to be 400 now is good :-)

@thaJeztah

Copy link
Copy Markdown
Member

Thanks @calavera! LGTM. Only concern: how do we handle migration of existing volumes that are no longer valid?

Also: lets keep the discussion open for loosening up and being less restrictive after 1.9

@thaJeztah

Copy link
Copy Markdown
Member

oh, after looking at the error code that is (no real show-stopper, but 4XX seems more appropriate)

@calavera
calavera force-pushed the volume_driver_validate_name branch 2 times, most recently from 415084d to dc3bcb0 Compare October 21, 2015 16:27
Delegate validation tasks to the volume drivers. It's up to them
to decide whether a name is valid or not.
Restrict volume names for the local driver to prevent creating
mount points outside docker's volumes directory.

Signed-off-by: David Calavera <[email protected]>
@calavera
calavera force-pushed the volume_driver_validate_name branch from dc3bcb0 to d6d6028 Compare October 21, 2015 16:28
@tiborvass

Copy link
Copy Markdown
Contributor

thanks for addressing the issues @calavera

@cpuguy83

Copy link
Copy Markdown
Member

Will run these tests locally

@thaJeztah

Copy link
Copy Markdown
Member

Added impact/changelog; do we need a mention in "deprecations" to tell people that some volume names are no longer valid?

@cpuguy83

Copy link
Copy Markdown
Member

Tests are good locally.
LGTM

@thaJeztah for the merge if docs are needed.

@thaJeztah

Copy link
Copy Markdown
Member

@calavera I think we should add a mention to https://github.com/docker/docker/blob/master/docs/misc/deprecated.md so that people are aware that this changed, wdyt?

@calavera

Copy link
Copy Markdown
Contributor Author

@thaJeztah this is not a feature change or improvement, this is a bug fix. From my point of view, it should go into the bug fixes section in the backlog.

@thaJeztah

Copy link
Copy Markdown
Member

@calavera cool 👍

calavera added a commit that referenced this pull request Oct 21, 2015
Validate volume names for the local driver.
@calavera
calavera merged commit 8247eff into moby:master Oct 21, 2015
@calavera
calavera deleted the volume_driver_validate_name branch October 21, 2015 18:48
@tiborvass

Copy link
Copy Markdown
Contributor

Removing impact/changelog since volume top level command is introduced in 1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants