Skip to content

improve linux username pattern#13506

Closed
JohnYuu wants to merge 1 commit intoapache:devfrom
JohnYuu:dev
Closed

improve linux username pattern#13506
JohnYuu wants to merge 1 commit intoapache:devfrom
JohnYuu:dev

Conversation

@JohnYuu
Copy link

@JohnYuu JohnYuu commented Feb 3, 2023

Purpose of the pull request

Brief change log

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

If your pull request contain incompatible change, you should also add it to docs/docs/en/guide/upgrede/incompatible.md

@SbloodyS SbloodyS linked an issue Feb 3, 2023 that may be closed by this pull request
3 tasks
@SbloodyS SbloodyS added first time contributor First-time contributor improvement make more easy to user or prompt friendly 3.2.0 for 3.2.0 version labels Feb 3, 2023
@SbloodyS SbloodyS added this to the 3.2.0 milestone Feb 3, 2023
@JohnYuu JohnYuu removed their assignment Feb 3, 2023
public class RegexUtils {

private static final Pattern LINUX_USERNAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_].{0,30}");
private static final Pattern LINUX_USERNAME_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z\\d_-]{0,30}");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private static final Pattern LINUX_USERNAME_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z\\d_-]{0,30}");
private static final Pattern LINUX_USERNAME_PATTERN = Pattern.compile("[a-zA-Z\\d_-].{0,30}");

Copy link
Member

Choose a reason for hiding this comment

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

Could you please add ut for this?

Copy link
Author

Choose a reason for hiding this comment

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

I think only '-' matches [a-zA-Z\d_-].{0,30}, pure numbers are also matches [a-zA-Z\d_-].{0,30}; such as '-', 123456; but these are not valid linux user names!

Copy link
Author

Choose a reason for hiding this comment

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

Looking forward to your reply and suggestions

Copy link
Member

Choose a reason for hiding this comment

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

The regex failed with 10000?

Copy link
Author

Choose a reason for hiding this comment

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

regex would not failed with 10000, but 10000 is not a valid linux user name

Copy link
Member

Choose a reason for hiding this comment

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

Please fix the UT

RegexUtilsTest.testIsValidLinuxUserName

Copy link
Author

Choose a reason for hiding this comment

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

Could you add me wechat or call me, I want to ask you a question? 15651806509

Copy link
Member

Choose a reason for hiding this comment

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

Could you add me wechat or call me, I want to ask you a question? 15651806509

It is better to keep it public so that others can participate in the review.

Copy link
Author

@JohnYuu JohnYuu left a comment

Choose a reason for hiding this comment

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

linux user name cat not start with '-'

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

This pull request has been automatically marked as stale because it has not had recent activity for 120 days. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Jun 7, 2023
@github-actions
Copy link

This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.

@github-actions github-actions bot closed this Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.2.0 for 3.2.0 version backend first time contributor First-time contributor improvement make more easy to user or prompt friendly Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][Module Name] Please enter the English operating system tenant

3 participants