@upx-us/shield
Advanced tools
| #!/usr/bin/env node | ||
| /** | ||
| * postinstall.js — runs after `npm install`. | ||
| * | ||
| * Checks whether the openclaw CLI is available. If it is not, this plugin | ||
| * has been installed outside of an OpenClaw gateway environment, and we | ||
| * print a clear warning to stderr so the user knows what to do. | ||
| * | ||
| * Must be plain CommonJS — no TypeScript, no npm dependencies. | ||
| * Runs before any build step, so dist/ may not exist yet. | ||
| * | ||
| * Safety contract: this script MUST NEVER exit non-zero. A broken postinstall | ||
| * would fail `npm install` for real users, which is unacceptable. | ||
| * The outer try/catch guarantees exit(0) in all circumstances. | ||
| */ | ||
| 'use strict'; | ||
| const { execSync } = require('child_process'); | ||
| const { existsSync } = require('fs'); | ||
| const { join } = require('path'); | ||
| const WARNING_BOX = [ | ||
| '', | ||
| ' ┌─────────────────────────────────────────────────────────┐', | ||
| ' │ ⚠️ OpenClaw Shield requires the OpenClaw gateway │', | ||
| ' │ This plugin is not meant to be installed directly. │', | ||
| ' │ Get started at: https://openclaw.ai │', | ||
| ' └─────────────────────────────────────────────────────────┘', | ||
| '', | ||
| ].join('\n') + '\n'; | ||
| function isOpenClawAvailable() { | ||
| const rawPath = String(process.env.PATH || ''); | ||
| const rawParts = rawPath.split(/[:;]/).filter(Boolean); | ||
| const pathDirs = []; | ||
| for (let i = 0; i < rawParts.length; i++) { | ||
| const part = rawParts[i]; | ||
| if ( | ||
| process.platform === 'win32' && | ||
| /^[A-Za-z]$/.test(part) && | ||
| rawParts[i + 1] && | ||
| /^[\\/]/.test(rawParts[i + 1]) | ||
| ) { | ||
| pathDirs.push(part + ':' + rawParts[i + 1]); | ||
| i++; | ||
| continue; | ||
| } | ||
| pathDirs.push(part); | ||
| } | ||
| const candidates = process.platform === 'win32' | ||
| ? ['openclaw.exe', 'openclaw.cmd', 'openclaw.bat', 'openclaw'] | ||
| : ['openclaw']; | ||
| for (const dir of pathDirs) { | ||
| for (const candidate of candidates) { | ||
| try { | ||
| if (existsSync(join(dir, candidate))) return true; | ||
| } catch (_) { | ||
| // ignore path access errors and continue | ||
| } | ||
| } | ||
| } | ||
| // Try `which openclaw` first (POSIX), then a version flag as a fallback. | ||
| // The fallback is important on Windows where `which` is not available. | ||
| const checks = ['which openclaw', 'openclaw --version']; | ||
| for (const cmd of checks) { | ||
| try { | ||
| execSync(cmd, { stdio: 'ignore' }); | ||
| return true; | ||
| } catch (_) { | ||
| // continue to next check | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| try { | ||
| if (!isOpenClawAvailable()) { | ||
| process.stderr.write(WARNING_BOX); | ||
| } | ||
| process.exit(0); | ||
| } catch (_) { | ||
| // Never break a real install — exit cleanly no matter what | ||
| process.exit(0); | ||
| } |
+10
-0
@@ -7,2 +7,12 @@ # Changelog | ||
| ## [0.9.5] — 2026-04-08 | ||
| ### Fixed | ||
| - **install**: fix postinstall hook path — moved postinstall.js to repo root so it is included in the published tarball (closes #227) | ||
| - **docs**: add missing `plugins.allow` config step to README Option 1 (closes #227) | ||
| - **cli**: fix `activate` command using stale in-memory state instead of on-disk credentials (closes #227) | ||
| --- | ||
| ## [0.9.4] — 2026-04-06 | ||
@@ -9,0 +19,0 @@ |
@@ -5,3 +5,3 @@ { | ||
| "description": "Real-time security monitoring \u2014 streams enriched, redacted security events to the Shield detection platform.", | ||
| "version": "0.9.4", | ||
| "version": "0.9.5", | ||
| "skills": [ | ||
@@ -8,0 +8,0 @@ "./skills" |
+3
-2
| { | ||
| "name": "@upx-us/shield", | ||
| "version": "0.9.4", | ||
| "version": "0.9.5", | ||
| "description": "Security monitoring and SIEM integration for OpenClaw agents — behavioral detection, case generation, and forensic audit trail via Google SecOps (Chronicle).", | ||
@@ -16,2 +16,3 @@ "main": "dist/index.js", | ||
| "openclaw.plugin.json", | ||
| "postinstall.js", | ||
| "skills/", | ||
@@ -23,3 +24,3 @@ "README.md", | ||
| "scripts": { | ||
| "postinstall": "node scripts/postinstall.js", | ||
| "postinstall": "node postinstall.js", | ||
| "prebuild": "npm run clean", | ||
@@ -26,0 +27,0 @@ "build": "tsc", |
+12
-0
@@ -108,3 +108,15 @@ # OpenClaw Shield | ||
| openclaw plugins install @upx-us/shield | ||
| ``` | ||
| Then add `"shield"` to the `plugins.allow` array in your `openclaw.json`: | ||
| ```json | ||
| { | ||
| "plugins": { | ||
| "allow": ["shield"] | ||
| } | ||
| } | ||
| ``` | ||
| ```bash | ||
| # Step 2: Activate (exchanges your key for credentials) | ||
@@ -111,0 +123,0 @@ openclaw shield activate <YOUR_KEY> |
Sorry, the diff of this file is too big to display
Install scripts
Supply chain riskInstall scripts are run when the package is installed or built. Malicious packages often use scripts that run automatically to execute payloads or fetch additional code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 20 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed or built. Malicious packages often use scripts that run automatically to execute payloads or fetch additional code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 19 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
457625
0.71%189
0.53%9286
0.88%637
1.92%52
4%15
7.14%