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

machine init: validate machine name and username #21692

Merged
merged 3 commits into from
Feb 17, 2024

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Feb 16, 2024

Validate the names with our name regex that we also use for
containers/pods. While we technically do not need to be that strict, I
think it makes sense to match containers. The most important bit of this
validation is that we exclude the use of / and \ which breaks all our
file paths as we just use this in the name an when machine write the
file it ends up being in a subdir which breaks the reading side. Also
other special characters could cause trouble for the URL parsing in the
machine connection URL.

also see the other cleanup commits

Does this PR introduce a user-facing change?

The podman machine name and remote username must match this regex: `[a-zA-Z0-9][a-zA-Z0-9_.-]*`

Remove unnecessary type redirection and just make it a normal function.
Also unexport it and move the test as it does not need to be public and
remove the default value assignments from the struct.

Signed-off-by: Paul Holzinger <[email protected]>
This function has to read/write the connections file as such it should
only ever be called once otherwise we read/write the same file twice
which makes no sense. Also cleanup the fucntion a bit and make it
private as there are no external callers.

Signed-off-by: Paul Holzinger <[email protected]>
Validate the names with our name regex that we also use for
containers/pods. While we technically do not need to be that strict, I
think it makes sense to match containers. The most important bit of this
validation is that we exclude the use of / and \ which breaks all our
file paths as we just use this in the name an when machine write the
file it ends up being in a subdir which breaks the reading side. Also
other special characters could cause trouble for the URL parsing in the
machine connection URL.

Signed-off-by: Paul Holzinger <[email protected]>
@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 16, 2024
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@rhatdan
Copy link
Member

rhatdan commented Feb 16, 2024

LGTM

Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented Feb 16, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Feb 17, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 17, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit fbb4d5d into containers:main Feb 17, 2024
89 of 91 checks passed
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label May 18, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants