强制超级管理员配置安全验证并保护本机密码重置
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-19 00:24:27 +08:00
1 parent de8c298bd5
commit 67931eab5d
38 files changed
+1128 -135

No files matched your search

@@ -35,6 +35,20 @@ func ReadProtectedPassword() (string, error) {
}
func readWindowsPassword(prompt string) (string, error) {
value, err := ReadProtectedInput(prompt)
if err != nil {
return "", err
}
if password.ValidateUserPassword(value) != nil {
return "", errors.New("密码长度必须为 8 到 12 个字符")
}
return value, nil
}
func ReadProtectedInput(prompt string) (string, error) {
if !term.IsTerminal(int(os.Stdin.Fd())) {
return "", errors.New("安全验证需要交互式控制台")
}
fmt.Fprint(os.Stderr, prompt+": ")
value, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Fprintln(os.Stderr)
@@ -45,8 +59,5 @@ func readWindowsPassword(prompt string) (string, error) {
for i := range value {
value[i] = 0
}
if password.ValidateUserPassword(normalized) != nil {
return "", errors.New("密码长度必须为 8 到 12 个字符")
}
return normalized, nil
}