@dreamlake/dreamlake-cli 0.15.0 → 0.16.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/dreamlake.js +52 -2
- package/package.json +9 -9
package/bin/dreamlake.js
CHANGED
|
@@ -29,13 +29,63 @@ try {
|
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// Only explicitly selected enrollment password descriptors cross this spawn.
|
|
33
|
+
// Never enumerate inherited descriptors; gaps are closed in the native child.
|
|
34
|
+
function passwordStdio(args) {
|
|
35
|
+
const stdio = ['inherit', 'inherit', 'inherit'];
|
|
36
|
+
let offset = 0;
|
|
37
|
+
while (args[offset] === '-p' || args[offset] === '--prefix' || args[offset]?.startsWith('--prefix=')) offset += args[offset].includes('=') ? 1 : 2;
|
|
38
|
+
if (args[offset] !== 'hosts' || args[offset + 1] !== 'enroll') return stdio;
|
|
39
|
+
const rest = args.slice(offset + 2);
|
|
40
|
+
if (rest.some(arg => ['--dry-run','--help','-h','--no-save-credentials'].includes(arg))) return stdio;
|
|
41
|
+
const selected = new Set(), descriptors = new Map();
|
|
42
|
+
const values = new Set(['-n','--name','-p','--prefix','--ssh','--config','--wait-seconds','--request-id','--lakeshore-id','--nymph-version','--target-key','--jump-key']);
|
|
43
|
+
const validName = name => typeof name === 'string' && name.length <= 512 && /^[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*$/.test(name);
|
|
44
|
+
for (let i = 0; i < rest.length; i++) {
|
|
45
|
+
if (rest[i] === '--') break;
|
|
46
|
+
const equal = rest[i].indexOf('=');
|
|
47
|
+
const flag = equal < 0 ? rest[i] : rest[i].slice(0, equal);
|
|
48
|
+
if (!['--target-password','--jump-password','--password-fd'].includes(flag)) {
|
|
49
|
+
if (values.has(flag) && equal < 0) i++;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const value = equal < 0 ? rest[++i] : rest[i].slice(equal + 1);
|
|
53
|
+
if (typeof value !== 'string') throw Error();
|
|
54
|
+
if (flag === '--password-fd') {
|
|
55
|
+
const match = /^(.+)=([0-9]+)$/.exec(value);
|
|
56
|
+
if (!match || !validName(match[1]) || descriptors.has(match[1])) throw Error();
|
|
57
|
+
const fd = Number(match[2]);
|
|
58
|
+
if (!Number.isSafeInteger(fd) || fd < 0 || fd > 1024) throw Error();
|
|
59
|
+
descriptors.set(match[1], fd);
|
|
60
|
+
} else {
|
|
61
|
+
const at = value.indexOf('=');
|
|
62
|
+
const name = flag === '--target-password' ? value : at > 0 ? value.slice(at + 1) : '';
|
|
63
|
+
if (!validName(name) || selected.has(name) || flag === '--jump-password' && !/^[A-Za-z0-9_.@:\[\]-]{1,255}$/.test(value.slice(0,at))) throw Error();
|
|
64
|
+
selected.add(name);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (selected.size > 32) throw Error();
|
|
68
|
+
const { fstatSync } = require('node:fs');
|
|
69
|
+
for (const [name, fd] of descriptors) {
|
|
70
|
+
if (!selected.has(name) || process.platform === 'win32') throw Error();
|
|
71
|
+
const info = fstatSync(fd);
|
|
72
|
+
if (!info.isFIFO() && !(info.isFile() && !(info.mode & 0o077) && info.uid === process.getuid())) throw Error();
|
|
73
|
+
while (stdio.length <= fd) stdio.push('ignore');
|
|
74
|
+
if (fd > 2) stdio[fd] = fd;
|
|
75
|
+
}
|
|
76
|
+
return stdio;
|
|
77
|
+
}
|
|
78
|
+
let stdio;
|
|
79
|
+
try { stdio = passwordStdio(process.argv.slice(2)); }
|
|
80
|
+
catch { process.stderr.write('dreamlake: invalid selected password descriptor configuration\n'); process.exit(1); }
|
|
81
|
+
|
|
82
|
+
let r = spawnSync(binPath, process.argv.slice(2), { stdio });
|
|
33
83
|
if (r.error && r.error.code === "EACCES") {
|
|
34
84
|
// Belt and braces: if a tarball ever ships the binary without the exec
|
|
35
85
|
// bit again, repair it once and retry rather than stranding the user.
|
|
36
86
|
try {
|
|
37
87
|
require("node:fs").chmodSync(binPath, 0o755);
|
|
38
|
-
r = spawnSync(binPath, process.argv.slice(2), { stdio
|
|
88
|
+
r = spawnSync(binPath, process.argv.slice(2), { stdio });
|
|
39
89
|
} catch {}
|
|
40
90
|
}
|
|
41
91
|
if (r.error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dreamlake-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"node": ">=18"
|
|
18
18
|
},
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@dreamlake/dreamlake-cli-darwin-arm64": "0.
|
|
21
|
-
"@dreamlake/dreamlake-cli-darwin-x64": "0.
|
|
22
|
-
"@dreamlake/dreamlake-cli-linux-x64": "0.
|
|
23
|
-
"@dreamlake/dreamlake-cli-linux-arm64": "0.
|
|
24
|
-
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.
|
|
25
|
-
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.
|
|
26
|
-
"@dreamlake/dreamlake-cli-win32-x64": "0.
|
|
27
|
-
"@dreamlake/dreamlake-cli-win32-arm64": "0.
|
|
20
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.16.0",
|
|
21
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.16.0",
|
|
22
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.16.0",
|
|
23
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.16.0",
|
|
24
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.16.0",
|
|
25
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.16.0",
|
|
26
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.16.0",
|
|
27
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.16.0"
|
|
28
28
|
}
|
|
29
29
|
}
|