@mondoohq/skillcheck 0.3.2 → 0.3.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/bin/skillcheck.js +69 -21
- package/package.json +7 -7
package/bin/skillcheck.js
CHANGED
|
@@ -44,36 +44,78 @@ function fail(message) {
|
|
|
44
44
|
process.exit(EXIT_FAILURE);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// candidateKeys lists the PLATFORM_PACKAGES keys to try, most preferred first.
|
|
48
|
+
//
|
|
49
|
+
// npm installs the optionalDependency matching the CPU of the Node that ran
|
|
50
|
+
// `npm install`, not the machine's, so switching Node builds afterwards leaves
|
|
51
|
+
// the "wrong" package on disk. Where the OS can run the other CPU's binary
|
|
52
|
+
// anyway, that package is an acceptable fallback:
|
|
53
|
+
//
|
|
54
|
+
// - win32: Windows on ARM64 runs both arm64 and x64 binaries (x64 under
|
|
55
|
+
// emulation), and an x64 Node there is common. arm64 <-> x64 both ways.
|
|
56
|
+
// - darwin: Apple Silicon runs x64 binaries under Rosetta, so an arm64 Node
|
|
57
|
+
// may use the x64 package. Not the reverse: an x64 Node may be on an Intel
|
|
58
|
+
// Mac, which cannot run arm64.
|
|
59
|
+
// - linux: strict. There is no general cross-CPU execution, and a binary
|
|
60
|
+
// that fails to exec is worse than a clear "not installed".
|
|
61
|
+
function candidateKeys(platform, arch) {
|
|
62
|
+
const keys = [`${platform}_${arch}`];
|
|
63
|
+
if (platform === 'win32') {
|
|
64
|
+
if (arch === 'arm64') keys.push('win32_x64');
|
|
65
|
+
else if (arch === 'x64') keys.push('win32_arm64');
|
|
66
|
+
} else if (platform === 'darwin' && arch === 'arm64') {
|
|
67
|
+
keys.push('darwin_x64');
|
|
68
|
+
}
|
|
69
|
+
return keys;
|
|
70
|
+
}
|
|
71
|
+
|
|
47
72
|
// resolveBinary finds the platform binary, or explains why it cannot. Each
|
|
48
73
|
// failure is something the user can act on, so each gets a sentence rather than
|
|
49
74
|
// a module-resolution stack trace.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
75
|
+
//
|
|
76
|
+
// platform, arch and resolve default to the real process and require.resolve;
|
|
77
|
+
// tests inject them. Returns { path } on success or { error } with the message.
|
|
78
|
+
function resolveBinary({ platform = process.platform, arch = process.arch, resolve = require.resolve } = {}) {
|
|
79
|
+
const targets = candidateKeys(platform, arch)
|
|
80
|
+
.map((key) => PLATFORM_PACKAGES[key])
|
|
81
|
+
.filter(Boolean);
|
|
82
|
+
if (targets.length === 0) {
|
|
54
83
|
const supported = Object.keys(PLATFORM_PACKAGES).sort().join(', ');
|
|
55
|
-
|
|
56
|
-
|
|
84
|
+
return {
|
|
85
|
+
error:
|
|
86
|
+
`no prebuilt binary for ${platform}/${arch}.\n` +
|
|
57
87
|
` supported: ${supported}\n` +
|
|
58
|
-
' other platforms: https://github.com/mondoohq/skillcheck/releases'
|
|
59
|
-
|
|
88
|
+
' other platforms: https://github.com/mondoohq/skillcheck/releases',
|
|
89
|
+
};
|
|
60
90
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
` fix: npm install ${target.pkg}`
|
|
70
|
-
);
|
|
91
|
+
for (const target of targets) {
|
|
92
|
+
let pkgJson;
|
|
93
|
+
try {
|
|
94
|
+
pkgJson = resolve(path.posix.join(target.pkg, 'package.json'));
|
|
95
|
+
} catch {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
return { path: path.join(path.dirname(pkgJson), target.bin) };
|
|
71
99
|
}
|
|
72
|
-
|
|
100
|
+
const preferred = targets[0].pkg;
|
|
101
|
+
const fallbacks = targets.slice(1).map((t) => t.pkg);
|
|
102
|
+
const which =
|
|
103
|
+
`the platform package ${preferred} is not installed` +
|
|
104
|
+
(fallbacks.length ? `, and neither is the fallback ${fallbacks.join(', ')}.` : '.');
|
|
105
|
+
return {
|
|
106
|
+
error:
|
|
107
|
+
`${which}\n` +
|
|
108
|
+
' it ships as an optionalDependency, so this usually means the install ran with\n' +
|
|
109
|
+
' --no-optional / --omit=optional, or a lockfile from a different platform was used,\n' +
|
|
110
|
+
` or node_modules was installed by a Node build for a different CPU than this one (${arch}).\n` +
|
|
111
|
+
` fix: npm install ${preferred}`,
|
|
112
|
+
};
|
|
73
113
|
}
|
|
74
114
|
|
|
75
115
|
function main() {
|
|
76
|
-
const
|
|
116
|
+
const resolved = resolveBinary();
|
|
117
|
+
if (resolved.error) fail(resolved.error);
|
|
118
|
+
const child = spawn(resolved.path, process.argv.slice(2), {
|
|
77
119
|
stdio: 'inherit',
|
|
78
120
|
env: process.env,
|
|
79
121
|
});
|
|
@@ -109,4 +151,10 @@ function main() {
|
|
|
109
151
|
});
|
|
110
152
|
}
|
|
111
153
|
|
|
112
|
-
|
|
154
|
+
// Run when executed as the `skillcheck` bin; export the resolution logic when
|
|
155
|
+
// required, so scripts/npm-launcher.test.mjs can test it without spawning.
|
|
156
|
+
if (require.main === module) {
|
|
157
|
+
main();
|
|
158
|
+
} else {
|
|
159
|
+
module.exports = { PLATFORM_PACKAGES, candidateKeys, resolveBinary };
|
|
160
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondoohq/skillcheck",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "AI agent skill security scanner. Detects locally installed agent skills, computes SHA-256 checksums, and queries the Mondoo AI Agent Security database for known threats.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-security",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"node": ">=18"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@mondoohq/skillcheck_darwin_amd64": "0.3.
|
|
37
|
-
"@mondoohq/skillcheck_darwin_arm64": "0.3.
|
|
38
|
-
"@mondoohq/skillcheck_linux_amd64": "0.3.
|
|
39
|
-
"@mondoohq/skillcheck_linux_arm64": "0.3.
|
|
40
|
-
"@mondoohq/skillcheck_windows_amd64": "0.3.
|
|
41
|
-
"@mondoohq/skillcheck_windows_arm64": "0.3.
|
|
36
|
+
"@mondoohq/skillcheck_darwin_amd64": "0.3.3",
|
|
37
|
+
"@mondoohq/skillcheck_darwin_arm64": "0.3.3",
|
|
38
|
+
"@mondoohq/skillcheck_linux_amd64": "0.3.3",
|
|
39
|
+
"@mondoohq/skillcheck_linux_arm64": "0.3.3",
|
|
40
|
+
"@mondoohq/skillcheck_windows_amd64": "0.3.3",
|
|
41
|
+
"@mondoohq/skillcheck_windows_arm64": "0.3.3"
|
|
42
42
|
}
|
|
43
43
|
}
|