Repository navigation
fix: backport security auth fixes to develop/2500u3 #1334
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
Merged
deepin-bot
merged 3 commits into
linuxdeepin:develop/2500u3
from
fly602:fix/security-auth-2500u3
Dec 3, 2026
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| package accounts | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "unicode/utf8" | ||
| ) | ||
|
|
||
| // maxPasswordHintLength bounds what can be written into the user config file. | ||
| const maxPasswordHintLength = 512 | ||
|
|
||
| // validatePasswordHint rejects hints that would not round-trip through the | ||
| // user config file: too long, or containing control characters. | ||
| func validatePasswordHint(hint string) error { | ||
| if utf8.RuneCountInString(hint) > maxPasswordHintLength { | ||
| return fmt.Errorf("password hint exceeds %d characters", maxPasswordHintLength) | ||
| } | ||
| for _, r := range hint { | ||
| if r < 0x20 || r == 0x7f { | ||
| return errors.New("password hint contains control characters") | ||
| } | ||
| } | ||
| return 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| package accounts | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestValidatePasswordHint(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| hint string | ||
| wantErr bool | ||
| }{ | ||
| {"empty is allowed and clears the hint", "", false}, | ||
| {"plain text", "my first pet", false}, | ||
| {"chinese text", "第一只宠物的名字", false}, | ||
| {"at the limit", strings.Repeat("a", maxPasswordHintLength), false}, | ||
| {"over the limit", strings.Repeat("a", maxPasswordHintLength+1), true}, | ||
| {"multi-byte counted in characters", strings.Repeat("密", maxPasswordHintLength), false}, | ||
| {"newline", "a\nb", true}, | ||
| {"carriage return", "a\rb", true}, | ||
| {"tab", "a\tb", true}, | ||
| {"del", "a\x7fb", true}, | ||
| {"nul", "a\x00b", true}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := validatePasswordHint(tt.hint) | ||
| if tt.wantErr { | ||
| assert.Error(t, err) | ||
| } else { | ||
| assert.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.