@mondoohq/xgrep 0.68.0 → 0.69.1
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/README.md +6 -4
- package/bin/xgrep.js +125 -0
- package/package.json +29 -27
- package/index.js +0 -11
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ code-intelligence and AI-agent features on top of scanning.
|
|
|
10
10
|
This npm package ships prebuilt `xgrep` binaries for Linux, macOS, and Windows
|
|
11
11
|
(amd64 and arm64; the macOS binaries are signed and notarized).
|
|
12
12
|
|
|
13
|
+
**Documentation: https://mondoo.com/docs/xgrep**
|
|
14
|
+
|
|
13
15
|
## Install
|
|
14
16
|
|
|
15
17
|
Install globally to add the `xgrep` command to your `PATH` — the recommended way
|
|
@@ -57,9 +59,9 @@ A scan target can also be a **remote git repository** — xgrep clones it
|
|
|
57
59
|
needed:
|
|
58
60
|
|
|
59
61
|
```bash
|
|
60
|
-
xgrep scan github.com/mondoohq/
|
|
61
|
-
xgrep scan https://github.com/mondoohq/
|
|
62
|
-
xgrep scan github.com/mondoohq/
|
|
62
|
+
xgrep scan github.com/mondoohq/skills # host/owner/repo shorthand
|
|
63
|
+
xgrep scan https://github.com/mondoohq/skills # or a full HTTPS/SSH URL
|
|
64
|
+
xgrep scan github.com/mondoohq/skills --ref v1.2.0 # a branch, tag, or commit
|
|
63
65
|
```
|
|
64
66
|
|
|
65
67
|
## Add it to CI
|
|
@@ -89,5 +91,5 @@ They also install into Codex, Gemini CLI, and Cursor — see the
|
|
|
89
91
|
|
|
90
92
|
`xgrep fix` also drives an agent directly (`--agent codex`, or a custom command)
|
|
91
93
|
if you'd rather not install the skills. See the
|
|
92
|
-
[documentation](https://
|
|
94
|
+
[documentation](https://xgrep.ai) for the full scan → triage →
|
|
93
95
|
fix workflow.
|
package/bin/xgrep.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright (c) Mondoo, Inc. All rights reserved. 2026
|
|
3
|
+
// SPDX-License-Identifier: LicenseRef-Mondoo-Proprietary
|
|
4
|
+
|
|
5
|
+
// Launcher for the `xgrep` command installed from npm.
|
|
6
|
+
//
|
|
7
|
+
// npm cannot ship one package with six platform binaries, so `@mondoohq/xgrep`
|
|
8
|
+
// is a thin wrapper: it declares the six `@mondoohq/xgrep_<os>_<arch>` packages
|
|
9
|
+
// as optionalDependencies (npm installs only the one matching `os`/`cpu`) and
|
|
10
|
+
// this script execs whichever one landed.
|
|
11
|
+
//
|
|
12
|
+
// Its whole job is to be invisible. Two things make it visible, and both are
|
|
13
|
+
// what this file exists to get right:
|
|
14
|
+
//
|
|
15
|
+
// - THE EXIT CODE. xgrep's exit code is its CI contract (0 clean, 1 findings
|
|
16
|
+
// under --error, 2 fatal, 3 missing upload, 4 incomplete scan — see
|
|
17
|
+
// docs/08-integrations/ci.md). A launcher that spawns the child and never
|
|
18
|
+
// reads its status exits 0 always, which silently disables every gate for
|
|
19
|
+
// everyone who installed from npm — and npm is the install path our own CI
|
|
20
|
+
// documentation recommends. See xgrep#2745.
|
|
21
|
+
// - SIGNALS. Without forwarding, Ctrl+C kills the launcher and leaves the
|
|
22
|
+
// scan running detached, still holding its temp files.
|
|
23
|
+
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
const os = require('os');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
const { spawn } = require('child_process');
|
|
29
|
+
|
|
30
|
+
// The platform packages, keyed by `${process.platform}_${process.arch}`.
|
|
31
|
+
// Keep in sync with the goreleaser build matrix (.goreleaser*.yaml) and the
|
|
32
|
+
// package list in .github/workflows/release.yml.
|
|
33
|
+
const PLATFORM_PACKAGES = {
|
|
34
|
+
linux_x64: { pkg: '@mondoohq/xgrep_linux_amd64', bin: 'xgrep' },
|
|
35
|
+
linux_arm64: { pkg: '@mondoohq/xgrep_linux_arm64', bin: 'xgrep' },
|
|
36
|
+
darwin_x64: { pkg: '@mondoohq/xgrep_darwin_amd64', bin: 'xgrep' },
|
|
37
|
+
darwin_arm64: { pkg: '@mondoohq/xgrep_darwin_arm64', bin: 'xgrep' },
|
|
38
|
+
win32_x64: { pkg: '@mondoohq/xgrep_windows_amd64', bin: 'xgrep.exe' },
|
|
39
|
+
win32_arm64: { pkg: '@mondoohq/xgrep_windows_arm64', bin: 'xgrep.exe' },
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// xgrep's own fatal-error code, so a launcher failure is reported the same way
|
|
43
|
+
// the binary would report one rather than as a findings exit.
|
|
44
|
+
const EXIT_FATAL = 2;
|
|
45
|
+
|
|
46
|
+
function fail(message) {
|
|
47
|
+
process.stderr.write(`xgrep: ${message}\n`);
|
|
48
|
+
process.exit(EXIT_FATAL);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// resolveBinary finds the platform binary, or explains why it cannot.
|
|
52
|
+
//
|
|
53
|
+
// The failure modes here are all things a user can act on — an unsupported
|
|
54
|
+
// platform, or an install that skipped optionalDependencies (`--no-optional`,
|
|
55
|
+
// `--omit=optional`, or a lockfile built on another platform) — so each gets a
|
|
56
|
+
// sentence rather than a module-resolution stack trace.
|
|
57
|
+
function resolveBinary() {
|
|
58
|
+
const key = `${process.platform}_${process.arch}`;
|
|
59
|
+
const target = PLATFORM_PACKAGES[key];
|
|
60
|
+
if (!target) {
|
|
61
|
+
const supported = Object.keys(PLATFORM_PACKAGES).sort().join(', ');
|
|
62
|
+
fail(
|
|
63
|
+
`no prebuilt binary for ${process.platform}/${process.arch}.\n` +
|
|
64
|
+
` supported: ${supported}\n` +
|
|
65
|
+
' build from source: https://xgrep.ai'
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
let pkgJson;
|
|
69
|
+
try {
|
|
70
|
+
pkgJson = require.resolve(path.posix.join(target.pkg, 'package.json'));
|
|
71
|
+
} catch {
|
|
72
|
+
fail(
|
|
73
|
+
`the platform package ${target.pkg} is not installed.\n` +
|
|
74
|
+
' it ships as an optionalDependency, so this usually means the install ran with\n' +
|
|
75
|
+
' --no-optional / --omit=optional, or a lockfile from a different platform was used.\n' +
|
|
76
|
+
` fix: npm install ${target.pkg}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return path.join(path.dirname(pkgJson), target.bin);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function main() {
|
|
83
|
+
const child = spawn(resolveBinary(), process.argv.slice(2), {
|
|
84
|
+
stdio: 'inherit',
|
|
85
|
+
env: process.env,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Forward signals so Ctrl+C reaches the scan instead of orphaning it. xgrep
|
|
89
|
+
// handles SIGINT/SIGTERM itself (it flushes telemetry and exits 130), so the
|
|
90
|
+
// child is left to exit on its own terms and `close` below reports whatever
|
|
91
|
+
// it chose. kill() throws if the child is already gone — a race we can ignore.
|
|
92
|
+
const forwarded = ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGQUIT', 'SIGBREAK'];
|
|
93
|
+
const handlers = [];
|
|
94
|
+
for (const signal of forwarded) {
|
|
95
|
+
// Windows has no SIGHUP/SIGQUIT and rejects a listener for them.
|
|
96
|
+
if (!(signal in os.constants.signals)) continue;
|
|
97
|
+
const handler = () => {
|
|
98
|
+
try {
|
|
99
|
+
child.kill(signal);
|
|
100
|
+
} catch {
|
|
101
|
+
/* already exited */
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
handlers.push([signal, handler]);
|
|
105
|
+
process.on(signal, handler);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
child.on('error', (err) => fail(`could not run the xgrep binary: ${err.message}`));
|
|
109
|
+
|
|
110
|
+
child.on('close', (code, signal) => {
|
|
111
|
+
// Stop holding the event loop open, so the exit below is the process's own.
|
|
112
|
+
for (const [sig, handler] of handlers) process.removeListener(sig, handler);
|
|
113
|
+
|
|
114
|
+
if (signal) {
|
|
115
|
+
// Killed rather than exited. Report it the way a shell does (128+signum)
|
|
116
|
+
// so `$?` means the same thing through the launcher as without it.
|
|
117
|
+
const signum = os.constants.signals[signal];
|
|
118
|
+
process.exit(signum ? 128 + signum : EXIT_FATAL);
|
|
119
|
+
}
|
|
120
|
+
// `code` is null only when a signal was delivered, which is handled above.
|
|
121
|
+
process.exit(code === null ? EXIT_FATAL : code);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondoohq/xgrep",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.69.1",
|
|
4
|
+
"description": "A fast, Semgrep-compatible code scanner written in Go.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sast",
|
|
7
|
+
"code-scanner",
|
|
8
|
+
"semgrep",
|
|
9
|
+
"security",
|
|
10
|
+
"static-analysis",
|
|
11
|
+
"xgrep",
|
|
12
|
+
"cli"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://xgrep.ai",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://xgrep.ai"
|
|
6
17
|
},
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"@mondoohq/xgrep_windows_amd64": "0.68.0",
|
|
11
|
-
"@mondoohq/xgrep_windows_arm64": "0.68.0",
|
|
12
|
-
"@mondoohq/xgrep_darwin_amd64": "0.68.0",
|
|
13
|
-
"@mondoohq/xgrep_darwin_arm64": "0.68.0"
|
|
18
|
+
"license": "LicenseRef-Mondoo-Proprietary",
|
|
19
|
+
"bin": {
|
|
20
|
+
"xgrep": "bin/xgrep.js"
|
|
14
21
|
},
|
|
15
|
-
"os": [
|
|
16
|
-
"linux",
|
|
17
|
-
"win32",
|
|
18
|
-
"darwin"
|
|
19
|
-
],
|
|
20
|
-
"cpu": [
|
|
21
|
-
"x64",
|
|
22
|
-
"arm64"
|
|
23
|
-
],
|
|
24
22
|
"files": [
|
|
23
|
+
"bin/",
|
|
25
24
|
"README.md"
|
|
26
25
|
],
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"@mondoohq/xgrep_darwin_amd64": "0.69.1",
|
|
31
|
+
"@mondoohq/xgrep_darwin_arm64": "0.69.1",
|
|
32
|
+
"@mondoohq/xgrep_linux_amd64": "0.69.1",
|
|
33
|
+
"@mondoohq/xgrep_linux_arm64": "0.69.1",
|
|
34
|
+
"@mondoohq/xgrep_windows_amd64": "0.69.1",
|
|
35
|
+
"@mondoohq/xgrep_windows_arm64": "0.69.1"
|
|
34
36
|
}
|
|
35
|
-
}
|
|
37
|
+
}
|
package/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const child_process = require('child_process');
|
|
4
|
-
const mapping = { linux_x64: { name: [ '@mondoohq', 'xgrep_linux_amd64' ], bin: 'xgrep' }, linux_arm64: { name: [ '@mondoohq', 'xgrep_linux_arm64' ], bin: 'xgrep' }, win32_x64: { name: [ '@mondoohq', 'xgrep_windows_amd64' ], bin: 'xgrep.exe' }, win32_arm64: { name: [ '@mondoohq', 'xgrep_windows_arm64' ], bin: 'xgrep.exe' }, darwin_x64: { name: [ '@mondoohq', 'xgrep_darwin_amd64' ], bin: 'xgrep' }, darwin_arm64: { name: [ '@mondoohq', 'xgrep_darwin_arm64' ], bin: 'xgrep' } };
|
|
5
|
-
const definition = mapping[process.platform + '_' + process.arch];
|
|
6
|
-
const packageJsonPath = require.resolve(path.join(...definition.name, 'package.json'));
|
|
7
|
-
const packagePath = path.join(path.dirname(packageJsonPath), definition.bin);
|
|
8
|
-
child_process.spawn(packagePath, process.argv.splice(2), {
|
|
9
|
-
stdio: 'inherit',
|
|
10
|
-
env: process.env,
|
|
11
|
-
});
|