crx-gate 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 crx-gate contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # crx-gate
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Static security analyzer and permission linter for Chrome extensions. Statically inspects unpacked extension directories, `.zip` bundles, or `.crx` binaries in under 3ms.
4
+
5
+ [![GitHub](https://img.shields.io/badge/GitHub-jaw0r3k%2Fcrx--gate-blue?logo=github)](https://github.com/jaw0r3k/crx-gate)
6
+ [![License: MIT OR Apache-2.0](https://img.shields.io/badge/License-MIT%20OR%20Apache--2.0-blue.svg)](https://github.com/jaw0r3k/crx-gate/blob/master/LICENSE)
7
+
8
+ ---
9
+
10
+ ## Instant usage via `npx`
11
+
12
+ No installation required:
13
+
14
+ ```bash
15
+ # Audit an extension directory
16
+ npx crx-gate audit ./dist
17
+
18
+ # Generate standalone interactive HTML report
19
+ npx crx-gate audit ./dist --format html --output report.html
20
+
21
+ # Audit a packed .crx binary archive
22
+ npx crx-gate audit ./extension.crx
23
+
24
+ # Diff two versions to prevent permission creep
25
+ npx crx-gate diff ./v1.0.0 ./v1.1.0 --fail-on-degradation
26
+
27
+ # Export SARIF for GitHub Code Scanning
28
+ npx crx-gate audit ./dist --format sarif --output crx-gate.sarif
29
+
30
+ # List all built-in rules
31
+ npx crx-gate rules
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Documentation
37
+
38
+ Full documentation, GitHub Actions setup, and pre-commit hook integrations:
39
+ [https://github.com/jaw0r3k/crx-gate](https://github.com/jaw0r3k/crx-gate)
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const os = require("os");
7
+ const https = require("https");
8
+
9
+ const VERSION = "0.2.0";
10
+ const REPO = "jaw0r3k/crx-gate";
11
+
12
+ function getBinaryName() {
13
+ const platform = os.platform();
14
+ const arch = os.arch();
15
+
16
+ let targetArch = arch === "x64" ? "x86_64" : arch === "arm64" ? "aarch64" : null;
17
+ if (!targetArch) {
18
+ console.error(`crx-gate error: Unsupported CPU architecture '${arch}'.`);
19
+ process.exit(1);
20
+ }
21
+
22
+ if (platform === "linux") {
23
+ return {
24
+ artifact: `crx-gate-${targetArch}-unknown-linux-gnu.tar.gz`,
25
+ binaryName: "crx-gate",
26
+ isZip: false,
27
+ };
28
+ } else if (platform === "darwin") {
29
+ return {
30
+ artifact: `crx-gate-${targetArch}-apple-darwin.tar.gz`,
31
+ binaryName: "crx-gate",
32
+ isZip: false,
33
+ };
34
+ } else if (platform === "win32") {
35
+ return {
36
+ artifact: `crx-gate-x86_64-pc-windows-msvc.zip`,
37
+ binaryName: "crx-gate.exe",
38
+ isZip: true,
39
+ };
40
+ } else {
41
+ console.error(`crx-gate error: Unsupported OS '${platform}'.`);
42
+ process.exit(1);
43
+ }
44
+ }
45
+
46
+ function getLocalBinaryPath() {
47
+ // Check local release build first if developing locally
48
+ const localTarget = path.join(__dirname, "..", "..", "target", "release", process.platform === "win32" ? "crx-gate.exe" : "crx-gate");
49
+ if (fs.existsSync(localTarget)) {
50
+ return localTarget;
51
+ }
52
+
53
+ const { binaryName } = getBinaryName();
54
+ const cacheDir = path.join(os.homedir(), ".crx-gate", `v${VERSION}`);
55
+ return path.join(cacheDir, binaryName);
56
+ }
57
+
58
+ function runBinary(binPath, args) {
59
+ const result = spawnSync(binPath, args, { stdio: "inherit" });
60
+ if (result.error) {
61
+ console.error("Execution error:", result.error);
62
+ process.exit(1);
63
+ }
64
+ process.exit(result.status !== null ? result.status : 0);
65
+ }
66
+
67
+ function downloadBinary(url, dest, cb) {
68
+ https.get(url, (res) => {
69
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
70
+ downloadBinary(res.headers.location, dest, cb);
71
+ return;
72
+ }
73
+ if (res.statusCode !== 200) {
74
+ cb(new Error(`Failed to download binary: HTTP ${res.statusCode}`));
75
+ return;
76
+ }
77
+ const file = fs.createWriteStream(dest);
78
+ res.pipe(file);
79
+ file.on("finish", () => {
80
+ file.close(() => cb(null));
81
+ });
82
+ }).on("error", (err) => {
83
+ cb(err);
84
+ });
85
+ }
86
+
87
+ function main() {
88
+ const args = process.argv.slice(2);
89
+ const binPath = getLocalBinaryPath();
90
+
91
+ if (fs.existsSync(binPath)) {
92
+ runBinary(binPath, args);
93
+ return;
94
+ }
95
+
96
+ const { artifact, binaryName, isZip } = getBinaryName();
97
+ const cacheDir = path.join(os.homedir(), ".crx-gate", `v${VERSION}`);
98
+ fs.mkdirSync(cacheDir, { recursive: true });
99
+
100
+ const archivePath = path.join(cacheDir, artifact);
101
+ const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/${artifact}`;
102
+
103
+ console.log(`crx-gate: Fetching pre-compiled release binary (v${VERSION})...`);
104
+ downloadBinary(downloadUrl, archivePath, (err) => {
105
+ if (!err) {
106
+ try {
107
+ if (isZip) {
108
+ spawnSync("powershell", ["-Command", `Expand-Archive -Path '${archivePath}' -DestinationPath '${cacheDir}' -Force`]);
109
+ } else {
110
+ spawnSync("tar", ["-xzf", archivePath, "-C", cacheDir]);
111
+ }
112
+ if (fs.existsSync(binPath)) {
113
+ if (process.platform !== "win32") {
114
+ fs.chmodSync(binPath, 0o755);
115
+ }
116
+ try { fs.unlinkSync(archivePath); } catch (_) {}
117
+ runBinary(binPath, args);
118
+ return;
119
+ }
120
+ } catch (_) {}
121
+ }
122
+
123
+ // Fallback to cargo run if developing in repo
124
+ const cargoRun = spawnSync("cargo", ["run", "--release", "--quiet", "--", ...args], {
125
+ stdio: "inherit",
126
+ cwd: path.join(__dirname, "..", ".."),
127
+ });
128
+
129
+ if (cargoRun.status === 0) {
130
+ process.exit(0);
131
+ }
132
+
133
+ console.error(`crx-gate error: Could not run or download binary. Please install via cargo: 'cargo install crx-gate'`);
134
+ process.exit(1);
135
+ });
136
+ }
137
+
138
+ main();
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "crx-gate",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Zero-dependency pre-commit extension security, permission blast-radius auditing, and CWS rejection prediction",
5
+ "bin": {
6
+ "crx-gate": "bin/crx-gate.js"
7
+ },
8
+ "scripts": {
9
+ "test": "node bin/crx-gate.js --help"
10
+ },
11
+ "keywords": [
12
+ "chrome-extension",
13
+ "crx",
14
+ "security",
15
+ "audit",
16
+ "manifest-v3",
17
+ "blast-radius",
18
+ "sast",
19
+ "taint-analysis"
20
+ ],
21
+ "author": "crx-gate contributors",
22
+ "license": "MIT",
23
+ "homepage": "https://github.com/jaw0r3k/crx-gate#readme",
24
+ "bugs": {
25
+ "url": "https://github.com/jaw0r3k/crx-gate/issues"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/jaw0r3k/crx-gate.git"
30
+ },
31
+ "funding": {
32
+ "type": "individual",
33
+ "url": "https://github.com/jaw0r3k/crx-gate"
34
+ },
35
+ "files": [
36
+ "bin",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "engines": {
41
+ "node": ">=16.0.0"
42
+ }
43
+ }