@hsuite/smart-engines-cli 1.6.0 → 1.8.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/README.md +59 -9
- package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts +18 -0
- package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts.map +1 -0
- package/dist/__tests__/helpers/fixtures-image-hygiene.js +42 -0
- package/dist/__tests__/helpers/fixtures-image-hygiene.js.map +1 -0
- package/dist/_lib/baas.d.ts +12 -17
- package/dist/_lib/baas.d.ts.map +1 -1
- package/dist/_lib/baas.js +13 -1
- package/dist/_lib/baas.js.map +1 -1
- package/dist/_lib/cluster-convergence.d.ts +8 -0
- package/dist/_lib/cluster-convergence.d.ts.map +1 -1
- package/dist/_lib/cluster-convergence.js +2 -0
- package/dist/_lib/cluster-convergence.js.map +1 -1
- package/dist/_lib/cluster.d.ts +16 -10
- package/dist/_lib/cluster.d.ts.map +1 -1
- package/dist/_lib/cluster.js +23 -4
- package/dist/_lib/cluster.js.map +1 -1
- package/dist/_lib/framework.js +2 -2
- package/dist/_lib/image-hygiene.d.ts +36 -0
- package/dist/_lib/image-hygiene.d.ts.map +1 -0
- package/dist/_lib/image-hygiene.js +233 -0
- package/dist/_lib/image-hygiene.js.map +1 -0
- package/dist/_lib/run-fn.d.ts +34 -0
- package/dist/_lib/run-fn.d.ts.map +1 -0
- package/dist/_lib/run-fn.js +15 -0
- package/dist/_lib/run-fn.js.map +1 -0
- package/dist/_lib/subscription-client.d.ts +20 -0
- package/dist/_lib/subscription-client.d.ts.map +1 -1
- package/dist/_lib/subscription-client.js +23 -1
- package/dist/_lib/subscription-client.js.map +1 -1
- package/dist/_lib/transport.d.ts +62 -0
- package/dist/_lib/transport.d.ts.map +1 -0
- package/dist/_lib/transport.js +120 -0
- package/dist/_lib/transport.js.map +1 -0
- package/dist/commands/customer-scope.d.ts +48 -0
- package/dist/commands/customer-scope.d.ts.map +1 -0
- package/dist/commands/customer-scope.js +89 -0
- package/dist/commands/customer-scope.js.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +3 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/governance.d.ts.map +1 -1
- package/dist/commands/governance.js +13 -2
- package/dist/commands/governance.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +37 -7
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/personhood.d.ts.map +1 -1
- package/dist/commands/personhood.js +9 -4
- package/dist/commands/personhood.js.map +1 -1
- package/dist/commands/redeploy.d.ts.map +1 -1
- package/dist/commands/redeploy.js +3 -2
- package/dist/commands/redeploy.js.map +1 -1
- package/dist/commands/status.d.ts +45 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +149 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/transactions.d.ts.map +1 -1
- package/dist/commands/transactions.js +2 -1
- package/dist/commands/transactions.js.map +1 -1
- package/dist/commands/verify.d.ts +4 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +37 -22
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageHygieneError = exports.IMAGE_HYGIENE_FORBIDDEN_SUFFIXES = exports.IMAGE_HYGIENE_SCAN_DIRS = void 0;
|
|
4
|
+
exports.listTarEntries = listTarEntries;
|
|
5
|
+
exports.findImageHygieneViolations = findImageHygieneViolations;
|
|
6
|
+
exports.assertImageHygiene = assertImageHygiene;
|
|
7
|
+
/**
|
|
8
|
+
* `hsuite deploy` image-hygiene gate — HSUITEPT-5 (#3245).
|
|
9
|
+
*
|
|
10
|
+
* The pentest pulled a customer image whose compiled output shipped 98
|
|
11
|
+
* `.js.map`, 49 `.d.ts` and JSDoc-preserved `.js` files: the backend read like
|
|
12
|
+
* source, handing an attacker every guard condition and fallback path before
|
|
13
|
+
* touching the live app. The registry side (tenant Harbor projects served to
|
|
14
|
+
* anonymous pullers) is closed in the provisioner; this closes the image side
|
|
15
|
+
* at the one choke point the platform owns for a customer build — the CLI,
|
|
16
|
+
* right after `docker build` and BEFORE anything is tagged, logged in, or
|
|
17
|
+
* pushed. App-side tsconfig/Dockerfile hygiene is never relied on.
|
|
18
|
+
*
|
|
19
|
+
* Mechanism (no shell inside the image — a distroless runtime has none):
|
|
20
|
+
* docker inspect -f '{{.Config.WorkingDir}}' <image> → where the app lives
|
|
21
|
+
* docker create <image> → throwaway container
|
|
22
|
+
* docker cp <id>:<workdir>/<dir> - → tar of each compiled
|
|
23
|
+
* output dir (dist/…)
|
|
24
|
+
* docker rm -f <id> → always, even on throw
|
|
25
|
+
* The tar is parsed for ENTRY NAMES only; contents are never inspected. Only
|
|
26
|
+
* the conventional compiled-output dirs are scanned, so `node_modules/` (whose
|
|
27
|
+
* published packages legitimately ship `.d.ts` / `.map`) is never a false hit.
|
|
28
|
+
*
|
|
29
|
+
* Fail closed: any offending entry aborts the deploy with the full list and
|
|
30
|
+
* the fix. An absent output dir is "nothing to scan" (a warning when none of
|
|
31
|
+
* the conventional dirs exists at all — the gate could not see the app code).
|
|
32
|
+
* A `docker cp` that fails for any OTHER reason is also fatal — only docker's
|
|
33
|
+
* own not-found signature means "absent"; anything else is a scan that did not
|
|
34
|
+
* happen, and the gate must never report one it did not perform.
|
|
35
|
+
*/
|
|
36
|
+
const path_1 = require("path");
|
|
37
|
+
/** Compiled-output directories a smart-app image conventionally ships under its `WorkingDir`. */
|
|
38
|
+
exports.IMAGE_HYGIENE_SCAN_DIRS = ['dist', 'build', 'lib'];
|
|
39
|
+
/** Entry suffixes that must never ship in a customer image. */
|
|
40
|
+
exports.IMAGE_HYGIENE_FORBIDDEN_SUFFIXES = ['.map', '.d.ts', '.tsbuildinfo'];
|
|
41
|
+
/** `docker cp` of a compiled dist/ is a few MB; the default 1 MiB `execFileSync` buffer is not enough. */
|
|
42
|
+
const TAR_MAX_BUFFER_BYTES = 256 * 1024 * 1024;
|
|
43
|
+
/**
|
|
44
|
+
* Docker's "this path is not in the image" signature — the ONE `docker cp`
|
|
45
|
+
* failure that legitimately means "nothing to scan". Matched against the
|
|
46
|
+
* child's stderr, which docker populates for this wording.
|
|
47
|
+
*
|
|
48
|
+
* Deliberately NOT also matching a bare `no such file or directory`: that is
|
|
49
|
+
* the daemon's OS-level errno text, which appears when the READ failed (a
|
|
50
|
+
* pruned or corrupt overlay2 graph) rather than when the path is absent. The
|
|
51
|
+
* two must not collapse — a real not-found read as fatal only aborts a deploy
|
|
52
|
+
* the operator can re-run, while a broken read taken as "absent" silently
|
|
53
|
+
* disables the gate.
|
|
54
|
+
*/
|
|
55
|
+
const DOCKER_CP_MISSING_RE = /could not find the file/i;
|
|
56
|
+
const TAR_BLOCK = 512;
|
|
57
|
+
/** Thrown when the built image ships source maps / declarations. `violations` lists every entry. */
|
|
58
|
+
class ImageHygieneError extends Error {
|
|
59
|
+
image;
|
|
60
|
+
violations;
|
|
61
|
+
constructor(image, violations) {
|
|
62
|
+
super(`Image hygiene gate (HSUITEPT-5): ${image} ships ${violations.length} file(s) that expose ` +
|
|
63
|
+
`the app's source and must not be deployed:\n` +
|
|
64
|
+
violations.map((v) => ` - ${v}`).join('\n') +
|
|
65
|
+
`\nBuild the backend with sourceMap/declaration OFF and removeComments ON (a production ` +
|
|
66
|
+
`tsconfig), or exclude them from the image (.dockerignore), then re-run \`hsuite deploy\`.`);
|
|
67
|
+
this.image = image;
|
|
68
|
+
this.violations = violations;
|
|
69
|
+
this.name = 'ImageHygieneError';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.ImageHygieneError = ImageHygieneError;
|
|
73
|
+
/**
|
|
74
|
+
* Entry names of a (ustar / PAX / GNU) tar archive. Contents are skipped by
|
|
75
|
+
* size; only names are returned. Tolerant: stops at the first zero block or a
|
|
76
|
+
* truncated header, so a non-archive buffer yields `[]`.
|
|
77
|
+
*/
|
|
78
|
+
function listTarEntries(tar) {
|
|
79
|
+
const names = [];
|
|
80
|
+
let pendingLongName = null;
|
|
81
|
+
for (let off = 0; off + TAR_BLOCK <= tar.length;) {
|
|
82
|
+
const header = tar.subarray(off, off + TAR_BLOCK);
|
|
83
|
+
if (header.every((b) => b === 0))
|
|
84
|
+
break;
|
|
85
|
+
const size = parseInt(cstr(header, 124, 12) || '0', 8) || 0;
|
|
86
|
+
const type = String.fromCharCode(header[156] || 0x30);
|
|
87
|
+
const data = tar.subarray(off + TAR_BLOCK, off + TAR_BLOCK + size);
|
|
88
|
+
off += TAR_BLOCK + Math.ceil(size / TAR_BLOCK) * TAR_BLOCK;
|
|
89
|
+
if (type === 'L') {
|
|
90
|
+
pendingLongName = cstr(data, 0, data.length); // GNU long name
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (type === 'x') {
|
|
94
|
+
pendingLongName = paxPath(data.toString('utf8')) ?? pendingLongName; // PAX extended header
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (type === 'g')
|
|
98
|
+
continue; // PAX global header
|
|
99
|
+
const prefix = cstr(header, 345, 155);
|
|
100
|
+
const name = cstr(header, 0, 100);
|
|
101
|
+
names.push(pendingLongName ?? (prefix ? `${prefix}/${name}` : name));
|
|
102
|
+
pendingLongName = null;
|
|
103
|
+
}
|
|
104
|
+
return names;
|
|
105
|
+
}
|
|
106
|
+
/** Entries that must never ship in a customer image. */
|
|
107
|
+
function findImageHygieneViolations(entries) {
|
|
108
|
+
return entries.filter((e) => exports.IMAGE_HYGIENE_FORBIDDEN_SUFFIXES.some((s) => e.endsWith(s)));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Scan the built image's compiled output and THROW {@link ImageHygieneError}
|
|
112
|
+
* if it ships source maps, declaration files or tsbuildinfo. See the module
|
|
113
|
+
* header for the mechanism and the fail-closed contract.
|
|
114
|
+
*/
|
|
115
|
+
function assertImageHygiene(opts) {
|
|
116
|
+
const { image, run, env } = opts;
|
|
117
|
+
const log = opts.log ?? (() => undefined);
|
|
118
|
+
const utf8 = { stdio: ['ignore', 'pipe', 'inherit'], encoding: 'utf8', env };
|
|
119
|
+
const workdir = asText(run('docker', ['inspect', '-f', '{{.Config.WorkingDir}}', image], utf8)) || '/';
|
|
120
|
+
const cid = asText(run('docker', ['create', image], utf8));
|
|
121
|
+
if (!cid)
|
|
122
|
+
throw new Error(`image hygiene gate: \`docker create ${image}\` returned no container id`);
|
|
123
|
+
try {
|
|
124
|
+
const violations = [];
|
|
125
|
+
let scanned = 0;
|
|
126
|
+
for (const dir of exports.IMAGE_HYGIENE_SCAN_DIRS) {
|
|
127
|
+
const entries = copyOut(run, `${cid}:${path_1.posix.join(workdir, dir)}`, env);
|
|
128
|
+
if (entries === null)
|
|
129
|
+
continue;
|
|
130
|
+
scanned++;
|
|
131
|
+
const files = entries.filter((e) => !e.endsWith('/'));
|
|
132
|
+
const bad = findImageHygieneViolations(files);
|
|
133
|
+
violations.push(...bad);
|
|
134
|
+
log(` image hygiene: ${dir}/ — ${files.length} file(s), ${bad.length} offending`);
|
|
135
|
+
}
|
|
136
|
+
if (scanned === 0) {
|
|
137
|
+
log(` ⚠ image hygiene: no compiled output found under ${workdir} (${exports.IMAGE_HYGIENE_SCAN_DIRS.join('/')}) — ` +
|
|
138
|
+
`nothing to scan`);
|
|
139
|
+
}
|
|
140
|
+
if (violations.length > 0)
|
|
141
|
+
throw new ImageHygieneError(image, violations);
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
// Best-effort reaping. A throw from a `finally` REPLACES the in-flight
|
|
145
|
+
// exception, so an unchecked `docker rm` would mask an `ImageHygieneError`
|
|
146
|
+
// verdict with a docker error — but a leaked container is still worth a
|
|
147
|
+
// line rather than being silent.
|
|
148
|
+
try {
|
|
149
|
+
run('docker', ['rm', '-f', cid], { stdio: 'ignore', env });
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
log(` ⚠ image hygiene: could not remove scan container ${cid}: ${errorText(err)}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* `docker cp <src> -` → entry names, or `null` when the path genuinely does not
|
|
158
|
+
* exist in the image.
|
|
159
|
+
*
|
|
160
|
+
* FAIL CLOSED: only docker's own not-found signature maps to `null`. Every
|
|
161
|
+
* other failure — a `maxBuffer` overflow on an unexpectedly huge directory, a
|
|
162
|
+
* dead container, a dropped daemon — is rethrown, because the gate cannot
|
|
163
|
+
* distinguish a broken read from an absent directory and must not report a scan
|
|
164
|
+
* it did not perform. stderr is PIPED rather than discarded so that signature
|
|
165
|
+
* is actually visible; with stderr `ignore`d, `execFileSync`'s error carries no
|
|
166
|
+
* docker text and EVERY failure reads as "not found".
|
|
167
|
+
*/
|
|
168
|
+
function copyOut(run, src, env) {
|
|
169
|
+
let out;
|
|
170
|
+
try {
|
|
171
|
+
out = run('docker', ['cp', src, '-'], {
|
|
172
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
173
|
+
env,
|
|
174
|
+
maxBuffer: TAR_MAX_BUFFER_BYTES,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
const text = errorText(err);
|
|
179
|
+
if (DOCKER_CP_MISSING_RE.test(text))
|
|
180
|
+
return null;
|
|
181
|
+
throw new Error(`image hygiene gate: \`docker cp ${src} -\` failed, so the built image could not be ` +
|
|
182
|
+
`scanned — refusing to deploy an unscanned image: ${text}`);
|
|
183
|
+
}
|
|
184
|
+
// A non-Buffer means the seam decoded the archive, and a utf8 round-trip
|
|
185
|
+
// corrupts tar bytes into a buffer that parses as empty — a contract
|
|
186
|
+
// violation that would have read as "clean scan". Fail closed on it.
|
|
187
|
+
if (!Buffer.isBuffer(out)) {
|
|
188
|
+
throw new Error(`image hygiene gate: \`docker cp ${src} -\` returned ${typeof out}, not a tar buffer — ` +
|
|
189
|
+
`the run seam must not set \`encoding\` on this leg`);
|
|
190
|
+
}
|
|
191
|
+
return listTarEntries(out);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Message plus captured stderr of a thrown child-process error, for signature
|
|
195
|
+
* matching.
|
|
196
|
+
*
|
|
197
|
+
* TOTAL by construction: this runs inside `catch` blocks — including the
|
|
198
|
+
* `finally` that reaps the scan container — and `String()` throws on a
|
|
199
|
+
* null-prototype object or a hostile `Symbol.toPrimitive`. A throw from here
|
|
200
|
+
* would REPLACE the in-flight `ImageHygieneError`, i.e. the gate's verdict
|
|
201
|
+
* would be masked by a logging failure. Unstringifiable input therefore
|
|
202
|
+
* degrades to a literal rather than propagating.
|
|
203
|
+
*/
|
|
204
|
+
function errorText(err) {
|
|
205
|
+
try {
|
|
206
|
+
const stderr = err.stderr;
|
|
207
|
+
const tail = Buffer.isBuffer(stderr) ? stderr.toString('utf8') : String(stderr ?? '');
|
|
208
|
+
const head = err instanceof Error ? err.message : String(err);
|
|
209
|
+
return `${head}\n${tail}`.trim();
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return '[unstringifiable error]';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function asText(out) {
|
|
216
|
+
return typeof out === 'string'
|
|
217
|
+
? out.trim()
|
|
218
|
+
: Buffer.isBuffer(out)
|
|
219
|
+
? out.toString('utf8').trim()
|
|
220
|
+
: '';
|
|
221
|
+
}
|
|
222
|
+
/** NUL-terminated ASCII field of a tar header / GNU long-name block. */
|
|
223
|
+
function cstr(buf, start, len) {
|
|
224
|
+
const slice = buf.subarray(start, start + len);
|
|
225
|
+
const nul = slice.indexOf(0);
|
|
226
|
+
return slice.subarray(0, nul === -1 ? slice.length : nul).toString('utf8');
|
|
227
|
+
}
|
|
228
|
+
/** The `path=` record of a PAX extended header (`"<len> path=<value>\n"` lines). */
|
|
229
|
+
function paxPath(pax) {
|
|
230
|
+
const m = /(?:^|\n)\d+ path=([^\n]*)\n/.exec(pax);
|
|
231
|
+
return m ? m[1] : null;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=image-hygiene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-hygiene.js","sourceRoot":"","sources":["../../src/_lib/image-hygiene.ts"],"names":[],"mappings":";;;AA+EA,wCA0BC;AAGD,gEAEC;AAkBD,gDAyCC;AAzKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,+BAA6B;AAG7B,iGAAiG;AACpF,QAAA,uBAAuB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAEzE,+DAA+D;AAClD,QAAA,gCAAgC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,CAAU,CAAC;AAE3F,0GAA0G;AAC1G,MAAM,oBAAoB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAExD,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,oGAAoG;AACpG,MAAa,iBAAkB,SAAQ,KAAK;IAE/B;IACA;IAFX,YACW,KAAa,EACb,UAAoB;QAE7B,KAAK,CACH,oCAAoC,KAAK,UAAU,UAAU,CAAC,MAAM,uBAAuB;YACzF,8CAA8C;YAC9C,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,yFAAyF;YACzF,2FAA2F,CAC9F,CAAC;QATO,UAAK,GAAL,KAAK,CAAQ;QACb,eAAU,GAAV,UAAU,CAAU;QAS7B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAdD,8CAcC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,GAAW;IACxC,MAAM,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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's one shell-out seam, in a module of its own.
|
|
3
|
+
*
|
|
4
|
+
* It lives here rather than in `baas.ts` because two modules need it and they
|
|
5
|
+
* also need each other: `buildAndPush` (baas) calls `assertImageHygiene`
|
|
6
|
+
* (image-hygiene), and the gate takes the same seam. A type-only import back
|
|
7
|
+
* into `baas.ts` still forms a cycle as far as dependency-cruiser's
|
|
8
|
+
* `no-circular` rule is concerned, and a cycle between two modules that are
|
|
9
|
+
* genuinely layered is a design smell rather than a lint quirk. A leaf module
|
|
10
|
+
* both can import breaks it with no runtime cost — this file compiles to
|
|
11
|
+
* nothing.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* `execFileSync`-shaped seam. Throwing on a non-zero exit is the contract
|
|
15
|
+
* `execFileSync` provides.
|
|
16
|
+
*
|
|
17
|
+
* The return value MATTERS for stdout-capturing invocations (the `docker push`
|
|
18
|
+
* and `docker inspect` legs in `buildAndPush`, and the `docker cp` tar in the
|
|
19
|
+
* image-hygiene gate): `execFileSync` returns the child's stdout, and with
|
|
20
|
+
* `encoding: 'utf8'` that is a `string`. We parse the push summary /
|
|
21
|
+
* `RepoDigests` out of it to recover the pushed manifest digest. Legs run with
|
|
22
|
+
* inherited stdio (build/tag/login) return nothing meaningful. Unit tests
|
|
23
|
+
* supply a fake that returns canned push/inspect stdout.
|
|
24
|
+
*/
|
|
25
|
+
export type RunFn = (file: string, args: string[], options: {
|
|
26
|
+
input?: string;
|
|
27
|
+
stdio?: unknown;
|
|
28
|
+
env?: NodeJS.ProcessEnv;
|
|
29
|
+
cwd?: string;
|
|
30
|
+
encoding?: BufferEncoding;
|
|
31
|
+
/** Stdout cap for byte-heavy captures (the image-hygiene `docker cp` tar). */
|
|
32
|
+
maxBuffer?: number;
|
|
33
|
+
}) => unknown;
|
|
34
|
+
//# sourceMappingURL=run-fn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-fn.d.ts","sourceRoot":"","sources":["../../src/_lib/run-fn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,KAAK,GAAG,CAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,KACE,OAAO,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The CLI's one shell-out seam, in a module of its own.
|
|
4
|
+
*
|
|
5
|
+
* It lives here rather than in `baas.ts` because two modules need it and they
|
|
6
|
+
* also need each other: `buildAndPush` (baas) calls `assertImageHygiene`
|
|
7
|
+
* (image-hygiene), and the gate takes the same seam. A type-only import back
|
|
8
|
+
* into `baas.ts` still forms a cycle as far as dependency-cruiser's
|
|
9
|
+
* `no-circular` rule is concerned, and a cycle between two modules that are
|
|
10
|
+
* genuinely layered is a design smell rather than a lint quirk. A leaf module
|
|
11
|
+
* both can import breaks it with no runtime cost — this file compiles to
|
|
12
|
+
* nothing.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
//# sourceMappingURL=run-fn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-fn.js","sourceRoot":"","sources":["../../src/_lib/run-fn.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -239,6 +239,26 @@ export declare class SubscriptionClient {
|
|
|
239
239
|
* `/smart-apps` and the full URL is `${origin}/api/v3/smart-apps`.
|
|
240
240
|
*/
|
|
241
241
|
createApp(payload: CreateAppPayload): Promise<CreateAppResponse>;
|
|
242
|
+
/**
|
|
243
|
+
* Set the smart-app's `config.customerScope` policy via
|
|
244
|
+
* `PUT /api/v3/smart-apps/:appId` (`SmartAppController.update`, owner-gated
|
|
245
|
+
* on `developerWallet`) — the developer-facing lever for smart-host #3228
|
|
246
|
+
* (Hacken HSUITEPT-6).
|
|
247
|
+
*
|
|
248
|
+
* `'strict'` makes the HOST refuse any BaaS data-plane request from this app
|
|
249
|
+
* that carries no end-user identity, so an app backend that forgets to
|
|
250
|
+
* forward a customer's session cannot silently run that call with its
|
|
251
|
+
* tenant-wide authority. `'permissive'` (the default when the field is
|
|
252
|
+
* absent) restores the pre-#3228 behaviour.
|
|
253
|
+
*
|
|
254
|
+
* The validator merges `config` partially (`UpdateSmartAppSchema` →
|
|
255
|
+
* `SmartAppConfigSchema.partial()`), so this call carries ONLY the policy —
|
|
256
|
+
* `acceptedLoginChains` and the payment/subscription fields are untouched.
|
|
257
|
+
*/
|
|
258
|
+
setCustomerScope(appId: string, customerScope: 'strict' | 'permissive'): Promise<{
|
|
259
|
+
appId: string;
|
|
260
|
+
configCid?: string;
|
|
261
|
+
}>;
|
|
242
262
|
request(payload: {
|
|
243
263
|
appId: string;
|
|
244
264
|
developerAccountId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-client.d.ts","sourceRoot":"","sources":["../../src/_lib/subscription-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscription-client.d.ts","sourceRoot":"","sources":["../../src/_lib/subscription-client.ts"],"names":[],"mappings":"AAwCA,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;I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;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IASI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOnE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOrE,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAK5D,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAMnD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAMxD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,EAAE,MAAM,SAAI,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAMrF"}
|
|
@@ -66,6 +66,7 @@ exports.SubscriptionClient = void 0;
|
|
|
66
66
|
* create route, posting on the same shared `${origin}/api/v3` client.
|
|
67
67
|
*/
|
|
68
68
|
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
69
|
+
const transport_1 = require("./transport");
|
|
69
70
|
/**
|
|
70
71
|
* Validator-side subscription HTTP client.
|
|
71
72
|
*
|
|
@@ -118,7 +119,9 @@ class SubscriptionClient {
|
|
|
118
119
|
// ripple-keypairs ships with xrpl (a CLI dep); import lazily.
|
|
119
120
|
const kp = await Promise.resolve().then(() => __importStar(require('ripple-keypairs')));
|
|
120
121
|
const { publicKey, privateKey } = kp.deriveKeypair(this.auth.seed);
|
|
121
|
-
const authClient = new smart_engines_sdk_1.ValidatorAuthClient({
|
|
122
|
+
const authClient = new smart_engines_sdk_1.ValidatorAuthClient({
|
|
123
|
+
security: { allowInsecure: (0, transport_1.resolveAllowInsecure)(this.origin) },
|
|
124
|
+
});
|
|
122
125
|
const res = await authClient.authenticateWithSigner(this.origin, this.auth.chain, this.auth.address, publicKey, (challenge) => {
|
|
123
126
|
const messageHex = Buffer.from(challenge, 'utf-8').toString('hex').toUpperCase();
|
|
124
127
|
return kp.sign(messageHex, privateKey);
|
|
@@ -177,6 +180,25 @@ class SubscriptionClient {
|
|
|
177
180
|
async createApp(payload) {
|
|
178
181
|
return this.withReauth(() => this.http.post('/smart-apps', payload));
|
|
179
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Set the smart-app's `config.customerScope` policy via
|
|
185
|
+
* `PUT /api/v3/smart-apps/:appId` (`SmartAppController.update`, owner-gated
|
|
186
|
+
* on `developerWallet`) — the developer-facing lever for smart-host #3228
|
|
187
|
+
* (Hacken HSUITEPT-6).
|
|
188
|
+
*
|
|
189
|
+
* `'strict'` makes the HOST refuse any BaaS data-plane request from this app
|
|
190
|
+
* that carries no end-user identity, so an app backend that forgets to
|
|
191
|
+
* forward a customer's session cannot silently run that call with its
|
|
192
|
+
* tenant-wide authority. `'permissive'` (the default when the field is
|
|
193
|
+
* absent) restores the pre-#3228 behaviour.
|
|
194
|
+
*
|
|
195
|
+
* The validator merges `config` partially (`UpdateSmartAppSchema` →
|
|
196
|
+
* `SmartAppConfigSchema.partial()`), so this call carries ONLY the policy —
|
|
197
|
+
* `acceptedLoginChains` and the payment/subscription fields are untouched.
|
|
198
|
+
*/
|
|
199
|
+
async setCustomerScope(appId, customerScope) {
|
|
200
|
+
return this.withReauth(() => this.http.put(`/smart-apps/${encodeURIComponent(appId)}`, { config: { customerScope } }));
|
|
201
|
+
}
|
|
180
202
|
async request(payload) {
|
|
181
203
|
return this.withReauth(() => this.sdk.request(payload));
|
|
182
204
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-client.js","sourceRoot":"","sources":["../../src/_lib/subscription-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,iEAMmC;
|
|
1
|
+
{"version":3,"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AAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAU,EAAE;QAChD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,4CAA4C,CAAC,CAAC;IAChG,CAAC,CAAC;IACF,OAAO;QACL,GAAG,EAAE,CAAI,IAAY,EAAE,EAAE,CAAC,IAAI,CAAI,KAAK,EAAE,IAAI,CAAC;QAC9C,IAAI,EAAE,CAAI,IAAY,EAAE,CAAU,EAAE,EAAE,CAAC,IAAI,CAAI,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,GAAG,EAAE,WAAW,CAAC,KAAK,CAAsB;QAC5C,KAAK,EAAE,WAAW,CAAC,OAAO,CAAwB;QAClD,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAyB;QACrD,OAAO,EAAE,WAAW,CAAC,SAAS,CAA0B;QACxD,SAAS,EAAE,WAAW,CAAC,WAAW,CAA4B;QAC9D,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAAoC;QACtF,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAyB;QACrD,YAAY,EAAE,CAAC,CAAqB,EAAE,EAAE;YACtC,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's ONE transport-policy adapter (HSUITEPT-16 residue, #3276).
|
|
3
|
+
*
|
|
4
|
+
* `libs/smartengine-sdk/src/transport-policy.ts` (landed in #3258) admits
|
|
5
|
+
* plain `http://` only toward a Kubernetes in-cluster service name (`*.svc`,
|
|
6
|
+
* `*.cluster.local`); everything else requires an explicit `allowInsecure`.
|
|
7
|
+
* The CLI used to DERIVE that flag from the URL scheme
|
|
8
|
+
* (`server.startsWith('http://')`), which asserted the flag for a public
|
|
9
|
+
* plaintext host too — so `hsuite --server http://gateway.example.com` sent the
|
|
10
|
+
* wallet-signed session and `X-API-Key` in cleartext, and the SDK could not
|
|
11
|
+
* refuse because the CLI had already opted in. The CLI is the tool that mints
|
|
12
|
+
* and carries credentials (`hsuite init`, `hsuite subscribe`), so that
|
|
13
|
+
* derivation was the whole exposure, one layer up.
|
|
14
|
+
*
|
|
15
|
+
* Every CLI site that builds an SDK client routes through
|
|
16
|
+
* {@link resolveAllowInsecure} instead. It adds the two things the SDK policy
|
|
17
|
+
* deliberately does not cover, and re-implements nothing:
|
|
18
|
+
*
|
|
19
|
+
* - `true` for a LOOPBACK target (`localhost`, `127.0.0.1`, `::1`) — the
|
|
20
|
+
* documented `hsuite --server http://localhost:3000` local-dev flow;
|
|
21
|
+
* - `true` when the operator opted in explicitly, via the global `--insecure`
|
|
22
|
+
* flag (wired once, in `src/index.ts`) or `HSUITE_ALLOW_INSECURE=1`.
|
|
23
|
+
*
|
|
24
|
+
* Everything else goes back to the SDK: a target the policy admits without the
|
|
25
|
+
* flag (https, in-cluster service name) gets `undefined` — "pass nothing, you
|
|
26
|
+
* decide" — and a target it would refuse is refused HERE, before any credential
|
|
27
|
+
* is signed or sent, with a message naming the CLI opt-in. The in-cluster
|
|
28
|
+
* suffix list is NOT copied: whether to refuse is decided by asking
|
|
29
|
+
* `plaintextRejection`, the policy function itself.
|
|
30
|
+
*/
|
|
31
|
+
import type { Command } from 'commander';
|
|
32
|
+
/** Env-var spelling of the opt-in; the value must be exactly `'1'`. */
|
|
33
|
+
export declare const INSECURE_OPT_IN_ENV = "HSUITE_ALLOW_INSECURE";
|
|
34
|
+
/** The global flag spelling of the opt-in (registered on the root program). */
|
|
35
|
+
export declare const INSECURE_OPT_IN_FLAG = "--insecure";
|
|
36
|
+
/** True when `hostname` names the local machine (loopback). */
|
|
37
|
+
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
38
|
+
/** True when the operator opted into plaintext explicitly (`HSUITE_ALLOW_INSECURE=1`). */
|
|
39
|
+
export declare function insecureOptIn(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Register the ONE opt-in flag on the ROOT program, and normalise it into
|
|
42
|
+
* {@link INSECURE_OPT_IN_ENV} — the single channel {@link resolveAllowInsecure}
|
|
43
|
+
* reads. Called once, from `src/index.ts`; never re-added per command.
|
|
44
|
+
*
|
|
45
|
+
* Declaring it on the root is what makes `hsuite --insecure …` and
|
|
46
|
+
* `hsuite deploy --insecure …` the same mechanism: commander's `preAction`
|
|
47
|
+
* hooks fire up the command chain, so this runs before any action body.
|
|
48
|
+
*/
|
|
49
|
+
export declare function installInsecureOptIn(program: Command): void;
|
|
50
|
+
/**
|
|
51
|
+
* The `allowInsecure` value to hand an SDK client built against `target`:
|
|
52
|
+
*
|
|
53
|
+
* - `true` — loopback, or the operator opted in;
|
|
54
|
+
* - `undefined` — the SDK transport policy decides;
|
|
55
|
+
* - throws — plaintext to a public host with no opt-in. Nothing is
|
|
56
|
+
* constructed and no credential is signed.
|
|
57
|
+
*
|
|
58
|
+
* Read the module header before adding a caller: this is the only place in
|
|
59
|
+
* `packages/hsuite-cli` allowed to produce an `allowInsecure` value.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveAllowInsecure(target: string): boolean | undefined;
|
|
62
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/_lib/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAejD,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAY3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CA2BxE"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The CLI's ONE transport-policy adapter (HSUITEPT-16 residue, #3276).
|
|
4
|
+
*
|
|
5
|
+
* `libs/smartengine-sdk/src/transport-policy.ts` (landed in #3258) admits
|
|
6
|
+
* plain `http://` only toward a Kubernetes in-cluster service name (`*.svc`,
|
|
7
|
+
* `*.cluster.local`); everything else requires an explicit `allowInsecure`.
|
|
8
|
+
* The CLI used to DERIVE that flag from the URL scheme
|
|
9
|
+
* (`server.startsWith('http://')`), which asserted the flag for a public
|
|
10
|
+
* plaintext host too — so `hsuite --server http://gateway.example.com` sent the
|
|
11
|
+
* wallet-signed session and `X-API-Key` in cleartext, and the SDK could not
|
|
12
|
+
* refuse because the CLI had already opted in. The CLI is the tool that mints
|
|
13
|
+
* and carries credentials (`hsuite init`, `hsuite subscribe`), so that
|
|
14
|
+
* derivation was the whole exposure, one layer up.
|
|
15
|
+
*
|
|
16
|
+
* Every CLI site that builds an SDK client routes through
|
|
17
|
+
* {@link resolveAllowInsecure} instead. It adds the two things the SDK policy
|
|
18
|
+
* deliberately does not cover, and re-implements nothing:
|
|
19
|
+
*
|
|
20
|
+
* - `true` for a LOOPBACK target (`localhost`, `127.0.0.1`, `::1`) — the
|
|
21
|
+
* documented `hsuite --server http://localhost:3000` local-dev flow;
|
|
22
|
+
* - `true` when the operator opted in explicitly, via the global `--insecure`
|
|
23
|
+
* flag (wired once, in `src/index.ts`) or `HSUITE_ALLOW_INSECURE=1`.
|
|
24
|
+
*
|
|
25
|
+
* Everything else goes back to the SDK: a target the policy admits without the
|
|
26
|
+
* flag (https, in-cluster service name) gets `undefined` — "pass nothing, you
|
|
27
|
+
* decide" — and a target it would refuse is refused HERE, before any credential
|
|
28
|
+
* is signed or sent, with a message naming the CLI opt-in. The in-cluster
|
|
29
|
+
* suffix list is NOT copied: whether to refuse is decided by asking
|
|
30
|
+
* `plaintextRejection`, the policy function itself.
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.INSECURE_OPT_IN_FLAG = exports.INSECURE_OPT_IN_ENV = void 0;
|
|
34
|
+
exports.isLoopbackHostname = isLoopbackHostname;
|
|
35
|
+
exports.insecureOptIn = insecureOptIn;
|
|
36
|
+
exports.installInsecureOptIn = installInsecureOptIn;
|
|
37
|
+
exports.resolveAllowInsecure = resolveAllowInsecure;
|
|
38
|
+
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
39
|
+
/** Env-var spelling of the opt-in; the value must be exactly `'1'`. */
|
|
40
|
+
exports.INSECURE_OPT_IN_ENV = 'HSUITE_ALLOW_INSECURE';
|
|
41
|
+
/** The global flag spelling of the opt-in (registered on the root program). */
|
|
42
|
+
exports.INSECURE_OPT_IN_FLAG = '--insecure';
|
|
43
|
+
/**
|
|
44
|
+
* Hostnames that can only ever name the machine the CLI runs on. Exact match,
|
|
45
|
+
* never a suffix — `localhost.evil.example` is a public name and must not be
|
|
46
|
+
* mistaken for the local-dev escape hatch.
|
|
47
|
+
*/
|
|
48
|
+
const LOOPBACK_HOSTNAMES = new Set([
|
|
49
|
+
'localhost',
|
|
50
|
+
'127.0.0.1',
|
|
51
|
+
'::1',
|
|
52
|
+
// WHATWG `URL.hostname` keeps the brackets on an IPv6 literal.
|
|
53
|
+
'[::1]',
|
|
54
|
+
]);
|
|
55
|
+
/** True when `hostname` names the local machine (loopback). */
|
|
56
|
+
function isLoopbackHostname(hostname) {
|
|
57
|
+
return LOOPBACK_HOSTNAMES.has(hostname.toLowerCase());
|
|
58
|
+
}
|
|
59
|
+
/** True when the operator opted into plaintext explicitly (`HSUITE_ALLOW_INSECURE=1`). */
|
|
60
|
+
function insecureOptIn() {
|
|
61
|
+
return process.env[exports.INSECURE_OPT_IN_ENV] === '1';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Register the ONE opt-in flag on the ROOT program, and normalise it into
|
|
65
|
+
* {@link INSECURE_OPT_IN_ENV} — the single channel {@link resolveAllowInsecure}
|
|
66
|
+
* reads. Called once, from `src/index.ts`; never re-added per command.
|
|
67
|
+
*
|
|
68
|
+
* Declaring it on the root is what makes `hsuite --insecure …` and
|
|
69
|
+
* `hsuite deploy --insecure …` the same mechanism: commander's `preAction`
|
|
70
|
+
* hooks fire up the command chain, so this runs before any action body.
|
|
71
|
+
*/
|
|
72
|
+
function installInsecureOptIn(program) {
|
|
73
|
+
program
|
|
74
|
+
.option(exports.INSECURE_OPT_IN_FLAG, 'Allow plaintext http:// to a non-loopback host (local development only; ' +
|
|
75
|
+
`equivalent to ${exports.INSECURE_OPT_IN_ENV}=1)`)
|
|
76
|
+
.hook('preAction', (thisCommand) => {
|
|
77
|
+
// The resolver lives in plain modules, not just commander actions, so the
|
|
78
|
+
// environment is the one channel both spellings meet in.
|
|
79
|
+
if (thisCommand.opts().insecure)
|
|
80
|
+
process.env[exports.INSECURE_OPT_IN_ENV] = '1';
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The `allowInsecure` value to hand an SDK client built against `target`:
|
|
85
|
+
*
|
|
86
|
+
* - `true` — loopback, or the operator opted in;
|
|
87
|
+
* - `undefined` — the SDK transport policy decides;
|
|
88
|
+
* - throws — plaintext to a public host with no opt-in. Nothing is
|
|
89
|
+
* constructed and no credential is signed.
|
|
90
|
+
*
|
|
91
|
+
* Read the module header before adding a caller: this is the only place in
|
|
92
|
+
* `packages/hsuite-cli` allowed to produce an `allowInsecure` value.
|
|
93
|
+
*/
|
|
94
|
+
function resolveAllowInsecure(target) {
|
|
95
|
+
if (insecureOptIn())
|
|
96
|
+
return true;
|
|
97
|
+
let parsed;
|
|
98
|
+
try {
|
|
99
|
+
parsed = new URL(target);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Not a URL we can reason about — leave the diagnosis to the SDK, whose
|
|
103
|
+
// error surface for a malformed base URL is the one callers already render.
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (isLoopbackHostname(parsed.hostname))
|
|
107
|
+
return true;
|
|
108
|
+
// Ask the policy, with the flag off, what it would decide. `null` means the
|
|
109
|
+
// SDK admits this target on its own (https, or an in-cluster service name) —
|
|
110
|
+
// so pass nothing and let it. A reason means the SDK would refuse; refuse
|
|
111
|
+
// here instead, where the CLI can name its own opt-in.
|
|
112
|
+
if ((0, smart_engines_sdk_1.plaintextRejection)(parsed, false) === null)
|
|
113
|
+
return undefined;
|
|
114
|
+
throw new Error(`refusing to send credentials over plaintext http:// to ${parsed.hostname}: ` +
|
|
115
|
+
'the smart-engines transport policy admits plain http:// only toward an ' +
|
|
116
|
+
'in-cluster service name (*.svc, *.cluster.local). Use https://, or re-run ' +
|
|
117
|
+
`with ${exports.INSECURE_OPT_IN_FLAG} (or ${exports.INSECURE_OPT_IN_ENV}=1) to allow it — ` +
|
|
118
|
+
'local development only.');
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/_lib/transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAyBH,gDAEC;AAGD,sCAEC;AAWD,oDAYC;AAaD,oDA2BC;AA5FD,iEAA+D;AAE/D,uEAAuE;AAC1D,QAAA,mBAAmB,GAAG,uBAAuB,CAAC;AAE3D,+EAA+E;AAClE,QAAA,oBAAoB,GAAG,YAAY,CAAC;AAEjD;;;;GAIG;AACH,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,WAAW;IACX,KAAK;IACL,+DAA+D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