refactor: harden control-ui auth flow and add insecure-flag audit summary

This commit is contained in:
Peter Steinberger
2026-02-21 13:17:44 +01:00
parent 4cd7d95746
commit 14b0d2b816
4 changed files with 203 additions and 64 deletions

View File

@@ -707,7 +707,12 @@ describe("security audit", () => {
expect.arrayContaining([
expect.objectContaining({
checkId: "gateway.control_ui.insecure_auth",
severity: "critical",
severity: "warn",
}),
expect.objectContaining({
checkId: "config.insecure_or_dangerous_flags",
severity: "warn",
detail: expect.stringContaining("gateway.controlUi.allowInsecureAuth=true"),
}),
]),
);
@@ -728,10 +733,40 @@ describe("security audit", () => {
checkId: "gateway.control_ui.device_auth_disabled",
severity: "critical",
}),
expect.objectContaining({
checkId: "config.insecure_or_dangerous_flags",
severity: "warn",
detail: expect.stringContaining("gateway.controlUi.dangerouslyDisableDeviceAuth=true"),
}),
]),
);
});
it("warns when insecure/dangerous debug flags are enabled", async () => {
const cfg: OpenClawConfig = {
hooks: {
gmail: { allowUnsafeExternalContent: true },
mappings: [{ allowUnsafeExternalContent: true }],
},
tools: {
exec: {
applyPatch: {
workspaceOnly: false,
},
},
},
};
const res = await audit(cfg);
const finding = res.findings.find((f) => f.checkId === "config.insecure_or_dangerous_flags");
expect(finding).toBeTruthy();
expect(finding?.severity).toBe("warn");
expect(finding?.detail).toContain("hooks.gmail.allowUnsafeExternalContent=true");
expect(finding?.detail).toContain("hooks.mappings[0].allowUnsafeExternalContent=true");
expect(finding?.detail).toContain("tools.exec.applyPatch.workspaceOnly=false");
});
it("flags trusted-proxy auth mode without generic shared-secret findings", async () => {
const cfg: OpenClawConfig = {
gateway: {