@infosupport/huddle-cli 0.0.0-experiment-160.127.1 → 0.0.0-experiment-160.129.1
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/dist/pipe/sbx-kit.js +2 -1
- package/dist/runtime.js +38 -19
- package/package.json +1 -1
package/dist/pipe/sbx-kit.js
CHANGED
|
@@ -42,8 +42,9 @@ setup:
|
|
|
42
42
|
install:
|
|
43
43
|
- command: "sh ${IN_BOX}/install.sh"
|
|
44
44
|
user: "0"
|
|
45
|
+
# startup takes the command as argv, install as one string (sbx's schema).
|
|
45
46
|
startup:
|
|
46
|
-
- command: "sh ${IN_BOX}/jbr-watch.sh"
|
|
47
|
+
- command: ["sh", "${IN_BOX}/jbr-watch.sh"]
|
|
47
48
|
`;
|
|
48
49
|
const INSTALL = `#!/bin/sh
|
|
49
50
|
# Generated by Huddle. Runs as root when the sandbox is created.
|
package/dist/runtime.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseDockerContextSocket = parseDockerContextSocket;
|
|
4
4
|
exports.isRancherDesktopSocket = isRancherDesktopSocket;
|
|
5
|
+
exports.dockerMountSocket = dockerMountSocket;
|
|
5
6
|
exports.parseRuntimeName = parseRuntimeName;
|
|
6
7
|
exports.resolveRuntime = resolveRuntime;
|
|
7
8
|
const child_process_1 = require("child_process");
|
|
@@ -41,9 +42,6 @@ function podmanSocketPath() {
|
|
|
41
42
|
}
|
|
42
43
|
return '/run/podman/podman.sock';
|
|
43
44
|
}
|
|
44
|
-
function dockerSocketPath() {
|
|
45
|
-
return process.platform === 'win32' ? '//var/run/docker.sock' : '/var/run/docker.sock';
|
|
46
|
-
}
|
|
47
45
|
/**
|
|
48
46
|
* Extracts the unix socket path from the JSON of `docker context inspect`. The
|
|
49
47
|
* active context determines which engine the `docker` command talks to; Rancher
|
|
@@ -51,6 +49,11 @@ function dockerSocketPath() {
|
|
|
51
49
|
* `Endpoints.docker.Host` points to `unix:///<home>/.rd/docker.sock` instead of
|
|
52
50
|
* the default `/var/run/docker.sock`.
|
|
53
51
|
*
|
|
52
|
+
* The result is only used to DETECT the engine (see buildRuntime), never as a
|
|
53
|
+
* bind-mount source: a context socket is the path the CLI uses to reach the
|
|
54
|
+
* daemon, which for VM-based engines is a host-side forwarder that the daemon
|
|
55
|
+
* itself cannot mount.
|
|
56
|
+
*
|
|
54
57
|
* Pure function so we can test the parsing in isolation. Returns `null` for
|
|
55
58
|
* non-parsable input or a non-unix endpoint (npipe:// on Windows,
|
|
56
59
|
* tcp:// / ssh:// remote), because those cannot be bind-mounted as a file path.
|
|
@@ -72,10 +75,10 @@ function parseDockerContextSocket(json) {
|
|
|
72
75
|
const path = host.slice('unix://'.length);
|
|
73
76
|
if (!path.startsWith('/'))
|
|
74
77
|
return null;
|
|
75
|
-
// The
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
78
|
+
// The `Host` from `docker context inspect` is attacker-influenceable (whoever
|
|
79
|
+
// can create/activate a docker context controls the value). The path is only
|
|
80
|
+
// used for detection now, but keep it as defense in depth should it ever reach
|
|
81
|
+
// a shell command again: restrict it to characters that occur in a real
|
|
79
82
|
// socket path: allow spaces (legal in e.g. macOS `/Users/First Last/.rd/...`)
|
|
80
83
|
// but never the metacharacters that stay dangerous inside double quotes
|
|
81
84
|
// ($, backtick, ", \) or the command separators (;, |, &, (), newline).
|
|
@@ -94,6 +97,28 @@ function dockerContextSocket() {
|
|
|
94
97
|
return undefined;
|
|
95
98
|
return parseDockerContextSocket(json) ?? undefined;
|
|
96
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Determines the docker socket to bind-mount (as seen by the engine) and
|
|
102
|
+
* whether the engine runs in a VM, given the active context's socket.
|
|
103
|
+
*
|
|
104
|
+
* Rancher Desktop (dockerd/moby mode) looks like an ordinary Docker engine, but
|
|
105
|
+
* its context points to `~/.rd/docker.sock`. That is a host-side forwarder into
|
|
106
|
+
* the Lima VM that only the CLI can use: bind-mount sources are resolved by
|
|
107
|
+
* dockerd INSIDE the VM, where that file is not a usable socket (dockerd then
|
|
108
|
+
* tries to mkdir it: "operation not supported"). Inside the VM dockerd listens
|
|
109
|
+
* on the standard /var/run/docker.sock, so we always mount that — the same
|
|
110
|
+
* engine-side reasoning as for /tmp/dc-sockets in init.ts.
|
|
111
|
+
*
|
|
112
|
+
* Pure function so we can test it without a daemon.
|
|
113
|
+
*/
|
|
114
|
+
function dockerMountSocket(contextSocket, platform) {
|
|
115
|
+
return {
|
|
116
|
+
socketPath: platform === 'win32' ? '//var/run/docker.sock' : '/var/run/docker.sock',
|
|
117
|
+
// Docker Desktop (macOS/Windows) and Rancher Desktop (every OS, Lima/WSL)
|
|
118
|
+
// run in a VM; native Docker on Linux does not.
|
|
119
|
+
isRemote: isRancherDesktopSocket(contextSocket) || platform !== 'linux',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
97
122
|
function podmanIsRemote() {
|
|
98
123
|
// On macOS/Windows Podman always runs in a `podman machine` VM; on Linux too
|
|
99
124
|
// the client can point at a remote socket. `ServiceIsRemote` is the
|
|
@@ -110,21 +135,15 @@ function buildRuntime(name) {
|
|
|
110
135
|
securityOpts: ['label=disable'],
|
|
111
136
|
};
|
|
112
137
|
}
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
// Docker, Docker Desktop). Rancher Desktop runs the engine in a VM (Lima/WSL)
|
|
118
|
-
// on EVERY platform, so it is always 'remote'.
|
|
119
|
-
const contextSocket = dockerContextSocket();
|
|
120
|
-
const isRancher = isRancherDesktopSocket(contextSocket);
|
|
138
|
+
// The active docker context only tells us WHICH engine this is (Rancher
|
|
139
|
+
// Desktop or not); the mount source is always the engine-side socket. See
|
|
140
|
+
// dockerMountSocket().
|
|
141
|
+
const { socketPath, isRemote } = dockerMountSocket(dockerContextSocket(), process.platform);
|
|
121
142
|
return {
|
|
122
143
|
name,
|
|
123
|
-
socketPath
|
|
144
|
+
socketPath,
|
|
124
145
|
defaultNetwork: 'bridge',
|
|
125
|
-
|
|
126
|
-
// Docker on Linux does not.
|
|
127
|
-
isRemote: isRancher || process.platform !== 'linux',
|
|
146
|
+
isRemote,
|
|
128
147
|
securityOpts: [],
|
|
129
148
|
};
|
|
130
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infosupport/huddle-cli",
|
|
3
|
-
"version": "0.0.0-experiment-160.
|
|
3
|
+
"version": "0.0.0-experiment-160.129.1",
|
|
4
4
|
"description": "Huddle CLI — start devcontainers and manage firewall rules",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"author": "Info Support B.V.",
|