herozion 1.0.71

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 ADDED
@@ -0,0 +1,20 @@
1
+ # Herozion — npm package
2
+
3
+ Binary wrapper for the [Herozion](https://herozion.io) CLI security scanner.
4
+
5
+ ## Usage without global install (recommended)
6
+
7
+ ```bash
8
+ # Run directly with npx — no install, no PATH modification
9
+ npx herozion scan .
10
+
11
+ # Or as a project dev-dependency
12
+ npm install herozion --save-dev
13
+ npx herozion scan .
14
+ ```
15
+
16
+ The binary is stored inside `node_modules/herozion/bin/` — it never touches your system PATH.
17
+
18
+ ## Full documentation
19
+
20
+ See [github.com/Herozion/scanner](https://github.com/Herozion/scanner#readme)
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Herozion bin shim.
4
+ *
5
+ * Locates the pre-built binary downloaded by install.js and spawns it,
6
+ * forwarding all arguments and environment variables.
7
+ *
8
+ * The binary lives in node_modules/herozion/bin/ — never in the system PATH.
9
+ * This means `npx herozion scan .` or running from a project dev-dependency
10
+ * gives herozion access ONLY to what you pass as arguments.
11
+ */
12
+
13
+ "use strict";
14
+
15
+ const { spawnSync } = require("child_process");
16
+ const path = require("path");
17
+ const fs = require("fs");
18
+
19
+ const isWindows = process.platform === "win32";
20
+ const binaryName = isWindows ? "herozion.exe" : "herozion";
21
+ const binaryPath = path.join(__dirname, binaryName);
22
+
23
+ if (!fs.existsSync(binaryPath)) {
24
+ console.error(
25
+ "herozion: binary not found. The postinstall download may have failed.\n" +
26
+ "Try reinstalling: npm install herozion\n" +
27
+ "Or download manually from: https://github.com/Herozion/scanner-releases/releases/latest"
28
+ );
29
+ process.exit(1);
30
+ }
31
+
32
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
33
+ stdio: "inherit",
34
+ env: process.env,
35
+ // Shell is false: the binary is exec'd directly, no shell expansion
36
+ shell: false,
37
+ });
38
+
39
+ process.exit(result.status ?? 1);
package/install.js ADDED
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Herozion postinstall script.
4
+ *
5
+ * Downloads the correct pre-built binary from GitHub Releases and saves it
6
+ * inside this package's directory so that the `herozion` bin shim can exec it.
7
+ *
8
+ * The binary is NEVER placed in the system PATH — it lives in node_modules/
9
+ * alongside this package. Running `npx herozion scan .` or adding herozion
10
+ * as a dev-dependency keeps the scope limited to the project.
11
+ *
12
+ * Supported platforms:
13
+ * Windows x64 → herozion-windows-amd64.exe
14
+ * Linux x64 → herozion-linux-amd64
15
+ * macOS arm64 → herozion-macos-arm64
16
+ * macOS x64 → herozion-macos-amd64
17
+ */
18
+
19
+ "use strict";
20
+
21
+ const https = require("https");
22
+ const fs = require("fs");
23
+ const path = require("path");
24
+ const { execSync } = require("child_process");
25
+
26
+ const VERSION = require("./package.json").version;
27
+ const BASE_URL =
28
+ `https://github.com/Herozion/scanner-releases/releases/download/v${VERSION}`;
29
+
30
+ // ── Platform detection ────────────────────────────────────────────────────────
31
+
32
+ function getBinaryName() {
33
+ const { platform, arch } = process;
34
+
35
+ if (platform === "win32" && arch === "x64") return "herozion-windows-amd64.exe";
36
+ if (platform === "linux" && (arch === "x64" || arch === "ia32")) return "herozion-linux-amd64";
37
+ if (platform === "darwin" && arch === "arm64") return "herozion-macos-arm64";
38
+ if (platform === "darwin" && (arch === "x64" || arch === "ia32")) return "herozion-macos-amd64";
39
+
40
+ throw new Error(
41
+ `Herozion: unsupported platform ${platform}/${arch}.\n` +
42
+ "Please open an issue at https://github.com/Herozion/scanner/issues"
43
+ );
44
+ }
45
+
46
+ // ── Download helper ───────────────────────────────────────────────────────────
47
+
48
+ function download(url, destPath, redirectCount = 0) {
49
+ return new Promise((resolve, reject) => {
50
+ if (redirectCount > 5) {
51
+ return reject(new Error("Too many redirects"));
52
+ }
53
+ https.get(url, { headers: { "User-Agent": "herozion-npm-installer" } }, (res) => {
54
+ if (res.statusCode === 301 || res.statusCode === 302) {
55
+ return resolve(download(res.headers.location, destPath, redirectCount + 1));
56
+ }
57
+ if (res.statusCode !== 200) {
58
+ return reject(new Error(`HTTP ${res.statusCode} — failed to download ${url}`));
59
+ }
60
+
61
+ const file = fs.createWriteStream(destPath);
62
+ res.pipe(file);
63
+ file.on("finish", () => file.close(resolve));
64
+ file.on("error", (err) => {
65
+ fs.unlink(destPath, () => {});
66
+ reject(err);
67
+ });
68
+ }).on("error", reject);
69
+ });
70
+ }
71
+
72
+ // ── Main ──────────────────────────────────────────────────────────────────────
73
+
74
+ async function main() {
75
+ const binaryName = getBinaryName();
76
+ const url = `${BASE_URL}/${binaryName}`;
77
+
78
+ // Store the binary inside this package directory (node_modules/herozion/)
79
+ const binDir = path.join(__dirname, "bin");
80
+ fs.mkdirSync(binDir, { recursive: true });
81
+
82
+ const isWindows = process.platform === "win32";
83
+ const destName = isWindows ? "herozion.exe" : "herozion";
84
+ const destPath = path.join(binDir, destName);
85
+
86
+ // Skip download if binary already exists and matches version
87
+ const markerPath = path.join(binDir, `.version-${VERSION}`);
88
+ if (fs.existsSync(destPath) && fs.existsSync(markerPath)) {
89
+ console.log(`herozion: binary v${VERSION} already present, skipping download.`);
90
+ return;
91
+ }
92
+
93
+ console.log(`herozion: downloading ${binaryName} v${VERSION}...`);
94
+ try {
95
+ await download(url, destPath);
96
+ if (!isWindows) {
97
+ fs.chmodSync(destPath, 0o755);
98
+ }
99
+ // Write version marker so we don't re-download on repeated installs
100
+ fs.writeFileSync(markerPath, VERSION, "utf8");
101
+ console.log(`herozion: binary installed successfully.`);
102
+ } catch (err) {
103
+ // Non-fatal: warn and continue — the bin shim will give a clear error at runtime
104
+ console.warn(`herozion: WARNING — could not download binary: ${err.message}`);
105
+ console.warn("You can download it manually from:");
106
+ console.warn(` ${url}`);
107
+ }
108
+ }
109
+
110
+ main().catch((err) => {
111
+ console.error("herozion install error:", err.message);
112
+ // Do not exit(1) — a failed postinstall breaks `npm install` entirely
113
+ });
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "herozion",
3
+ "version": "1.0.71",
4
+ "description": "Security audit and performance analysis CLI tool for developers",
5
+ "keywords": ["security", "audit", "vulnerability", "cli", "owasp"],
6
+ "homepage": "https://herozion.io",
7
+ "bugs": {
8
+ "url": "https://github.com/Herozion/scanner/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Herozion/scanner.git"
13
+ },
14
+ "license": "SEE LICENSE IN LICENSE",
15
+ "bin": {
16
+ "herozion": "bin/herozion.js"
17
+ },
18
+ "files": [
19
+ "bin/herozion.js",
20
+ "install.js",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "postinstall": "node install.js"
25
+ },
26
+ "engines": {
27
+ "node": ">=16.0.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "os": ["darwin", "linux", "win32"],
33
+ "cpu": ["x64", "arm64"]
34
+ }