@supersdk/supercli 0.5.8 → 0.5.9
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/commands/analytics.js +1 -19
- package/dist/commands/analytics.js.map +1 -1
- package/dist/commands/analyticsInsights.js +11 -23
- package/dist/commands/analyticsInsights.js.map +1 -1
- package/dist/commands/db.js +18 -51
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/delivery.js +1 -14
- package/dist/commands/delivery.js.map +1 -1
- package/dist/commands/org.js +4 -17
- package/dist/commands/org.js.map +1 -1
- package/dist/commands/projects.js +2 -10
- package/dist/commands/projects.js.map +1 -1
- package/dist/commands/runLifecycle.js +0 -21
- package/dist/commands/runLifecycle.js.map +1 -1
- package/dist/commands/scheduler.js +0 -20
- package/dist/commands/scheduler.js.map +1 -1
- package/dist/commands/settings.js +1 -19
- package/dist/commands/settings.js.map +1 -1
- package/dist/commands/site.js +1 -12
- package/dist/commands/site.js.map +1 -1
- package/dist/commands/sqlInput.js +5 -2
- package/dist/commands/sqlInput.js.map +1 -1
- package/dist/deploy/domainEndpoints.js +1 -3
- package/dist/deploy/domainEndpoints.js.map +1 -1
- package/dist/deploy/resultWriter.js +0 -3
- package/dist/deploy/resultWriter.js.map +1 -1
- package/dist/output/envelope.js +6 -59
- package/dist/output/envelope.js.map +1 -1
- package/dist/output/resultPrinter.js +0 -16
- package/dist/output/resultPrinter.js.map +1 -1
- package/package.json +1 -1
package/dist/output/envelope.js
CHANGED
|
@@ -33,10 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.SCHEMA_VERSION = void 0;
|
|
37
37
|
exports.generateRequestId = generateRequestId;
|
|
38
38
|
exports.redactTokenShaped = redactTokenShaped;
|
|
39
|
-
exports.assertNoTokenShapedValue = assertNoTokenShapedValue;
|
|
40
39
|
// Agent Contract JSON envelope (AC-1). The single, stable shape every command
|
|
41
40
|
// emits on stdout under `--output json`:
|
|
42
41
|
//
|
|
@@ -57,67 +56,15 @@ exports.SCHEMA_VERSION = 1;
|
|
|
57
56
|
function generateRequestId() {
|
|
58
57
|
return `cli_${crypto.randomUUID()}`;
|
|
59
58
|
}
|
|
60
|
-
// A full CLI/service token is `cli_`/`sst_` followed by a long base64url run
|
|
61
|
-
// (alphabet A-Za-z0-9 plus `-` and `_` — the generator uses base64url, so ~40% of real
|
|
62
|
-
// tokens carry a `-`/`_` within the first 16 chars and MUST be matched · review EXR-4).
|
|
63
|
-
// A masked identity (e.g. `cli_…a1b2`) uses an ellipsis (not in the class), so it does
|
|
64
|
-
// not trip this guard.
|
|
65
|
-
const TOKEN_VALUE_PATTERN = /(?:cli|sst)_[A-Za-z0-9_-]{16,}/;
|
|
66
59
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
60
|
+
* A full CLI/service token is `cli_`/`sst_` followed by a long base64url run (alphabet
|
|
61
|
+
* A-Za-z0-9 plus `-` and `_` · review EXR-4). This REDACTS token-shaped runs from a free-text error
|
|
62
|
+
* message before it reaches stdout/stderr (review EXR-5 · defense-in-depth). Result payloads are
|
|
63
|
+
* never inspected or altered (the CLI restricts by permission, not by content); an error
|
|
64
|
+
* message may echo user input, so we scrub rather than throw — never lose the error, never leak a token.
|
|
71
65
|
*/
|
|
72
66
|
const TOKEN_VALUE_PATTERN_G = /(?:cli|sst)_[A-Za-z0-9_-]{16,}/g;
|
|
73
67
|
function redactTokenShaped(message) {
|
|
74
68
|
return message.replace(TOKEN_VALUE_PATTERN_G, '[redacted]');
|
|
75
69
|
}
|
|
76
|
-
class ResultLeakError extends Error {
|
|
77
|
-
constructor(where) {
|
|
78
|
-
super(`refusing to emit result: a token-shaped value was found at ${where}`);
|
|
79
|
-
this.name = 'ResultLeakError';
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.ResultLeakError = ResultLeakError;
|
|
83
|
-
function pathIsAllowed(pathStr, allowTokenShapedPaths) {
|
|
84
|
-
const normalized = pathStr.replace(/\[\d+\]/g, '[*]');
|
|
85
|
-
return allowTokenShapedPaths.some((allowed) => {
|
|
86
|
-
if (allowed.endsWith('.**')) {
|
|
87
|
-
const root = allowed.slice(0, -3);
|
|
88
|
-
return normalized === root || normalized.startsWith(`${root}.`) || normalized.startsWith(`${root}[`);
|
|
89
|
-
}
|
|
90
|
-
return normalized === allowed;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Defense-in-depth self-check (PRD "开工前项"): a `result` payload is written to
|
|
95
|
-
* stdout WITHOUT going through log.ts's redact(), so before emitting it we assert
|
|
96
|
-
* no string value looks like a live token. Fails closed (throws) rather than ever
|
|
97
|
-
* leaking a token onto stdout — the primary control is still "commands never put
|
|
98
|
-
* a raw token into result".
|
|
99
|
-
*/
|
|
100
|
-
function assertNoTokenShapedValue(value, pathStr = '$', depth = 0, opts = {}) {
|
|
101
|
-
if (value == null)
|
|
102
|
-
return;
|
|
103
|
-
// The traversal budget is only a denial-of-service guard. Exceeding it must
|
|
104
|
-
// fail closed; silently skipping a deep subtree could expose a credential.
|
|
105
|
-
if (depth > 64)
|
|
106
|
-
throw new ResultLeakError(pathStr);
|
|
107
|
-
if (typeof value === 'string') {
|
|
108
|
-
if (TOKEN_VALUE_PATTERN.test(value) && !pathIsAllowed(pathStr, opts.allowTokenShapedPaths ?? [])) {
|
|
109
|
-
throw new ResultLeakError(pathStr);
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (Array.isArray(value)) {
|
|
114
|
-
value.forEach((v, i) => assertNoTokenShapedValue(v, `${pathStr}[${i}]`, depth + 1, opts));
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (typeof value === 'object') {
|
|
118
|
-
for (const [k, v] of Object.entries(value)) {
|
|
119
|
-
assertNoTokenShapedValue(v, `${pathStr}.${k}`, depth + 1, opts);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
70
|
//# sourceMappingURL=envelope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/output/envelope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,8CAEC;
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/output/envelope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,8CAEC;AAUD,8CAEC;AA/CD,8EAA8E;AAC9E,yCAAyC;AACzC,EAAE;AACF,+DAA+D;AAC/D,8EAA8E;AAC9E,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,iFAAiF;AACjF,4DAA4D;AAC5D,oDAAsC;AAEtC,gFAAgF;AACnE,QAAA,cAAc,GAAG,CAAC,CAAC;AAgBhC,kFAAkF;AAClF,SAAgB,iBAAiB;IAC/B,OAAO,OAAO,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;AACtC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AAChE,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,OAAO,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -23,19 +23,6 @@ class ResultPrinter {
|
|
|
23
23
|
}
|
|
24
24
|
/** Emit a success result (exit stays 0). */
|
|
25
25
|
success(result, opts = {}) {
|
|
26
|
-
// CA query results intentionally echo this printer's CLI-local request id.
|
|
27
|
-
// It resembles a credential, so accept only this exact top-level value; all
|
|
28
|
-
// other values are guarded in both JSON and human modes.
|
|
29
|
-
if (result !== null &&
|
|
30
|
-
typeof result === 'object' &&
|
|
31
|
-
!Array.isArray(result) &&
|
|
32
|
-
result.request_id === this.requestId) {
|
|
33
|
-
const { request_id: _requestId, ...withoutRequestId } = result;
|
|
34
|
-
(0, envelope_1.assertNoTokenShapedValue)(withoutRequestId, '$', 0, opts);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
(0, envelope_1.assertNoTokenShapedValue)(result, '$', 0, opts);
|
|
38
|
-
}
|
|
39
26
|
if (this.mode === 'json') {
|
|
40
27
|
const envelope = {
|
|
41
28
|
schema_version: envelope_1.SCHEMA_VERSION,
|
|
@@ -62,8 +49,6 @@ class ResultPrinter {
|
|
|
62
49
|
const publicCode = opts.publicCode && PUBLIC_CODE.test(opts.publicCode)
|
|
63
50
|
? opts.publicCode
|
|
64
51
|
: errorCode;
|
|
65
|
-
if (opts.result !== undefined)
|
|
66
|
-
(0, envelope_1.assertNoTokenShapedValue)(opts.result);
|
|
67
52
|
process.exitCode = exitCode;
|
|
68
53
|
if (opts.logMeta) {
|
|
69
54
|
// Opt-in command-owned diagnostic. This stays off by default so adding
|
|
@@ -90,7 +75,6 @@ class ResultPrinter {
|
|
|
90
75
|
this.success(outcome.result, {
|
|
91
76
|
soft: outcome.soft,
|
|
92
77
|
humanMessage: outcome.humanMessage,
|
|
93
|
-
allowTokenShapedPaths: outcome.allowTokenShapedPaths,
|
|
94
78
|
});
|
|
95
79
|
}
|
|
96
80
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resultPrinter.js","sourceRoot":"","sources":["../../src/output/resultPrinter.ts"],"names":[],"mappings":";;;AAAA,kEAAkE;AAClE,+EAA+E;AAC/E,2EAA2E;AAC3E,yEAAyE;AACzE,4DAA4D;AAC5D,gFAAgF;AAChF,
|
|
1
|
+
{"version":3,"file":"resultPrinter.js","sourceRoot":"","sources":["../../src/output/resultPrinter.ts"],"names":[],"mappings":";;;AAAA,kEAAkE;AAClE,+EAA+E;AAC/E,2EAA2E;AAC3E,yEAAyE;AACz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