-
Notifications
You must be signed in to change notification settings - Fork 160
validate: add root.path validation when platform is windows #472
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
validate: add root.path validation when platform is windows #472
Conversation
e17a31d to
e59ea68
Compare
validate/validate.go
Outdated
| } | ||
|
|
||
| if v.platform == "windows" { | ||
| if !strings.HasPrefix(v.spec.Root.Path, `\\?\`) { |
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.
We can be stricter than this. The spec links here, which would be a regex like [\][\][?][\]Volume[ {][a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}[}][\]?". The Windows docs say "GUID", I think they mean "UUID", based on their \\?\Volume{26a21bda-a627-11d7-9931-806e6f6e6963}\ example.
Also, unit tests :).
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.
updated, PTAL.
0e1633c to
ec26a84
Compare
| }{ | ||
| {rspec.Spec{Windows: &rspec.Windows{HyperV: &rspec.WindowsHyperV{}}, Root: &rspec.Root{}}, "windows", specerror.RootOnHyperV}, | ||
| {rspec.Spec{Windows: &rspec.Windows{HyperV: &rspec.WindowsHyperV{}}, Root: nil}, "windows", specerror.NonError}, | ||
| {rspec.Spec{Windows: &rspec.Windows{}, Root: &rspec.Root{Path: filepath.Join(tmpBundle, "rootfs")}}, "windows", specerror.PathFormatOnWindows}, |
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.
Can we also check that this passes validation? The regex is large, and a positive match would help convince me that it wasn't broken.
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.
updated.
d214edd to
ab58414
Compare
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
ab58414 to
567f1aa
Compare
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
f1104b0 to
1a9532e
Compare
| } | ||
|
|
||
| return nil | ||
| return validate.CapValid(cp, false) |
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.
I like this change, but it seems orthogonal. Can 1a9532e get its own PR?
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.
All of this looks good to me, regardless of whether the generate commit is spun off.
|
ping @mrunalp @liangchenye |
According to the spec.
Signed-off-by: zhouhao zhouhao@cn.fujitsu.com