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

username must be at least 3 characters long #29198

Merged
merged 1 commit into from
Oct 13, 2017

Conversation

peterprochaska
Copy link
Contributor

Description

Username must be at least 3 characters long

Related Issue

HackerOne and https://github.com/owncloud/security-tracker/issues/227

Motivation and Context

How Has This Been Tested?

You can't add a user with 'a' or 'ab'

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@DeepDiver1975
Copy link
Member

@Peter-Prochaska did you test this? jenkins is red - please have a look

@phil-davis
Copy link
Contributor

This will "fix" the user named "0" issue, by banning any 1 (or 2) char string as a username: #28406

@phil-davis
Copy link
Contributor

I guess this only applies to "local" ownCloud-created usernames. Short ones could still come from LDAP?

@phil-davis phil-davis mentioned this pull request Oct 10, 2017
@PVince81
Copy link
Contributor

Short ones could still come from LDAP?

Yes

@peterprochaska
Copy link
Contributor Author

peterprochaska commented Oct 10, 2017


@peterprochaska peterprochaska force-pushed the username-must-at-least-3-characters-long branch from 5c806a6 to 94ee206 Compare October 10, 2017 13:06
.htaccess Outdated
@@ -84,4 +84,3 @@ Options -Indexes
<IfModule pagespeed_module>
ModPagespeed Off
</IfModule>

Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@peterprochaska peterprochaska force-pushed the username-must-at-least-3-characters-long branch from eb80f56 to e723c18 Compare October 10, 2017 13:34
@@ -289,6 +289,12 @@ public function searchDisplayName($pattern, $limit = null, $offset = null) {
*/
public function createUser($uid, $password) {
$l = \OC::$server->getL10N('lib');

// Username must at least 3 characters long
if(strlen($uid) <= 3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This ends up in min 4

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally I would place it after the whitespace check...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No and no, <=3 ist min 3. And after the whitespace check we have the problem with the "."

Copy link
Contributor

@phil-davis phil-davis Oct 11, 2017

Choose a reason for hiding this comment

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

The message says The username must be at least 3 characters long which means it can be 3, 4, 5... characters long. But if I put in a 3-character username "abc" it will not let me do it.
So the "if" test here and the message have different things. One of them needs to be changed, depending on what is the requirement.

Copy link
Contributor

Choose a reason for hiding this comment

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

just replace <= with <

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

see @mmattel's comments

.htaccess Outdated
@@ -83,5 +83,4 @@ AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
ModPagespeed Off
</IfModule>

</IfModule>
Copy link

Choose a reason for hiding this comment

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

I guess this will break the .htaccess again? AFAIK the newline is expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What now? Expected or not?

Copy link
Contributor

Choose a reason for hiding this comment

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

In the first place a change to .htaccess should never have been added to the commit. Sometimes git is seeing that it was modified during a local dev install, and then "just adds it" to the commit (it depends what git tool you are using and what is in the .gitignore file etc.)

So you need to press "Enter" at the end of the last line, commit and squash. Hopefully .htaccess will then become identical to the current version in master, and so it will disappear from this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

git checkout master .htaccess to revert the changes.

htaccess is not relevant to this PR / commit, so if we want something different there, needs to be fixed separately

@peterprochaska peterprochaska force-pushed the username-must-at-least-3-characters-long branch from e4bccad to 23e7eb0 Compare October 11, 2017 07:32
Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

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

Just little comments.

@@ -289,6 +289,12 @@ public function searchDisplayName($pattern, $limit = null, $offset = null) {
*/
public function createUser($uid, $password) {
$l = \OC::$server->getL10N('lib');

// Username must at least 3 characters long
Copy link
Contributor

Choose a reason for hiding this comment

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

Username must be at least...

@@ -289,6 +289,12 @@ public function searchDisplayName($pattern, $limit = null, $offset = null) {
*/
public function createUser($uid, $password) {
$l = \OC::$server->getL10N('lib');

// Username must at least 3 characters long
if(strlen($uid) < 3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like to have space between keywords an the next bracket, like in the next ``if (` below.
It is part of some coding standards - don't know if it is the rule in oC.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why you put that quey at the start - just before all other checks like whitespace and valid characters?
Should´nt the result be minimum three valid characters ?

Copy link
Member

@DeepDiver1975 DeepDiver1975 Oct 11, 2017

Choose a reason for hiding this comment

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

Quite valid question - otherwise we end up with ' .' as user name

Copy link
Contributor

Choose a reason for hiding this comment

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

the answer is likely: need more ☕️ 😉

fixed error

reverted .htaccess

reverted .htaccess

reverted .htaccess to master version and adjust if statement

moved len check after other checks
@peterprochaska peterprochaska force-pushed the username-must-at-least-3-characters-long branch from 3484c4e to e682412 Compare October 11, 2017 08:00
Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍

@PVince81
Copy link
Contributor

restarted jenkins

@DeepDiver1975 DeepDiver1975 merged commit 67c8e05 into master Oct 13, 2017
@DeepDiver1975 DeepDiver1975 deleted the username-must-at-least-3-characters-long branch October 13, 2017 10:45
@lock
Copy link

lock bot commented Aug 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants