隐藏密码重置接口本机命令标识并扩大响应回归
This commit is contained in:
parent
5791e7906f
commit
9c58c5b079
@ -50,7 +50,7 @@ func (s *Server) resolvePasswordResetAccount(c *gin.Context) {
|
|||||||
AccountLabel: "超级管理员",
|
AccountLabel: "超级管理员",
|
||||||
Title: "超级管理员密码重置",
|
Title: "超级管理员密码重置",
|
||||||
Description: "已识别为超级管理员账户。该账户不能通过普通重置页面修改密码,请联系系统管理员按照服务器本机安全维护流程处理。",
|
Description: "已识别为超级管理员账户。该账户不能通过普通重置页面修改密码,请联系系统管理员按照服务器本机安全维护流程处理。",
|
||||||
Action: "local_admin_command",
|
Action: "contact_administrator",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPasswordResetResolutionOnlyOffersLocalAdminCommand(t *testing.T) {
|
func TestPasswordResetResolutionOnlyOffersAdministratorContact(t *testing.T) {
|
||||||
cfg := readyTestConfig(t.TempDir())
|
cfg := readyTestConfig(t.TempDir())
|
||||||
cfg.Admin.Username = "owner"
|
cfg.Admin.Username = "owner"
|
||||||
cfg.Admin.Email = "owner@example.test"
|
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 {
|
if err := json.Unmarshal(response.Body.Bytes(), &payload); err != nil {
|
||||||
t.Fatal(err)
|
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)
|
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)
|
t.Fatalf("公开查询不应泄露本机管理命令:%s", description)
|
||||||
}
|
}
|
||||||
for _, field := range []string{"reset_path", "reset_url", "token", "nonce"} {
|
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 {
|
if _, authenticated := s.currentAuthSession(c); authenticated {
|
||||||
payload["https_mode"] = cfg.Server.HTTPSMode
|
payload["https_mode"] = cfg.Server.HTTPSMode
|
||||||
payload["database_driver"] = cfg.Database.Driver
|
payload["database_driver"] = cfg.Database.Driver
|
||||||
payload["reset_method"] = "local_admin_command"
|
payload["reset_method"] = "contact_administrator"
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, payload)
|
c.JSON(http.StatusOK, payload)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ function elements(node, predicate, matches = []) {
|
|||||||
test("超级管理员查询保留本机处理标识,不生成网页重置链接", async (t) => {
|
test("超级管理员查询保留本机处理标识,不生成网页重置链接", async (t) => {
|
||||||
const payload = {
|
const payload = {
|
||||||
account_type: "super_admin",
|
account_type: "super_admin",
|
||||||
action: "local_admin_command",
|
action: "contact_administrator",
|
||||||
title: "超级管理员密码重置",
|
title: "超级管理员密码重置",
|
||||||
description: "请在部署主机操作。",
|
description: "请在部署主机操作。",
|
||||||
};
|
};
|
||||||
@ -32,8 +32,9 @@ test("超级管理员查询保留本机处理标识,不生成网页重置链
|
|||||||
});
|
});
|
||||||
state.identifier.value = " owner ";
|
state.identifier.value = " owner ";
|
||||||
await state.submit();
|
await state.submit();
|
||||||
assert.equal(state.resolution.value.action, "local_admin_command");
|
assert.equal(state.resolution.value.action, "contact_administrator");
|
||||||
assert.equal("reset_path" in state.resolution.value, false);
|
assert.equal("reset_path" in state.resolution.value, false);
|
||||||
|
assert.doesNotMatch(JSON.stringify(state.resolution.value), /local_admin_command|systemctl|scert-admin/iu);
|
||||||
assert.equal(state.error.value, "");
|
assert.equal(state.error.value, "");
|
||||||
assert.equal(state.submitting.value, false);
|
assert.equal(state.submitting.value, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user