fix: enforce work product external url policy
This commit is contained in:
1 parent
c779fc2858
commit
6c757f2081
7 files changed
+456
-30
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
classifyExternalUrl,
|
||||
normalizeExternalHttpUrl,
|
||||
} from "../../src/main/external-url-policy";
|
||||
|
||||
describe("external URL policy", () => {
|
||||
it("normalizes http and https URLs", () => {
|
||||
expect(normalizeExternalHttpUrl(" https://github.com/agentcompany ")).toBe("https://github.com/agentcompany");
|
||||
expect(normalizeExternalHttpUrl("http://example.com/path?q=1")).toBe("http://example.com/path?q=1");
|
||||
});
|
||||
|
||||
it("blocks custom schemes and credential-bearing URLs", () => {
|
||||
expect(classifyExternalUrl("vscode://file/etc/passwd")).toMatchObject({ kind: "blocked" });
|
||||
expect(classifyExternalUrl("https://user:pass@example.com/report")).toMatchObject({ kind: "blocked" });
|
||||
});
|
||||
|
||||
it("separates trusted hosts from confirmation hosts", () => {
|
||||
expect(classifyExternalUrl("https://github.com/acme/repo")).toMatchObject({ kind: "trusted", host: "github.com" });
|
||||
expect(classifyExternalUrl("https://example.com/report")).toMatchObject({ kind: "confirm", host: "example.com" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user