隐藏密码重置接口本机命令标识并扩大响应回归
This commit is contained in:
1 parent
5791e7906f
commit
9c58c5b079
4 files changed
+8
-7
No files matched your search
@@ -50,7 +50,7 @@ func (s *Server) resolvePasswordResetAccount(c *gin.Context) {
|
||||
AccountLabel: "超级管理员",
|
||||
Title: "超级管理员密码重置",
|
||||
Description: "已识别为超级管理员账户。该账户不能通过普通重置页面修改密码,请联系系统管理员按照服务器本机安全维护流程处理。",
|
||||
Action: "local_admin_command",
|
||||
Action: "contact_administrator",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPasswordResetResolutionOnlyOffersLocalAdminCommand(t *testing.T) {
|
||||
func TestPasswordResetResolutionOnlyOffersAdministratorContact(t *testing.T) {
|
||||
cfg := readyTestConfig(t.TempDir())
|
||||
cfg.Admin.Username = "owner"
|
||||
cfg.Admin.Email = "owner@example.test"
|
||||
@@ -30,10 +30,10 @@ func TestPasswordResetResolutionOnlyOffersLocalAdminCommand(t *testing.T) {
|
||||
if err := json.Unmarshal(response.Body.Bytes(), &payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if payload["account_type"] != "super_admin" || payload["action"] != "local_admin_command" {
|
||||
if payload["account_type"] != "super_admin" || payload["action"] != "contact_administrator" {
|
||||
t.Fatalf("超级管理员没有返回受控本机处理标识:%v", payload)
|
||||
}
|
||||
if description, _ := payload["description"].(string); strings.Contains(strings.ToLower(description), "scert-admin") || strings.Contains(description, "systemctl") {
|
||||
if description := strings.ToLower(response.Body.String()); strings.Contains(description, "scert-admin") || strings.Contains(description, "systemctl") || strings.Contains(description, "local_admin_command") {
|
||||
t.Fatalf("公开查询不应泄露本机管理命令:%s", description)
|
||||
}
|
||||
for _, field := range []string{"reset_path", "reset_url", "token", "nonce"} {
|
||||
|
||||
@@ -525,7 +525,7 @@ func (s *Server) status(c *gin.Context) {
|
||||
if _, authenticated := s.currentAuthSession(c); authenticated {
|
||||
payload["https_mode"] = cfg.Server.HTTPSMode
|
||||
payload["database_driver"] = cfg.Database.Driver
|
||||
payload["reset_method"] = "local_admin_command"
|
||||
payload["reset_method"] = "contact_administrator"
|
||||
}
|
||||
c.JSON(http.StatusOK, payload)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user