@infosupport/huddle-cli 0.0.0-experiment-160.157.1 → 0.0.0-experiment-160.159.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/fbk-spec.js +36 -0
- package/dist/pipe/serve.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// `fbk.spec`: the `.firebrick.yml` of one project folder, for the gateway to see
|
|
3
|
+
// a Firebrick sandbox's network rules before it starts it (docs/host-pipe.md,
|
|
4
|
+
// "fbk egress"). Only that one file, in a folder held to the same rules as
|
|
5
|
+
// tool.run's cwd (absolute, existing, links followed, never in ~/.huddle).
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MAX_SPEC_BYTES = void 0;
|
|
11
|
+
exports.fbkSpec = fbkSpec;
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const protocol_1 = require("./protocol");
|
|
15
|
+
const tools_1 = require("./tools");
|
|
16
|
+
const config_1 = require("../config");
|
|
17
|
+
/** The spec is a small hand-edited file; anything bigger is not one. */
|
|
18
|
+
exports.MAX_SPEC_BYTES = 64 * 1024;
|
|
19
|
+
const SPEC_FILE = '.firebrick.yml';
|
|
20
|
+
function fbkSpec(args, huddleHome = config_1.CONFIG_DIR) {
|
|
21
|
+
const dir = (0, tools_1.checkToolCwd)(args.cwd, huddleHome);
|
|
22
|
+
const file = path_1.default.join(dir, SPEC_FILE);
|
|
23
|
+
let st;
|
|
24
|
+
try {
|
|
25
|
+
st = fs_1.default.lstatSync(file);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return { text: null };
|
|
29
|
+
}
|
|
30
|
+
// The file itself, not a link to somewhere else on the host.
|
|
31
|
+
if (!st.isFile())
|
|
32
|
+
throw new protocol_1.PipeError('bad_request', `${SPEC_FILE} is not a regular file`);
|
|
33
|
+
if (st.size > exports.MAX_SPEC_BYTES)
|
|
34
|
+
throw new protocol_1.PipeError('bad_request', `${SPEC_FILE} is larger than ${exports.MAX_SPEC_BYTES} bytes`);
|
|
35
|
+
return { text: fs_1.default.readFileSync(file, 'utf8') };
|
|
36
|
+
}
|
package/dist/pipe/serve.js
CHANGED
|
@@ -20,6 +20,7 @@ const protocol_1 = require("./protocol");
|
|
|
20
20
|
const fs_list_1 = require("./fs-list");
|
|
21
21
|
const tools_1 = require("./tools");
|
|
22
22
|
const sbx_kit_1 = require("./sbx-kit");
|
|
23
|
+
const fbk_spec_1 = require("./fbk-spec");
|
|
23
24
|
const sbx_links_1 = require("./sbx-links");
|
|
24
25
|
const ssh_hosts_1 = require("./ssh-hosts");
|
|
25
26
|
// Ids are generated by the gateway (32 hex); anything that does not look like
|
|
@@ -46,6 +47,8 @@ async function dispatch(req, maxEntries) {
|
|
|
46
47
|
return (0, sbx_links_1.sbxLinks)(args);
|
|
47
48
|
case 'sbx.kit':
|
|
48
49
|
return (0, sbx_kit_1.sbxKit)(args);
|
|
50
|
+
case 'fbk.spec':
|
|
51
|
+
return (0, fbk_spec_1.fbkSpec)(args);
|
|
49
52
|
case 'ssh.key':
|
|
50
53
|
return (0, ssh_hosts_1.sshKey)(args);
|
|
51
54
|
case 'ssh.host':
|
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.159.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.",
|