mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:58:28 +00:00
fix(security): harden imessage remote scp/ssh handling
This commit is contained in:
19
src/infra/scp-host.test.ts
Normal file
19
src/infra/scp-host.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isSafeScpRemoteHost, normalizeScpRemoteHost } from "./scp-host.js";
|
||||
|
||||
describe("scp remote host", () => {
|
||||
it("accepts host and user@host forms", () => {
|
||||
expect(normalizeScpRemoteHost("gateway-host")).toBe("gateway-host");
|
||||
expect(normalizeScpRemoteHost("bot@gateway-host")).toBe("bot@gateway-host");
|
||||
expect(normalizeScpRemoteHost("bot@192.168.64.3")).toBe("bot@192.168.64.3");
|
||||
expect(normalizeScpRemoteHost("bot@[fe80::1]")).toBe("bot@[fe80::1]");
|
||||
});
|
||||
|
||||
it("rejects unsafe host tokens", () => {
|
||||
expect(isSafeScpRemoteHost("-oProxyCommand=whoami")).toBe(false);
|
||||
expect(isSafeScpRemoteHost("bot@gateway-host -oStrictHostKeyChecking=no")).toBe(false);
|
||||
expect(isSafeScpRemoteHost("bot@host:22")).toBe(false);
|
||||
expect(isSafeScpRemoteHost("bot@/tmp/host")).toBe(false);
|
||||
expect(isSafeScpRemoteHost("bot@@host")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user