@j3ssie/osmedeus 5.1.0-linux-x64 → 5.1.0
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/osmedeus.js +188 -0
- package/package.json +25 -10
- package/vendor/linux-x64/osmedeus.gz +0 -0
package/bin/osmedeus.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unified entry point for the Osmedeus CLI distributed via npm.
|
|
3
|
+
//
|
|
4
|
+
// The platform-specific binary is shipped *gzipped* inside an optional
|
|
5
|
+
// dependency package (one of @j3ssie/osmedeus-<tag>). On first run we
|
|
6
|
+
// decompress it once into a version-scoped cache directory and then exec it,
|
|
7
|
+
// forwarding args, stdio, signals and the exit status.
|
|
8
|
+
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { createReadStream, createWriteStream, existsSync, statSync } from "node:fs";
|
|
11
|
+
import { mkdir, rename, chmod, unlink } from "node:fs/promises";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
import { pipeline } from "node:stream/promises";
|
|
14
|
+
import { createGunzip } from "node:zlib";
|
|
15
|
+
import os from "node:os";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
|
|
19
|
+
// __dirname / require equivalents in ESM.
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
|
|
24
|
+
// Local alias (npm install path) -> nothing else; the underlying package
|
|
25
|
+
// published to npm is always @j3ssie/osmedeus with a version suffix.
|
|
26
|
+
const PLATFORM_PACKAGE_BY_TAG = {
|
|
27
|
+
"linux-x64": "@j3ssie/osmedeus-linux-x64",
|
|
28
|
+
"linux-arm64": "@j3ssie/osmedeus-linux-arm64",
|
|
29
|
+
"darwin-x64": "@j3ssie/osmedeus-darwin-x64",
|
|
30
|
+
"darwin-arm64": "@j3ssie/osmedeus-darwin-arm64",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const { platform, arch } = process;
|
|
34
|
+
|
|
35
|
+
function detectPackageManager() {
|
|
36
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
37
|
+
if (/\bbun\//.test(userAgent)) return "bun";
|
|
38
|
+
const execPath = process.env.npm_execpath || "";
|
|
39
|
+
if (execPath.includes("bun")) return "bun";
|
|
40
|
+
return userAgent ? "npm" : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function reinstallHint() {
|
|
44
|
+
return detectPackageManager() === "bun"
|
|
45
|
+
? "bun install -g @j3ssie/osmedeus@latest"
|
|
46
|
+
: "npm install -g @j3ssie/osmedeus@latest";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let platformTag = null;
|
|
50
|
+
switch (platform) {
|
|
51
|
+
case "linux":
|
|
52
|
+
case "android":
|
|
53
|
+
if (arch === "x64") platformTag = "linux-x64";
|
|
54
|
+
else if (arch === "arm64") platformTag = "linux-arm64";
|
|
55
|
+
break;
|
|
56
|
+
case "darwin":
|
|
57
|
+
if (arch === "x64") platformTag = "darwin-x64";
|
|
58
|
+
else if (arch === "arm64") platformTag = "darwin-arm64";
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!platformTag) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Unsupported platform: ${platform} (${arch}). ` +
|
|
67
|
+
`Osmedeus npm builds cover linux/darwin on x64/arm64. ` +
|
|
68
|
+
`See https://docs.osmedeus.org for other install options.`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const platformPackage = PLATFORM_PACKAGE_BY_TAG[platformTag];
|
|
73
|
+
|
|
74
|
+
// Resolve the gzipped binary: prefer the installed optional-dependency
|
|
75
|
+
// package, fall back to a local vendor/ tree (used by `npm pack` testing and
|
|
76
|
+
// in-repo dev before publishing).
|
|
77
|
+
const gzName = "osmedeus.gz";
|
|
78
|
+
const localVendorRoot = path.join(__dirname, "..", "vendor");
|
|
79
|
+
const localGzPath = path.join(localVendorRoot, platformTag, gzName);
|
|
80
|
+
|
|
81
|
+
let gzPath = null;
|
|
82
|
+
try {
|
|
83
|
+
const pkgJsonPath = require.resolve(`${platformPackage}/package.json`);
|
|
84
|
+
gzPath = path.join(path.dirname(pkgJsonPath), "vendor", platformTag, gzName);
|
|
85
|
+
} catch {
|
|
86
|
+
if (existsSync(localGzPath)) {
|
|
87
|
+
gzPath = localGzPath;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!gzPath || !existsSync(gzPath)) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Missing platform package ${platformPackage} (the osmedeus binary for ` +
|
|
94
|
+
`${platformTag} was not installed). This usually means npm skipped ` +
|
|
95
|
+
`optional dependencies. Reinstall Osmedeus:\n ${reinstallHint()}`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Version-scoped cache path so upgrades never exec a stale binary, and so the
|
|
100
|
+
// extraction directory is always writable by the running user even when the
|
|
101
|
+
// package itself was installed into a root-owned global prefix.
|
|
102
|
+
const pkgVersion = require("../package.json").version;
|
|
103
|
+
const osmedeusHome =
|
|
104
|
+
process.env.OSMEDEUS_NPM_HOME || path.join(os.homedir(), ".osmedeus");
|
|
105
|
+
const binaryDir = path.join(osmedeusHome, "npm-bin", pkgVersion, platformTag);
|
|
106
|
+
const binaryPath = path.join(binaryDir, "osmedeus");
|
|
107
|
+
|
|
108
|
+
async function ensureBinary() {
|
|
109
|
+
if (existsSync(binaryPath) && statSync(binaryPath).size > 0) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
await mkdir(binaryDir, { recursive: true });
|
|
114
|
+
|
|
115
|
+
// Decompress to a unique temp file, then atomically rename into place so
|
|
116
|
+
// concurrent first-runs and interrupted extractions can never leave a
|
|
117
|
+
// truncated binary at the final path.
|
|
118
|
+
const tmpPath = path.join(
|
|
119
|
+
binaryDir,
|
|
120
|
+
`osmedeus.${process.pid}.${Date.now()}.tmp`,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
await pipeline(
|
|
125
|
+
createReadStream(gzPath),
|
|
126
|
+
createGunzip(),
|
|
127
|
+
createWriteStream(tmpPath, { mode: 0o755 }),
|
|
128
|
+
);
|
|
129
|
+
await chmod(tmpPath, 0o755);
|
|
130
|
+
await rename(tmpPath, binaryPath);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
await unlink(tmpPath).catch(() => {});
|
|
133
|
+
// Another racing process may have completed the extraction already.
|
|
134
|
+
if (existsSync(binaryPath) && statSync(binaryPath).size > 0) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
throw new Error(
|
|
138
|
+
`Failed to unpack the osmedeus binary for ${platformTag}: ${err.message}\n` +
|
|
139
|
+
`Try reinstalling:\n ${reinstallHint()}`,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
await ensureBinary();
|
|
145
|
+
|
|
146
|
+
// Use an asynchronous spawn (not spawnSync) so Node can respond to signals
|
|
147
|
+
// (e.g. Ctrl-C / SIGINT) while the native binary runs, forward them to the
|
|
148
|
+
// child, and mirror the child's termination reason in the parent.
|
|
149
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
150
|
+
stdio: "inherit",
|
|
151
|
+
env: process.env,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
child.on("error", (err) => {
|
|
155
|
+
// eslint-disable-next-line no-console
|
|
156
|
+
console.error(err);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const forwardSignal = (signal) => {
|
|
161
|
+
if (child.killed) return;
|
|
162
|
+
try {
|
|
163
|
+
child.kill(signal);
|
|
164
|
+
} catch {
|
|
165
|
+
/* ignore */
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
|
|
170
|
+
process.on(sig, () => forwardSignal(sig));
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const childResult = await new Promise((resolve) => {
|
|
174
|
+
child.on("exit", (code, signal) => {
|
|
175
|
+
if (signal) {
|
|
176
|
+
resolve({ type: "signal", signal });
|
|
177
|
+
} else {
|
|
178
|
+
resolve({ type: "code", exitCode: code ?? 1 });
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
if (childResult.type === "signal") {
|
|
184
|
+
// Re-emit the same signal so the parent terminates with 128 + n semantics.
|
|
185
|
+
process.kill(process.pid, childResult.signal);
|
|
186
|
+
} else {
|
|
187
|
+
process.exit(childResult.exitCode);
|
|
188
|
+
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@j3ssie/osmedeus",
|
|
3
|
-
"version": "5.1.0
|
|
4
|
-
"description": "Osmedeus - A Modern Orchestration Engine for Security
|
|
3
|
+
"version": "5.1.0",
|
|
4
|
+
"description": "Osmedeus - A Modern Orchestration Engine for Security",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"osmedeus",
|
|
7
|
+
"security",
|
|
8
|
+
"recon",
|
|
9
|
+
"reconnaissance",
|
|
10
|
+
"bug-bounty",
|
|
11
|
+
"pentest",
|
|
12
|
+
"workflow",
|
|
13
|
+
"automation",
|
|
14
|
+
"orchestration"
|
|
15
|
+
],
|
|
5
16
|
"license": "MIT",
|
|
6
17
|
"homepage": "https://www.osmedeus.org",
|
|
7
18
|
"repository": {
|
|
8
19
|
"type": "git",
|
|
9
20
|
"url": "git+https://github.com/j3ssie/osmedeus.git"
|
|
10
21
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"x64"
|
|
16
|
-
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"bin": {
|
|
24
|
+
"osmedeus": "bin/osmedeus.js"
|
|
25
|
+
},
|
|
17
26
|
"engines": {
|
|
18
27
|
"node": ">=16"
|
|
19
28
|
},
|
|
20
29
|
"files": [
|
|
21
|
-
"
|
|
22
|
-
]
|
|
30
|
+
"bin"
|
|
31
|
+
],
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"@j3ssie/osmedeus-linux-x64": "npm:@j3ssie/osmedeus@5.1.0-linux-x64",
|
|
34
|
+
"@j3ssie/osmedeus-linux-arm64": "npm:@j3ssie/osmedeus@5.1.0-linux-arm64",
|
|
35
|
+
"@j3ssie/osmedeus-darwin-x64": "npm:@j3ssie/osmedeus@5.1.0-darwin-x64",
|
|
36
|
+
"@j3ssie/osmedeus-darwin-arm64": "npm:@j3ssie/osmedeus@5.1.0-darwin-arm64"
|
|
37
|
+
}
|
|
23
38
|
}
|
|
Binary file
|