@runsec/mcp 1.0.64 → 1.0.65
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/bin/ensure-binaries.cjs +10 -0
- package/bin/runsec-mcp.cjs +32 -7
- package/dist/index.js +36 -5
- package/package.json +1 -1
package/bin/ensure-binaries.cjs
CHANGED
|
@@ -370,15 +370,24 @@ async function installSemgrep() {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
async function runDownload() {
|
|
373
|
+
console.error(
|
|
374
|
+
`[RunSec Debug] ensure-binaries runDownload() PKG_ROOT=${PKG_ROOT} BIN_DIR=${BIN_DIR} platform=${process.platform} arch=${process.arch}`
|
|
375
|
+
);
|
|
376
|
+
|
|
373
377
|
if (process.env.RUNSEC_SKIP_BINARY_DOWNLOAD === "1") {
|
|
378
|
+
console.error("[RunSec Debug] ensure-binaries abort: RUNSEC_SKIP_BINARY_DOWNLOAD=1");
|
|
374
379
|
log("Skipping binary download (RUNSEC_SKIP_BINARY_DOWNLOAD=1)");
|
|
375
380
|
return;
|
|
376
381
|
}
|
|
377
382
|
if (shouldDeferPostinstall()) {
|
|
383
|
+
console.error(
|
|
384
|
+
"[RunSec Debug] ensure-binaries abort: shouldDeferPostinstall()=true (npx install deferral)"
|
|
385
|
+
);
|
|
378
386
|
log("Deferring binary download during npx install (fetched on first MCP start).");
|
|
379
387
|
return;
|
|
380
388
|
}
|
|
381
389
|
|
|
390
|
+
console.error("[RunSec Debug] ensure-binaries starting GitHub binary download…");
|
|
382
391
|
ensureDir(BIN_DIR);
|
|
383
392
|
const manifest = {
|
|
384
393
|
platform: `${process.platform}-${process.arch}`,
|
|
@@ -403,6 +412,7 @@ async function runDownload() {
|
|
|
403
412
|
|
|
404
413
|
fs.writeFileSync(MANIFEST_PATH, JSON.stringify(manifest, null, 2));
|
|
405
414
|
rmrf(STAGING_DIR);
|
|
415
|
+
console.error(`[RunSec Debug] ensure-binaries complete manifest=${JSON.stringify(manifest)}`);
|
|
406
416
|
log("Binary setup complete (see bin/.versions.json)");
|
|
407
417
|
}
|
|
408
418
|
|
package/bin/runsec-mcp.cjs
CHANGED
|
@@ -33,11 +33,14 @@ function optionalEngineResolvable(engine) {
|
|
|
33
33
|
? [`${pkg}/bin/${engine}.exe`, `${pkg}/bin/${engine}`]
|
|
34
34
|
: [`${pkg}/bin/${engine}`];
|
|
35
35
|
for (const candidate of candidates) {
|
|
36
|
+
console.error(`[RunSec Debug] runsec-mcp require.resolve: ${candidate}`);
|
|
36
37
|
try {
|
|
37
|
-
require.resolve(candidate);
|
|
38
|
+
const resolved = require.resolve(candidate);
|
|
39
|
+
console.error(`[RunSec Debug] runsec-mcp optional OK ${candidate} -> ${resolved}`);
|
|
38
40
|
return true;
|
|
39
|
-
} catch {
|
|
40
|
-
|
|
41
|
+
} catch (err) {
|
|
42
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
43
|
+
console.error(`[RunSec Debug] runsec-mcp require.resolve failed ${candidate}: ${message}`);
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
return false;
|
|
@@ -53,21 +56,43 @@ function binariesMissing() {
|
|
|
53
56
|
|
|
54
57
|
/** Thin package: skip GitHub download when platform optional @runsec/engine-* packages are installed. */
|
|
55
58
|
function shouldFetchBundledBinaries() {
|
|
56
|
-
if (process.env.RUNSEC_SKIP_BINARY_DOWNLOAD === "1")
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
if (process.env.RUNSEC_SKIP_BINARY_DOWNLOAD === "1") {
|
|
60
|
+
console.error("[RunSec Debug] ensure-binaries skipped: RUNSEC_SKIP_BINARY_DOWNLOAD=1");
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const thOptional = optionalEngineResolvable("trufflehog");
|
|
64
|
+
const syOptional = optionalEngineResolvable("syft");
|
|
65
|
+
console.error(
|
|
66
|
+
`[RunSec Debug] optionalEngineResolvable trufflehog=${thOptional} syft=${syOptional} platform=${process.platform} arch=${process.arch}`
|
|
67
|
+
);
|
|
68
|
+
if (thOptional && syOptional) {
|
|
69
|
+
console.error("[RunSec Debug] ensure-binaries skipped: optional @runsec/engine-* packages resolve");
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const missing = binariesMissing();
|
|
73
|
+
console.error(`[RunSec Debug] binariesMissing()=${missing} PKG_ROOT=${PKG_ROOT}`);
|
|
74
|
+
return missing;
|
|
59
75
|
}
|
|
60
76
|
|
|
61
|
-
|
|
77
|
+
const fetchBundled = shouldFetchBundledBinaries();
|
|
78
|
+
console.error(`[RunSec Debug] runsec-mcp startup: shouldFetchBundledBinaries=${fetchBundled}`);
|
|
79
|
+
|
|
80
|
+
if (fetchBundled) {
|
|
81
|
+
console.error("[RunSec Debug] Running ensure-binaries.cjs (GitHub download into bin/)…");
|
|
62
82
|
console.log("[runsec] Fetching security engine binaries (first run)…");
|
|
63
83
|
const result = spawnSync(process.execPath, [ensureScript], {
|
|
64
84
|
cwd: PKG_ROOT,
|
|
65
85
|
stdio: "inherit",
|
|
66
86
|
env: { ...process.env, RUNSEC_FORCE_BINARY_DOWNLOAD: "1" },
|
|
67
87
|
});
|
|
88
|
+
console.error(
|
|
89
|
+
`[RunSec Debug] ensure-binaries.cjs exit status=${result.status} signal=${result.signal ?? "none"}`
|
|
90
|
+
);
|
|
68
91
|
if (result.status !== 0) {
|
|
69
92
|
console.warn("[runsec] Binary setup incomplete; scans may use global tools or Docker.");
|
|
70
93
|
}
|
|
94
|
+
} else {
|
|
95
|
+
console.error("[RunSec Debug] ensure-binaries.cjs not invoked on this startup");
|
|
71
96
|
}
|
|
72
97
|
|
|
73
98
|
require("../dist/index.js");
|
package/dist/index.js
CHANGED
|
@@ -2030,16 +2030,32 @@ function binResolveCandidates(engineName, packageName) {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
function getEngineExecutable(engineName) {
|
|
2032
2032
|
const packageName = buildOptionalEnginePackageName(engineName);
|
|
2033
|
+
console.error(
|
|
2034
|
+
`[RunSec Debug] getEngineExecutable(${engineName}) platform=${process.platform} arch=${process.arch} __filename=${__filename}`
|
|
2035
|
+
);
|
|
2033
2036
|
if (!packageName) {
|
|
2037
|
+
console.error(
|
|
2038
|
+
`[RunSec Debug] Unsupported platform/arch for optional engine package \u2014 falling back to PATH: ${engineName}`
|
|
2039
|
+
);
|
|
2034
2040
|
return engineName;
|
|
2035
2041
|
}
|
|
2042
|
+
console.error(`[RunSec Debug] Optional package name: ${packageName}`);
|
|
2036
2043
|
const require2 = (0, import_node_module.createRequire)(__filename);
|
|
2037
|
-
|
|
2044
|
+
const candidates = binResolveCandidates(engineName, packageName);
|
|
2045
|
+
for (const candidate of candidates) {
|
|
2046
|
+
console.error(`[RunSec Debug] require.resolve target: ${candidate}`);
|
|
2038
2047
|
try {
|
|
2039
|
-
|
|
2040
|
-
|
|
2048
|
+
const resolved = require2.resolve(candidate);
|
|
2049
|
+
console.error(`[RunSec Debug] Found optional package binary at: ${resolved}`);
|
|
2050
|
+
return resolved;
|
|
2051
|
+
} catch (err) {
|
|
2052
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2053
|
+
console.error(`[RunSec Debug] require.resolve failed for ${candidate}: ${message}`);
|
|
2041
2054
|
}
|
|
2042
2055
|
}
|
|
2056
|
+
console.error(
|
|
2057
|
+
`[RunSec Debug] No optional package binary for ${engineName} (${packageName}) \u2014 falling back to PATH: ${engineName}`
|
|
2058
|
+
);
|
|
2043
2059
|
return engineName;
|
|
2044
2060
|
}
|
|
2045
2061
|
function isOptionalPackageExecutable(engineName, command) {
|
|
@@ -2080,14 +2096,29 @@ function getBundledBinDir() {
|
|
|
2080
2096
|
return import_node_path9.default.join(getPackageRoot(), "bin");
|
|
2081
2097
|
}
|
|
2082
2098
|
function resolveEngineBinary(tool) {
|
|
2099
|
+
const packageRoot = getPackageRoot();
|
|
2100
|
+
const bundledBinDir = getBundledBinDir();
|
|
2101
|
+
console.error(
|
|
2102
|
+
`[RunSec Debug] resolveEngineBinary(${tool}) packageRoot=${packageRoot} bundledBinDir=${bundledBinDir} __dirname=${__dirname}`
|
|
2103
|
+
);
|
|
2083
2104
|
const optionalCommand = getEngineExecutable(tool);
|
|
2105
|
+
console.error(`[RunSec Debug] Optional resolve result for ${tool}: ${optionalCommand}`);
|
|
2084
2106
|
if (isOptionalPackageExecutable(tool, optionalCommand)) {
|
|
2107
|
+
console.error(`[RunSec Debug] Using optional-package binary for ${tool}: ${optionalCommand}`);
|
|
2085
2108
|
return { command: optionalCommand, source: "optional-package" };
|
|
2086
2109
|
}
|
|
2087
|
-
const bundled = import_node_path9.default.join(
|
|
2088
|
-
|
|
2110
|
+
const bundled = import_node_path9.default.join(bundledBinDir, binFileName(tool));
|
|
2111
|
+
console.error(`[RunSec Debug] Checking bundled path: ${bundled}`);
|
|
2112
|
+
const bundledExists = import_node_fs6.default.existsSync(bundled);
|
|
2113
|
+
const bundledRunnable = bundledExists && isBundledBinaryRunnable(bundled);
|
|
2114
|
+
console.error(
|
|
2115
|
+
`[RunSec Debug] Bundled path exists=${bundledExists} runnable=${bundledRunnable}` + (bundledExists ? ` size=${import_node_fs6.default.statSync(bundled).size}` : "")
|
|
2116
|
+
);
|
|
2117
|
+
if (bundledRunnable) {
|
|
2118
|
+
console.error(`[RunSec Debug] Using bundled binary for ${tool}: ${bundled}`);
|
|
2089
2119
|
return { command: bundled, source: "bundled" };
|
|
2090
2120
|
}
|
|
2121
|
+
console.error(`[RunSec Debug] Fallback to global PATH for: ${tool}`);
|
|
2091
2122
|
return { command: tool, source: "global" };
|
|
2092
2123
|
}
|
|
2093
2124
|
function resolveEngineCommand(tool) {
|