mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:57:39 +00:00
feat(security): warn on dangerous config flags at startup
This commit is contained in:
45
src/gateway/server-startup-log.test.ts
Normal file
45
src/gateway/server-startup-log.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { logGatewayStartup } from "./server-startup-log.js";
|
||||
|
||||
describe("gateway startup log", () => {
|
||||
it("warns when dangerous config flags are enabled", () => {
|
||||
const info = vi.fn();
|
||||
const warn = vi.fn();
|
||||
|
||||
logGatewayStartup({
|
||||
cfg: {
|
||||
gateway: {
|
||||
controlUi: {
|
||||
dangerouslyDisableDeviceAuth: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
bindHost: "127.0.0.1",
|
||||
port: 18789,
|
||||
log: { info, warn },
|
||||
isNixMode: false,
|
||||
});
|
||||
|
||||
expect(warn).toHaveBeenCalledTimes(1);
|
||||
expect(warn).toHaveBeenCalledWith(expect.stringContaining("dangerous config flags enabled"));
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
expect.stringContaining("gateway.controlUi.dangerouslyDisableDeviceAuth=true"),
|
||||
);
|
||||
expect(warn).toHaveBeenCalledWith(expect.stringContaining("openclaw security audit"));
|
||||
});
|
||||
|
||||
it("does not warn when dangerous config flags are disabled", () => {
|
||||
const info = vi.fn();
|
||||
const warn = vi.fn();
|
||||
|
||||
logGatewayStartup({
|
||||
cfg: {},
|
||||
bindHost: "127.0.0.1",
|
||||
port: 18789,
|
||||
log: { info, warn },
|
||||
isNixMode: false,
|
||||
});
|
||||
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user