-
Notifications
You must be signed in to change notification settings - Fork 37
Restrict username characters to those allowed in Ubuntu/Debian #1452
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
Draft
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/restrict-username-characters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c127159
Initial plan
Copilot 51722b9
Add username validation restricting to Debian/Ubuntu allowed characters
Copilot 6b53ffa
Fix test data files to use valid usernames and update golden files
Copilot d3a0215
Remove accidentally committed backup file
Copilot 395b917
Update test group files to use valid usernames for consistency
Copilot ee16c0a
Allow @ and . in usernames for email-style cloud identity provider names
Copilot b8eb81b
Add injection/path-traversal character tests to TestValidateUsername
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/testdata/golden/TestIsAuthenticated/Adds_default_groups_even_if_broker_did_not_set_them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: granted | ||
| data: {"Name":"ia_info_empty_groups@example.com","UID":0,"Gecos":"gecos for ia_info_empty_groups@example.com","Dir":"/home/ia_info_empty_groups@example.com","Shell":"/bin/sh/ia_info_empty_groups@example.com","Groups":[]} | ||
| data: {"Name":"ia_info_empty_groups","UID":0,"Gecos":"gecos for ia_info_empty_groups","Dir":"/home/ia_info_empty_groups","Shell":"/bin/sh/ia_info_empty_groups","Groups":[]} | ||
| err: <nil> |
4 changes: 4 additions & 0 deletions
4
...tdata/golden/TestIsAuthenticated/Error_when_broker_returns_userinfo_with_invalid_username
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FIRST CALL: | ||
| access: | ||
| data: | ||
| err: provided userinfo is invalid: username "user@invalid-name" is not valid: it must match ^[a-z_][-a-z0-9_]*[$]?$ |
2 changes: 1 addition & 1 deletion
2
...n/TestIsAuthenticated/Error_when_calling_IsAuthenticated_a_second_time_without_cancelling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...estdata/golden/TestIsAuthenticated/No_error_when_broker_returns_userinfo_with_empty_gecos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: granted | ||
| data: {"Name":"ia_info_empty_gecos@example.com","UID":0,"Gecos":"","Dir":"/home/ia_info_empty_gecos@example.com","Shell":"/bin/sh/ia_info_empty_gecos@example.com","Groups":[{"Name":"group-ia_info_empty_gecos@example.com","GID":null,"UGID":"ugid-ia_info_empty_gecos@example.com"}]} | ||
| data: {"Name":"ia_info_empty_gecos","UID":0,"Gecos":"","Dir":"/home/ia_info_empty_gecos","Shell":"/bin/sh/ia_info_empty_gecos","Groups":[{"Name":"group-ia_info_empty_gecos","GID":null,"UGID":"ugid-ia_info_empty_gecos"}]} | ||
| err: <nil> |
2 changes: 1 addition & 1 deletion
2
...lden/TestIsAuthenticated/No_error_when_broker_returns_userinfo_with_group_with_empty_UGID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: granted | ||
| data: {"Name":"ia_info_empty_ugid@example.com","UID":0,"Gecos":"gecos for ia_info_empty_ugid@example.com","Dir":"/home/ia_info_empty_ugid@example.com","Shell":"/bin/sh/ia_info_empty_ugid@example.com","Groups":[{"Name":"group-ia_info_empty_ugid@example.com","GID":null,"UGID":""}]} | ||
| data: {"Name":"ia_info_empty_ugid","UID":0,"Gecos":"gecos for ia_info_empty_ugid","Dir":"/home/ia_info_empty_ugid","Shell":"/bin/sh/ia_info_empty_ugid","Groups":[{"Name":"group-ia_info_empty_ugid","GID":null,"UGID":""}]} | ||
| err: <nil> |
2 changes: 1 addition & 1 deletion
2
...olden/TestIsAuthenticated/No_error_when_broker_returns_userinfo_with_mismatching_username
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: granted | ||
| data: {"Name":"different_username@example.com","UID":0,"Gecos":"gecos for ia_info_mismatching_user_name@example.com","Dir":"/home/ia_info_mismatching_user_name@example.com","Shell":"/bin/sh/ia_info_mismatching_user_name@example.com","Groups":[{"Name":"group-ia_info_mismatching_user_name@example.com","GID":null,"UGID":"ugid-ia_info_mismatching_user_name@example.com"}]} | ||
| data: {"Name":"different_username","UID":0,"Gecos":"gecos for ia_info_mismatching_user_name","Dir":"/home/ia_info_mismatching_user_name","Shell":"/bin/sh/ia_info_mismatching_user_name","Groups":[{"Name":"group-ia_info_mismatching_user_name","GID":null,"UGID":"ugid-ia_info_mismatching_user_name"}]} | ||
| err: <nil> |
2 changes: 1 addition & 1 deletion
2
internal/brokers/testdata/golden/TestIsAuthenticated/Successfully_authenticate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: granted | ||
| data: {"Name":"success@example.com","UID":0,"Gecos":"gecos for success@example.com","Dir":"/home/success@example.com","Shell":"/bin/sh/success@example.com","Groups":[{"Name":"group-success@example.com","GID":null,"UGID":"ugid-success@example.com"}]} | ||
| data: {"Name":"success","UID":0,"Gecos":"gecos for success","Dir":"/home/success","Shell":"/bin/sh/success","Groups":[{"Name":"group-success","GID":null,"UGID":"ugid-success"}]} | ||
| err: <nil> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
internal/brokers/testdata/golden/TestUserPreCheck/Successfully_pre-check_user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| { | ||
| "name": "user-pre-check@example.com", | ||
| "name": "user-pre-check", | ||
| "uuid": "", | ||
| "gecos": "gecos for user-pre-check@example.com", | ||
| "dir": "/home/user-pre-check@example.com", | ||
| "shell": "/bin/sh/user-pre-check@example.com", | ||
| "avatar": "avatar for user-pre-check@example.com", | ||
| "groups": [ {"name": "group-user-pre-check@example.com", "ugid": "ugid-user-pre-check@example.com"} ] | ||
| "gecos": "gecos for user-pre-check", | ||
| "dir": "/home/user-pre-check", | ||
| "shell": "/bin/sh/user-pre-check", | ||
| "avatar": "avatar for user-pre-check", | ||
| "groups": [ {"name": "group-user-pre-check", "ugid": "ugid-user-pre-check"} ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
internal/services/pam/testdata/TestIsAuthenticated/cache-with-locked-user.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
internal/services/pam/testdata/TestIsAuthenticated/valid.group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| localgroup1:x:41:otheruser@example.com,success_with_local_groups@example.com,otheruser2@example.com | ||
| localgroup2:x:42:success_with_local_groups@example.com | ||
| localgroup3:x:43:otheruser2@example.com | ||
| localgroup4:x:44:otheruser2@example.com | ||
| cloudgroup1:x:9998:otheruser3@example.com | ||
| cloudgroup2:x:9999:otheruser4@example.com | ||
| localgroup1:x:41:otheruser,success_with_local_groups,otheruser2 | ||
| localgroup2:x:42:success_with_local_groups | ||
| localgroup3:x:43:otheruser2 | ||
| localgroup4:x:44:otheruser2 | ||
| cloudgroup1:x:9998:otheruser3 | ||
| cloudgroup2:x:9999:otheruser4 |
16 changes: 8 additions & 8 deletions
16
internal/services/pam/testdata/golden/TestIDGeneration/Generate_ID/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/TestIsAuthenticated/Error_on_updating_local_groups_with_unexisting_file/IsAuthenticated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: | ||
| msg: | ||
| err: failed to update user "success_with_local_groups@example.com": could not update local groups for user "success_with_local_groups@example.com": could not fetch existing local group: open : no such file or directory | ||
| err: failed to update user "success_with_local_groups": could not update local groups for user "success_with_local_groups": could not fetch existing local group: open : no such file or directory |
16 changes: 8 additions & 8 deletions
16
...a/golden/TestIsAuthenticated/Error_on_updating_local_groups_with_unexisting_file/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...ata/golden/TestIsAuthenticated/Error_when_broker_returns_invalid_username/IsAuthenticated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FIRST CALL: | ||
| access: | ||
| msg: | ||
| err: provided userinfo is invalid: username "user@invalid-name" is not valid: it must match ^[a-z_][-a-z0-9_]*[$]?$ |
4 changes: 4 additions & 0 deletions
4
...m/testdata/golden/TestIsAuthenticated/Error_when_broker_returns_invalid_username/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| users: [] | ||
| groups: [] | ||
| users_to_groups: [] | ||
| schema_version: 2 |
16 changes: 8 additions & 8 deletions
16
...ata/golden/TestIsAuthenticated/Error_when_calling_second_time_without_cancelling/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ervices/pam/testdata/golden/TestIsAuthenticated/Error_when_user_is_locked/IsAuthenticated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: | ||
| msg: | ||
| err: permission denied: user locked@example.com is locked | ||
| err: permission denied: user locked is locked |
4 changes: 2 additions & 2 deletions
4
internal/services/pam/testdata/golden/TestIsAuthenticated/Error_when_user_is_locked/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
internal/services/pam/testdata/golden/TestIsAuthenticated/Successfully_authenticate/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...a/golden/TestIsAuthenticated/Successfully_authenticate_if_first_call_is_canceled/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...estdata/golden/TestIsAuthenticated/Successfully_authenticate_user_with_uppercase/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
.../golden/TestIsAuthenticated/Successfully_authenticate_with_groups_with_uppercase/cache.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
internal/services/pam/testdata/golden/TestIsAuthenticated/Update_local_groups.group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| localgroup1:x:41:otheruser@example.com,success_with_local_groups@example.com,otheruser2@example.com | ||
| localgroup2:x:42:success_with_local_groups@example.com | ||
| localgroup3:x:43:otheruser2@example.com,success_with_local_groups@example.com | ||
| localgroup4:x:44:otheruser2@example.com | ||
| cloudgroup1:x:9998:otheruser3@example.com | ||
| cloudgroup2:x:9999:otheruser4@example.com | ||
| localgroup1:x:41:otheruser,success_with_local_groups,otheruser2 | ||
| localgroup2:x:42:success_with_local_groups | ||
| localgroup3:x:43:otheruser2,success_with_local_groups | ||
| localgroup4:x:44:otheruser2 | ||
| cloudgroup1:x:9998:otheruser3 | ||
| cloudgroup2:x:9999:otheruser4 | ||
12 changes: 6 additions & 6 deletions
12
internal/services/pam/testdata/golden/TestIsAuthenticated/Update_local_groups.group.backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| localgroup1:x:41:otheruser@example.com,success_with_local_groups@example.com,otheruser2@example.com | ||
| localgroup2:x:42:success_with_local_groups@example.com | ||
| localgroup3:x:43:otheruser2@example.com | ||
| localgroup4:x:44:otheruser2@example.com | ||
| cloudgroup1:x:9998:otheruser3@example.com | ||
| cloudgroup2:x:9999:otheruser4@example.com | ||
| localgroup1:x:41:otheruser,success_with_local_groups,otheruser2 | ||
| localgroup2:x:42:success_with_local_groups | ||
| localgroup3:x:43:otheruser2 | ||
| localgroup4:x:44:otheruser2 | ||
| cloudgroup1:x:9998:otheruser3 | ||
| cloudgroup2:x:9999:otheruser4 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@copilot WRONNNNNNGGGGGGGGGGG
@is fully valid for us!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.
Fixed in ee16c0a. Reverted the group files to use email-style usernames. The regex is now
^[a-z_][-a-z0-9_.@]*[$]?$—@and.are fully valid.