@jeancodogno/specforce-kit 0.2.0 → 0.2.2
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/index.js +13 -7
- package/package.json +7 -9
package/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
2
|
const { spawnSync } = require('child_process');
|
|
4
3
|
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* SpecForce Kit Proxy
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
|
+
* SECURITY NOTE: This proxy uses 'child_process.spawnSync' to execute native binaries.
|
|
10
|
+
* To prevent shell injection, we NEVER use 'shell: true' and always pass arguments
|
|
11
|
+
* as an explicit array. All paths are validated to be absolute before execution.
|
|
9
12
|
*/
|
|
10
13
|
|
|
11
14
|
const platform = process.platform;
|
|
@@ -19,15 +22,14 @@ try {
|
|
|
19
22
|
const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
|
|
20
23
|
const pkgDir = path.dirname(pkgJsonPath);
|
|
21
24
|
const pkgJson = require(pkgJsonPath);
|
|
22
|
-
|
|
25
|
+
|
|
23
26
|
// 2. Extract binary path from package.json bin field
|
|
24
27
|
const binRelativePath = typeof pkgJson.bin === 'string' ? pkgJson.bin : pkgJson.bin.specforce;
|
|
25
28
|
binaryPath = path.resolve(pkgDir, binRelativePath);
|
|
26
29
|
} catch (e) {
|
|
27
|
-
// Fallback 1: Look for a binary in the root (built via 'make build'
|
|
30
|
+
// Fallback 1: Look for a binary in the root (built via 'make build')
|
|
28
31
|
const localBinaryName = platform === 'win32' ? 'specforce.exe' : 'specforce';
|
|
29
32
|
const rootBinaryPath = path.join(__dirname, localBinaryName);
|
|
30
|
-
const fs = require('fs');
|
|
31
33
|
|
|
32
34
|
if (fs.existsSync(rootBinaryPath)) {
|
|
33
35
|
binaryPath = rootBinaryPath;
|
|
@@ -45,12 +47,16 @@ try {
|
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
// Security Hardening: Ensure binaryPath is absolute and exists before execution
|
|
51
|
+
if (!binaryPath || !path.isAbsolute(binaryPath) || !fs.existsSync(binaryPath)) {
|
|
52
|
+
runDiagnostic(platform, arch, pkgName);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
/**
|
|
49
57
|
* Runs a diagnostic check to help the user fix their environment.
|
|
50
58
|
*/
|
|
51
59
|
function runDiagnostic(platform, arch, pkgName) {
|
|
52
|
-
const fs = require('fs');
|
|
53
|
-
|
|
54
60
|
// Aesthetic Colors
|
|
55
61
|
const RESET = "\x1b[0m";
|
|
56
62
|
const BOLD = "\x1b[1m";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeancodogno/specforce-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "SpecForce Kit CLI - Distributed via Native Binaries",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,20 +15,18 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "make build",
|
|
18
|
-
"test": "go test ./..."
|
|
19
|
-
"prepare": "make build || true",
|
|
20
|
-
"postinstall": "make build || true"
|
|
18
|
+
"test": "go test ./..."
|
|
21
19
|
},
|
|
22
20
|
"files": [
|
|
23
21
|
"index.js",
|
|
24
22
|
"LICENSE"
|
|
25
23
|
],
|
|
26
24
|
"optionalDependencies": {
|
|
27
|
-
"@jeancodogno/specforce-kit-linux-x64": "0.2.
|
|
28
|
-
"@jeancodogno/specforce-kit-linux-arm64": "0.2.
|
|
29
|
-
"@jeancodogno/specforce-kit-darwin-x64": "0.2.
|
|
30
|
-
"@jeancodogno/specforce-kit-darwin-arm64": "0.2.
|
|
31
|
-
"@jeancodogno/specforce-kit-win32-x64": "0.2.
|
|
25
|
+
"@jeancodogno/specforce-kit-linux-x64": "0.2.2",
|
|
26
|
+
"@jeancodogno/specforce-kit-linux-arm64": "0.2.2",
|
|
27
|
+
"@jeancodogno/specforce-kit-darwin-x64": "0.2.2",
|
|
28
|
+
"@jeancodogno/specforce-kit-darwin-arm64": "0.2.2",
|
|
29
|
+
"@jeancodogno/specforce-kit-win32-x64": "0.2.2"
|
|
32
30
|
},
|
|
33
31
|
"author": "Jean Codogno <jeancarlo.eng.comp@gmail.com>",
|
|
34
32
|
"license": "MIT"
|