@silmaril-security/firewall-plugin 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +9 -0
- package/CLAUDE.md +303 -0
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +320 -0
- package/dist/index.js +1141 -0
- package/openclaw.plugin.json +48 -0
- package/package.json +46 -0
- package/scripts/open-playground.mjs +104 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "firewall-plugin",
|
|
3
|
+
"name": "Firewall Plugin",
|
|
4
|
+
"description": "Passes OpenClaw agent, tool, message, delivery, and subagent lifecycle hook payloads to Silmaril and renders readable blocked-decision feedback.",
|
|
5
|
+
"activation": {
|
|
6
|
+
"onStartup": true,
|
|
7
|
+
"onCapabilities": ["hook"]
|
|
8
|
+
},
|
|
9
|
+
"configSchema": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"additionalProperties": true,
|
|
12
|
+
"properties": {
|
|
13
|
+
"apiKey": { "type": "string" },
|
|
14
|
+
"silmarilApiKey": { "type": "string" },
|
|
15
|
+
"apiUrl": { "type": "string" },
|
|
16
|
+
"endpointId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
19
|
+
},
|
|
20
|
+
"timeoutMs": {
|
|
21
|
+
"type": "integer",
|
|
22
|
+
"minimum": 250,
|
|
23
|
+
"maximum": 10000,
|
|
24
|
+
"default": 2500
|
|
25
|
+
},
|
|
26
|
+
"mode": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["shadow", "warn", "block"]
|
|
29
|
+
},
|
|
30
|
+
"shadowMode": {
|
|
31
|
+
"type": "boolean"
|
|
32
|
+
},
|
|
33
|
+
"blockMalicious": {
|
|
34
|
+
"type": "boolean"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"uiHints": {
|
|
39
|
+
"apiKey": { "label": "API Key", "sensitive": true },
|
|
40
|
+
"silmarilApiKey": { "label": "Silmaril API Key", "sensitive": true },
|
|
41
|
+
"apiUrl": { "label": "API URL" },
|
|
42
|
+
"endpointId": { "label": "Endpoint ID", "advanced": true },
|
|
43
|
+
"timeoutMs": { "label": "Classification timeout (ms)", "advanced": true },
|
|
44
|
+
"mode": { "label": "Mode override", "advanced": true },
|
|
45
|
+
"shadowMode": { "label": "Legacy shadow mode", "advanced": true },
|
|
46
|
+
"blockMalicious": { "label": "Legacy block malicious", "advanced": true }
|
|
47
|
+
}
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@silmaril-security/firewall-plugin",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "node scripts/build.mjs",
|
|
8
|
+
"test": "npm run build && node scripts/run-unit-tests.mjs",
|
|
9
|
+
"test:unit": "npm run build && node scripts/run-unit-tests.mjs",
|
|
10
|
+
"prepack": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
".env.example",
|
|
14
|
+
"dist",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"NOTICE",
|
|
17
|
+
"openclaw.plugin.json",
|
|
18
|
+
"scripts/open-playground.mjs",
|
|
19
|
+
"README.md",
|
|
20
|
+
"CLAUDE.md"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@silmaril-security/sdk": "0.6.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"esbuild": "0.28.0",
|
|
27
|
+
"tsx": "4.22.3"
|
|
28
|
+
},
|
|
29
|
+
"openclaw": {
|
|
30
|
+
"extensions": [
|
|
31
|
+
"./dist/index.js"
|
|
32
|
+
],
|
|
33
|
+
"compat": {
|
|
34
|
+
"pluginApi": ">=2026.5.28",
|
|
35
|
+
"minGatewayVersion": "2026.5.28"
|
|
36
|
+
},
|
|
37
|
+
"build": {
|
|
38
|
+
"openclawVersion": "2026.5.28",
|
|
39
|
+
"pluginSdkVersion": "2026.5.28"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
|
|
5
|
+
const DEFAULT_DEMO_BASE_URL = "https://app.silmaril.dev";
|
|
6
|
+
const ROUTES = {
|
|
7
|
+
setup: "/demo/setup-complete",
|
|
8
|
+
playground: "/demo/playground",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function hasFlag(name) {
|
|
12
|
+
return process.argv.includes(name);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function optionValue(name) {
|
|
16
|
+
const index = process.argv.indexOf(name);
|
|
17
|
+
if (index < 0) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const next = process.argv[index + 1];
|
|
21
|
+
return next && !next.startsWith("--") ? next : undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalizeBaseUrl(value) {
|
|
25
|
+
const raw = (value || "").trim() || DEFAULT_DEMO_BASE_URL;
|
|
26
|
+
return raw.startsWith("http://") || raw.startsWith("https://")
|
|
27
|
+
? raw
|
|
28
|
+
: `https://${raw}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizeRoute(value) {
|
|
32
|
+
return value === "playground" ? "playground" : "setup";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function routeFromCli() {
|
|
36
|
+
return hasFlag("--playground") ? "playground" : normalizeRoute(optionValue("--route"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function buildDemoUrl(baseUrl, route = "setup") {
|
|
40
|
+
return new URL(ROUTES[normalizeRoute(route)], normalizeBaseUrl(baseUrl)).href;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function openerCommand(url) {
|
|
44
|
+
if (process.platform === "darwin") {
|
|
45
|
+
return { command: "open", args: [url], options: { detached: true, stdio: "ignore" } };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (process.platform === "win32") {
|
|
49
|
+
return {
|
|
50
|
+
command: "cmd",
|
|
51
|
+
args: ["/c", "start", "", url],
|
|
52
|
+
options: { detached: true, stdio: "ignore", windowsHide: true },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { command: "xdg-open", args: [url], options: { detached: true, stdio: "ignore" } };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function printOrOpen(url, spawnImpl = spawn) {
|
|
60
|
+
if (hasFlag("--json")) {
|
|
61
|
+
console.log(JSON.stringify({ url }));
|
|
62
|
+
} else {
|
|
63
|
+
console.log(url);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (hasFlag("--open")) {
|
|
67
|
+
const { command, args, options } = openerCommand(url);
|
|
68
|
+
try {
|
|
69
|
+
const child = spawnImpl(command, args, options);
|
|
70
|
+
child.on("error", (error) => {
|
|
71
|
+
console.error(`Could not open browser with ${command}: ${error.message}`);
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
});
|
|
74
|
+
child.unref();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error(`Could not open browser with ${command}: ${error.message}`);
|
|
77
|
+
process.exitCode = 1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function printHelp() {
|
|
83
|
+
console.log("Usage: node scripts/open-playground.mjs [--open] [--json] [--playground] [--route <setup|playground>]");
|
|
84
|
+
console.log("");
|
|
85
|
+
console.log("Prints the public Silmaril Firewall demo URL.");
|
|
86
|
+
console.log("Override the hosted base URL with SILMARIL_DEMO_BASE_URL for preview validation.");
|
|
87
|
+
console.log("Pass --json to print a machine-readable URL without OpenClaw configuration values.");
|
|
88
|
+
console.log(`Platform: ${os.platform()}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function main() {
|
|
92
|
+
if (hasFlag("--help") || hasFlag("-h")) {
|
|
93
|
+
printHelp();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const demoBaseUrl = process.env.SILMARIL_DEMO_BASE_URL ?? DEFAULT_DEMO_BASE_URL;
|
|
98
|
+
const route = routeFromCli();
|
|
99
|
+
await printOrOpen(buildDemoUrl(demoBaseUrl, route));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
103
|
+
await main();
|
|
104
|
+
}
|