Skip to content
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 identifiers should avoid reserved names on windows #3312

Closed
apostasie opened this issue Aug 14, 2024 · 4 comments · Fixed by #3339
Closed

Validate identifiers should avoid reserved names on windows #3312

apostasie opened this issue Aug 14, 2024 · 4 comments · Fixed by #3339
Labels
kind/feature platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2)

Comments

@apostasie
Copy link
Contributor

apostasie commented Aug 14, 2024

What is the problem you're trying to solve

https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file

"
CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM¹, COM², COM³, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, LPT¹, LPT², and LPT³. Also avoid these names followed immediately by an extension; for example, NUL.txt and NUL.tar.gz are both equivalent to NUL. For more information, see Namespaces.
"

Describe the solution you'd like

Identifiers that are being used on the filesystem should forbid these.
That should be put in a windows version of Validate (being reworked in #3279).

Something in the line of:
^(con|prn|nul|aux|com[1-9]|lpt[1-9])([.].*)?

Additional context

Docker seem to enforce these.

@Shubhranshu153
Copy link
Contributor

probably we want to add this also to validate function?
i am wondering there might be others regexp in docker too. Can document all the regexp and do a pr.
This week is bit constraint for me but can pick up next week.

@apostasie
Copy link
Contributor Author

Yeah, should definitely go in validate_windows.go or something in the line.
A quick recon in Moby may show some more.

@Shubhranshu153
Copy link
Contributor

do we want in the same pr or a different pr? would prefer a different pr in the sense adding restrictions to a validation function would mean we need to think about backward compatibility and how to handle that, relaxing on the other hand is simpler in that regard.

@AkihiroSuda AkihiroSuda added the platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2) label Aug 14, 2024
@apostasie
Copy link
Contributor Author

apostasie commented Aug 14, 2024

do we want in the same pr or a different pr? would prefer a different pr in the sense adding restrictions to a validation function would mean we need to think about backward compatibility and how to handle that, relaxing on the other hand is simpler in that regard.

Yeah, it is fine in a follow-up PR.

About backward compatibility, I don't think we need to think about it here.
(Most of) these identifiers would fail on windows regardless (with some cryptic message).
Adding the extra validation (like Moby does) will just safeguard it and provide some reasonable output to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants