hikoutei 0.11.101-dev → 0.11.103-dev
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/cli/adoptFlow.d.ts.map +1 -1
- package/dist/cli/adoptFlow.js +31 -0
- package/dist/cli/adoptFlow.js.map +1 -1
- package/dist/cli/checkpoint.d.ts +38 -52
- package/dist/cli/checkpoint.d.ts.map +1 -1
- package/dist/cli/checkpoint.js +87 -34
- package/dist/cli/checkpoint.js.map +1 -1
- package/dist/cli/envFileWriter.d.ts +42 -8
- package/dist/cli/envFileWriter.d.ts.map +1 -1
- package/dist/cli/envFileWriter.js +60 -30
- package/dist/cli/envFileWriter.js.map +1 -1
- package/dist/cli/errors.d.ts +6 -5
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +6 -5
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/gcloudRunner.d.ts +22 -5
- package/dist/cli/gcloudRunner.d.ts.map +1 -1
- package/dist/cli/gcloudRunner.js +168 -0
- package/dist/cli/gcloudRunner.js.map +1 -1
- package/dist/cli/keyContract.d.ts +62 -0
- package/dist/cli/keyContract.d.ts.map +1 -0
- package/dist/cli/keyContract.js +24 -0
- package/dist/cli/keyContract.js.map +1 -0
- package/dist/cli/keyMaterial.d.ts +1 -1
- package/dist/cli/keyMaterial.d.ts.map +1 -1
- package/dist/cli/keyMaterial.js +2 -2
- package/dist/cli/keyMaterial.js.map +1 -1
- package/dist/cli/keyProvision.d.ts +22 -44
- package/dist/cli/keyProvision.d.ts.map +1 -1
- package/dist/cli/keyProvision.js +212 -103
- package/dist/cli/keyProvision.js.map +1 -1
- package/dist/cli/setupFlow.d.ts +2 -7
- package/dist/cli/setupFlow.d.ts.map +1 -1
- package/dist/cli/setupFlow.js +301 -55
- package/dist/cli/setupFlow.js.map +1 -1
- package/dist/cli/setupPathCollision.d.ts +11 -3
- package/dist/cli/setupPathCollision.d.ts.map +1 -1
- package/dist/cli/setupPathCollision.js +10 -7
- package/dist/cli/setupPathCollision.js.map +1 -1
- package/dist/cli/setupPaths.d.ts +2 -0
- package/dist/cli/setupPaths.d.ts.map +1 -1
- package/dist/cli/setupPaths.js +9 -0
- package/dist/cli/setupPaths.js.map +1 -1
- package/dist/sheets/providers/google-sheets-api/model/batchBuilder.d.ts +10 -0
- package/dist/sheets/providers/google-sheets-api/model/batchBuilder.d.ts.map +1 -1
- package/dist/sheets/providers/google-sheets-api/model/batchBuilder.js +25 -36
- package/dist/sheets/providers/google-sheets-api/model/batchBuilder.js.map +1 -1
- package/dist/sheets/providers/google-sheets-api/model/planner.d.ts.map +1 -1
- package/dist/sheets/providers/google-sheets-api/model/planner.js +0 -3
- package/dist/sheets/providers/google-sheets-api/model/planner.js.map +1 -1
- package/dist/sheets/providers/google-sheets-api/operations/fastAppend.d.ts.map +1 -1
- package/dist/sheets/providers/google-sheets-api/operations/fastAppend.js +3 -13
- package/dist/sheets/providers/google-sheets-api/operations/fastAppend.js.map +1 -1
- package/dist/sheets/providers/google-sheets-api/operations/rowChecks.js +9 -10
- package/dist/sheets/providers/google-sheets-api/operations/rowChecks.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,8 +38,9 @@ export interface EnvFileWriteResult {
|
|
|
38
38
|
* refused before any open so a FIFO can never block), the file is opened
|
|
39
39
|
* WITHOUT following symlinks (`O_NOFOLLOW` where supported) and
|
|
40
40
|
* non-blocking (`O_NONBLOCK` where supported), the descriptor is
|
|
41
|
-
* fstat-verified as
|
|
42
|
-
* a
|
|
41
|
+
* fstat-verified as the SAME file the lstat observed (device/inode
|
|
42
|
+
* identity, covering a same-type replacement as well as a non-regular one)
|
|
43
|
+
* BEFORE a single byte is read, and any
|
|
43
44
|
* alias of the credentials file or other reserved paths (hardlink/symlink
|
|
44
45
|
* alias — the key contents are never read through it) is refused before a
|
|
45
46
|
* single byte is read. The preserved env content is built in memory and written to a unique private sibling temp
|
|
@@ -62,7 +63,40 @@ export declare function writeSetupEnvFile(outputPath: string, credentialsPath: s
|
|
|
62
63
|
* (a stale pool line is removed as a managed key). Paths are joined
|
|
63
64
|
* with commas and no spaces, matching the runtime pool parser.
|
|
64
65
|
*/
|
|
65
|
-
poolPaths?: readonly string[]
|
|
66
|
+
poolPaths?: readonly string[],
|
|
67
|
+
/**
|
|
68
|
+
* Filesystem used for the existing-output read; injectable so tests can
|
|
69
|
+
* prove the descriptor-identity check without a racy real swap. The
|
|
70
|
+
* atomic write below always uses the default filesystem.
|
|
71
|
+
*/
|
|
72
|
+
loadFs?: EnvFileLoadFs): EnvFileWriteResult;
|
|
73
|
+
/**
|
|
74
|
+
* Filesystem operations the existing-output read uses; injectable for
|
|
75
|
+
* tests (same-type replacement-descriptor coverage without a racy real
|
|
76
|
+
* swap).
|
|
77
|
+
*
|
|
78
|
+
* Both `lstatSync` and `fstatSync` expose the device/inode so the read can
|
|
79
|
+
* BIND the opened descriptor to the entry the lstat verified: a file
|
|
80
|
+
* replaced between the type check and the open is refused before a single
|
|
81
|
+
* byte is read. Mirrors `SetupStateLoadFs` in checkpoint.ts.
|
|
82
|
+
*/
|
|
83
|
+
export interface EnvFileLoadFs {
|
|
84
|
+
lstatSync(path: string): {
|
|
85
|
+
isSymbolicLink(): boolean;
|
|
86
|
+
isFile(): boolean;
|
|
87
|
+
readonly dev: number;
|
|
88
|
+
readonly ino: number;
|
|
89
|
+
};
|
|
90
|
+
openSync(path: string, flags: number): number;
|
|
91
|
+
fstatSync(fd: number): {
|
|
92
|
+
isFile(): boolean;
|
|
93
|
+
readonly dev: number;
|
|
94
|
+
readonly ino: number;
|
|
95
|
+
readonly mode: number;
|
|
96
|
+
};
|
|
97
|
+
readFileSync(fd: number, encoding: "utf8"): string;
|
|
98
|
+
closeSync(fd: number): void;
|
|
99
|
+
}
|
|
66
100
|
/**
|
|
67
101
|
* Writes content to the output path atomically via a unique private temp.
|
|
68
102
|
*
|
|
@@ -91,14 +125,14 @@ export { noFollowFlag, nonBlockFlag } from "./setupPaths.js";
|
|
|
91
125
|
* Re-runs the reserved-path collision check and fails closed when aliases
|
|
92
126
|
* changed after the initial preflight.
|
|
93
127
|
*
|
|
94
|
-
* The reserved paths (key, output, checkpoint, temp, lock
|
|
95
|
-
* immediately before every checkpoint
|
|
96
|
-
*
|
|
97
|
-
*
|
|
128
|
+
* The reserved paths (key, output, checkpoint, temp, lock, and any extra
|
|
129
|
+
* pool-key paths) are re-resolved immediately before every checkpoint and
|
|
130
|
+
* `.env` write: aliases planted after preflight must never redirect a write.
|
|
131
|
+
* Returns an error result on collision, `null` when safe.
|
|
98
132
|
*/
|
|
99
133
|
export declare function revalidateSetupPaths(options: {
|
|
100
134
|
readonly keyPath: string;
|
|
101
135
|
readonly outputPath: string;
|
|
102
136
|
readonly statePath: string;
|
|
103
|
-
}): SetupErrorResult | null;
|
|
137
|
+
}, extraReserved?: readonly string[]): SetupErrorResult | null;
|
|
104
138
|
//# sourceMappingURL=envFileWriter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envFileWriter.d.ts","sourceRoot":"","sources":["../../../../../../src/envFileWriter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGrE,2CAA2C;AAC3C,eAAO,MAAM,cAAc;;;IAGzB,sFAAsF;;CAE9E,CAAC;AAEX,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAgBD
|
|
1
|
+
{"version":3,"file":"envFileWriter.d.ts","sourceRoot":"","sources":["../../../../../../src/envFileWriter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH,OAAO,EAML,KAAK,iBAA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G,MAAM,CAAC;IACnD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AA+HD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,EAAE,GAAE,iBAA4C,GAC/C,IAAI,CA6EN;AAED;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA+B7D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE;IACP,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,EACD,aAAa,GAAE,SAAS,MAAM,EAAO,GACpC,gBAAgB,GAAG,IAAI,CAiBzB"}
|
|
@@ -45,8 +45,9 @@ const ENV_FILE_MODE = 0o600;
|
|
|
45
45
|
* refused before any open so a FIFO can never block), the file is opened
|
|
46
46
|
* WITHOUT following symlinks (`O_NOFOLLOW` where supported) and
|
|
47
47
|
* non-blocking (`O_NONBLOCK` where supported), the descriptor is
|
|
48
|
-
* fstat-verified as
|
|
49
|
-
* a
|
|
48
|
+
* fstat-verified as the SAME file the lstat observed (device/inode
|
|
49
|
+
* identity, covering a same-type replacement as well as a non-regular one)
|
|
50
|
+
* BEFORE a single byte is read, and any
|
|
50
51
|
* alias of the credentials file or other reserved paths (hardlink/symlink
|
|
51
52
|
* alias — the key contents are never read through it) is refused before a
|
|
52
53
|
* single byte is read. The preserved env content is built in memory and written to a unique private sibling temp
|
|
@@ -69,8 +70,14 @@ export function writeSetupEnvFile(outputPath, credentialsPath, spreadsheetUrl, r
|
|
|
69
70
|
* (a stale pool line is removed as a managed key). Paths are joined
|
|
70
71
|
* with commas and no spaces, matching the runtime pool parser.
|
|
71
72
|
*/
|
|
72
|
-
poolPaths = []
|
|
73
|
-
|
|
73
|
+
poolPaths = [],
|
|
74
|
+
/**
|
|
75
|
+
* Filesystem used for the existing-output read; injectable so tests can
|
|
76
|
+
* prove the descriptor-identity check without a racy real swap. The
|
|
77
|
+
* atomic write below always uses the default filesystem.
|
|
78
|
+
*/
|
|
79
|
+
loadFs = defaultEnvFileLoadFs) {
|
|
80
|
+
const read = readExistingEnvFile(outputPath, [credentialsPath, ...reservedPaths], loadFs);
|
|
74
81
|
const existing = read.existing;
|
|
75
82
|
const created = read.created;
|
|
76
83
|
const rawLines = existing === "" ? [] : existing.split("\n");
|
|
@@ -95,6 +102,14 @@ poolPaths = []) {
|
|
|
95
102
|
}
|
|
96
103
|
return { created, modified };
|
|
97
104
|
}
|
|
105
|
+
/** The default filesystem for the existing-output read. */
|
|
106
|
+
const defaultEnvFileLoadFs = {
|
|
107
|
+
lstatSync,
|
|
108
|
+
openSync: (path, flags) => openSync(path, flags),
|
|
109
|
+
fstatSync,
|
|
110
|
+
readFileSync,
|
|
111
|
+
closeSync,
|
|
112
|
+
};
|
|
98
113
|
/**
|
|
99
114
|
* Reads an existing .env output without following symlinks or aliases.
|
|
100
115
|
*
|
|
@@ -104,25 +119,19 @@ poolPaths = []) {
|
|
|
104
119
|
* FIFOs, devices, and sockets are refused BEFORE any open, so a FIFO can
|
|
105
120
|
* never block the open or a later read. The file is opened with `O_NOFOLLOW`
|
|
106
121
|
* (where supported) plus `O_NONBLOCK` (where supported), the descriptor is
|
|
107
|
-
* fstat-verified as a regular file
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
122
|
+
* fstat-verified as a regular file with the SAME device/inode the lstat
|
|
123
|
+
* observed BEFORE a single byte is read — covering a same-type replacement
|
|
124
|
+
* (a different regular file swapped in between the lstat check and the
|
|
125
|
+
* open) as well as a non-regular replacement — and the descriptor inode is
|
|
126
|
+
* compared against every reserved path; any match is refused before
|
|
127
|
+
* reading. A missing file is `created` with empty content. Throws on unsafe
|
|
128
|
+
* entries; the caller preserves carrier codes (`SetupPathSafetyError`) and
|
|
129
|
+
* falls back to `output_write_failed` for other errors.
|
|
114
130
|
*/
|
|
115
|
-
function readExistingEnvFile(outputPath, reservedPaths) {
|
|
131
|
+
function readExistingEnvFile(outputPath, reservedPaths, fs = defaultEnvFileLoadFs) {
|
|
132
|
+
let lst;
|
|
116
133
|
try {
|
|
117
|
-
|
|
118
|
-
if (lst.isSymbolicLink()) {
|
|
119
|
-
throw setupPathSafetyError(SETUP_ERROR_CODES.OUTPUT_SYMLINK_REFUSED, `refusing to follow a symlink at the output path ${outputPath}; remove the symlink and retry`);
|
|
120
|
-
}
|
|
121
|
-
if (!lst.isFile()) {
|
|
122
|
-
// Directories, FIFOs, devices, and sockets are never opened or read:
|
|
123
|
-
// a FIFO open without O_NONBLOCK would block indefinitely.
|
|
124
|
-
throw setupPathSafetyError(SETUP_ERROR_CODES.OUTPUT_NOT_REGULAR_FILE, `the output path ${outputPath} is not a regular file; remove it and retry`);
|
|
125
|
-
}
|
|
134
|
+
lst = fs.lstatSync(outputPath);
|
|
126
135
|
}
|
|
127
136
|
catch (error) {
|
|
128
137
|
if (isNodeError(error) && error.code === "ENOENT") {
|
|
@@ -130,9 +139,17 @@ function readExistingEnvFile(outputPath, reservedPaths) {
|
|
|
130
139
|
}
|
|
131
140
|
throw error;
|
|
132
141
|
}
|
|
142
|
+
if (lst.isSymbolicLink()) {
|
|
143
|
+
throw setupPathSafetyError(SETUP_ERROR_CODES.OUTPUT_SYMLINK_REFUSED, `refusing to follow a symlink at the output path ${outputPath}; remove the symlink and retry`);
|
|
144
|
+
}
|
|
145
|
+
if (!lst.isFile()) {
|
|
146
|
+
// Directories, FIFOs, devices, and sockets are never opened or read:
|
|
147
|
+
// a FIFO open without O_NONBLOCK would block indefinitely.
|
|
148
|
+
throw setupPathSafetyError(SETUP_ERROR_CODES.OUTPUT_NOT_REGULAR_FILE, `the output path ${outputPath} is not a regular file; remove it and retry`);
|
|
149
|
+
}
|
|
133
150
|
let fd;
|
|
134
151
|
try {
|
|
135
|
-
fd = openSync(outputPath, constants.O_RDONLY | noFollowFlag() | nonBlockFlag());
|
|
152
|
+
fd = fs.openSync(outputPath, constants.O_RDONLY | noFollowFlag() | nonBlockFlag());
|
|
136
153
|
}
|
|
137
154
|
catch (error) {
|
|
138
155
|
if (isNodeError(error) && (error.code === "ELOOP" || error.code === "EMLINK")) {
|
|
@@ -143,24 +160,33 @@ function readExistingEnvFile(outputPath, reservedPaths) {
|
|
|
143
160
|
throw error;
|
|
144
161
|
}
|
|
145
162
|
try {
|
|
146
|
-
const stat = fstatSync(fd);
|
|
163
|
+
const stat = fs.fstatSync(fd);
|
|
147
164
|
if (!stat.isFile()) {
|
|
148
165
|
// A non-regular entry replaced the output between the lstat check and
|
|
149
166
|
// the open (e.g. a FIFO planted mid-run): refuse without reading it
|
|
150
167
|
// (O_NONBLOCK made the open return instead of blocking on a FIFO).
|
|
151
168
|
throw setupPathSafetyError(SETUP_ERROR_CODES.OUTPUT_NOT_REGULAR_FILE, `the output path ${outputPath} is not a regular file; remove it and retry`);
|
|
152
169
|
}
|
|
170
|
+
if (stat.dev !== lst.dev || stat.ino !== lst.ino) {
|
|
171
|
+
// The descriptor is NOT the file the lstat verified: a same-type
|
|
172
|
+
// replacement (a different regular file) was swapped in between the
|
|
173
|
+
// lstat check and the open. Refuse before a single byte is read —
|
|
174
|
+
// the checked file's content must never be confused with the
|
|
175
|
+
// replacement's. Reuses the regular-file carrier: the opened entry
|
|
176
|
+
// is not the verified regular file.
|
|
177
|
+
throw setupPathSafetyError(SETUP_ERROR_CODES.OUTPUT_NOT_REGULAR_FILE, `the output path ${outputPath} was replaced before it could be read; remove it and retry`);
|
|
178
|
+
}
|
|
153
179
|
const alias = reservedPaths.find((path) => sameInodeAsPath(stat, path));
|
|
154
180
|
if (alias !== undefined) {
|
|
155
181
|
throw setupPathSafetyError(SETUP_ERROR_CODES.OUTPUT_ALIASES_RESERVED, `the output path ${outputPath} aliases the reserved file ${alias}; refusing to read or write through it`);
|
|
156
182
|
}
|
|
157
183
|
// The owner bits come from the SAME secured descriptor read, so the
|
|
158
184
|
// mode-repair decision below can never race a check-then-use sequence.
|
|
159
|
-
return { existing: readFileSync(fd, "utf8"), created: false, mode: Number(stat.mode) & 0o777 };
|
|
185
|
+
return { existing: fs.readFileSync(fd, "utf8"), created: false, mode: Number(stat.mode) & 0o777 };
|
|
160
186
|
}
|
|
161
187
|
finally {
|
|
162
188
|
try {
|
|
163
|
-
closeSync(fd);
|
|
189
|
+
fs.closeSync(fd);
|
|
164
190
|
}
|
|
165
191
|
catch {
|
|
166
192
|
// The read error is the one to report.
|
|
@@ -306,16 +332,20 @@ function removeOwnedTempFile(tempPath, dev, ino, fs) {
|
|
|
306
332
|
* Re-runs the reserved-path collision check and fails closed when aliases
|
|
307
333
|
* changed after the initial preflight.
|
|
308
334
|
*
|
|
309
|
-
* The reserved paths (key, output, checkpoint, temp, lock
|
|
310
|
-
* immediately before every checkpoint
|
|
311
|
-
*
|
|
312
|
-
*
|
|
335
|
+
* The reserved paths (key, output, checkpoint, temp, lock, and any extra
|
|
336
|
+
* pool-key paths) are re-resolved immediately before every checkpoint and
|
|
337
|
+
* `.env` write: aliases planted after preflight must never redirect a write.
|
|
338
|
+
* Returns an error result on collision, `null` when safe.
|
|
313
339
|
*/
|
|
314
|
-
export function revalidateSetupPaths(options) {
|
|
340
|
+
export function revalidateSetupPaths(options, extraReserved = []) {
|
|
315
341
|
const collision = findSetupPathCollision({
|
|
316
342
|
keyPath: options.keyPath,
|
|
317
343
|
outputPath: options.outputPath,
|
|
318
344
|
statePath: options.statePath,
|
|
345
|
+
// Planned pool keys plus caller-supplied stored pool keys (checkpoint
|
|
346
|
+
// pool entries and any in-flight pool write-ahead): an alias planted
|
|
347
|
+
// mid-run must never redirect a checkpoint or .env write.
|
|
348
|
+
poolKeyPaths: extraReserved,
|
|
319
349
|
});
|
|
320
350
|
if (collision.status === "collision") {
|
|
321
351
|
return errorResult(SETUP_ERROR_CODES.INVALID_ARGS, `${collision.message}; the reserved setup paths changed during the run, so nothing was written`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envFileWriter.js","sourceRoot":"","sources":["../../../../../../src/envFileWriter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,YAAY,GAEb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,WAAW,EAAyB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,2CAA2C;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW,EAAE,gCAAgC;IAC7C,eAAe,EAAE,+BAA+B;IAChD,sFAAsF;IACtF,eAAe,EAAE,2BAA2B;CACpC,CAAC;AAUX,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,WAAW,GAAG,CAAC;QACjD,IAAI,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,eAAe,GAAG,CAAC;QACrD,IAAI,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,eAAe,GAAG,CAAC,CACtD,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC,oDAAoD;AACpD,MAAM,aAA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,WAAW,CAChB,iBAAiB,CAAC,YAAY,EAC9B,GAAG,SAAS,CAAC,OAAO,2EAA2E,CAChG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AACnD,CAAC"}
|
package/dist/cli/errors.d.ts
CHANGED
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
* another, and so on; the message carries the specific detail. The 16 path-safety
|
|
9
9
|
* carrier codes (CHECKPOINT_TEMP_*, OUTPUT_*, SETUP_WRITE_NO_PROGRESS,
|
|
10
10
|
* SETUP_DIR_FSYNC_*, SETUP_RENAME_DURABLE_*) are operation-level: 16 distinct
|
|
11
|
-
* codes cover
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* codes cover 16 recoverable path-safety throw sites (OUTPUT_SYMLINK_REFUSED
|
|
12
|
+
* is reused at two sites and OUTPUT_NOT_REGULAR_FILE at three: the lstat
|
|
13
|
+
* boundary, the descriptor type check, and the descriptor-identity check)
|
|
14
|
+
* so the boundary catch can preserve machine-readable specificity instead
|
|
15
|
+
* of collapsing to a generic write code.
|
|
15
16
|
*/
|
|
16
17
|
export declare const SETUP_ERROR_CODES: {
|
|
17
18
|
/** gcloud CLI is not installed or `gcloud --version` fails. */
|
|
@@ -109,7 +110,7 @@ export interface SetupFailure {
|
|
|
109
110
|
/** Builds a structured failure value. */
|
|
110
111
|
export declare function setupFailure(code: SetupErrorCode, message: string): SetupFailure;
|
|
111
112
|
/**
|
|
112
|
-
* Typed internal carrier thrown by the
|
|
113
|
+
* Typed internal carrier thrown by the 16 recoverable path-safety sites.
|
|
113
114
|
*
|
|
114
115
|
* The nearest boundary catch extracts the code when present and falls back
|
|
115
116
|
* to the existing generic code (OUTPUT_WRITE_FAILED / SETUP_STATE_WRITE_FAILED)
|
package/dist/cli/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB;IAC5B,+DAA+D;;IAE/D,6DAA6D;;IAE7D,gGAAgG;;IAEhG,gHAAgH;;IAEhH,mFAAmF;;IAEnF,gFAAgF;;IAEhF,iGAAiG;;IAEjG,0CAA0C;;IAE1C,6DAA6D;;IAE7D,kDAAkD;;IAElD,mEAAmE;;IAEnE,yXAAyX;;IAEzX,mGAAmG;;IAEnG,iGAAiG;;IAEjG,0HAA0H;;IAE1H,oHAAoH;;IAEpH,sGAAsG;;IAEtG,wFAAwF;;IAExF,qFAAqF;;IAErF,0FAA0F;;IAE1F,yFAAyF;;IAEzF,kEAAkE;;IAElE,oDAAoD;;IAEpD,+EAA+E;;IAQ/E,6EAA6E;;IAE7E,6EAA6E;;IAE7E,4EAA4E;;IAE5E,4DAA4D;;IAE5D,4EAA4E;;IAE5E,sEAAsE;;IAEtE,yDAAyD;;IAEzD,sEAAsE;;IAEtE,qEAAqE;;IAErE,qEAAqE;;IAErE,wEAAwE;;IAExE,6EAA6E;;IAE7E,2EAA2E;;IAI3E,sFAAsF;;IAEtF,8EAA8E;;IAE9E,oEAAoE;;CAE5D,CAAC;AAEX,wDAAwD;AACxD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAExF,2CAA2C;AAC3C,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,sCAAsC;AACtC,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,yCAAyC;AACzC,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAEhF;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;gBAClB,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;CAKlD;AAED,gDAAgD;AAChD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAEhG;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAEtE"}
|
package/dist/cli/errors.js
CHANGED
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
* another, and so on; the message carries the specific detail. The 16 path-safety
|
|
9
9
|
* carrier codes (CHECKPOINT_TEMP_*, OUTPUT_*, SETUP_WRITE_NO_PROGRESS,
|
|
10
10
|
* SETUP_DIR_FSYNC_*, SETUP_RENAME_DURABLE_*) are operation-level: 16 distinct
|
|
11
|
-
* codes cover
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* codes cover 16 recoverable path-safety throw sites (OUTPUT_SYMLINK_REFUSED
|
|
12
|
+
* is reused at two sites and OUTPUT_NOT_REGULAR_FILE at three: the lstat
|
|
13
|
+
* boundary, the descriptor type check, and the descriptor-identity check)
|
|
14
|
+
* so the boundary catch can preserve machine-readable specificity instead
|
|
15
|
+
* of collapsing to a generic write code.
|
|
15
16
|
*/
|
|
16
17
|
export const SETUP_ERROR_CODES = {
|
|
17
18
|
/** gcloud CLI is not installed or `gcloud --version` fails. */
|
|
@@ -109,7 +110,7 @@ export function setupFailure(code, message) {
|
|
|
109
110
|
return { code, message };
|
|
110
111
|
}
|
|
111
112
|
/**
|
|
112
|
-
* Typed internal carrier thrown by the
|
|
113
|
+
* Typed internal carrier thrown by the 16 recoverable path-safety sites.
|
|
113
114
|
*
|
|
114
115
|
* The nearest boundary catch extracts the code when present and falls back
|
|
115
116
|
* to the existing generic code (OUTPUT_WRITE_FAILED / SETUP_STATE_WRITE_FAILED)
|
package/dist/cli/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,+DAA+D;IAC/D,cAAc,EAAE,gBAAgB;IAChC,6DAA6D;IAC7D,oBAAoB,EAAE,sBAAsB;IAC5C,gGAAgG;IAChG,4BAA4B,EAAE,8BAA8B;IAC5D,gHAAgH;IAChH,mBAAmB,EAAE,qBAAqB;IAC1C,mFAAmF;IACnF,iBAAiB,EAAE,mBAAmB;IACtC,gFAAgF;IAChF,qBAAqB,EAAE,uBAAuB;IAC9C,iGAAiG;IACjG,iBAAiB,EAAE,mBAAmB;IACtC,0CAA0C;IAC1C,qBAAqB,EAAE,uBAAuB;IAC9C,6DAA6D;IAC7D,iBAAiB,EAAE,mBAAmB;IACtC,kDAAkD;IAClD,gBAAgB,EAAE,kBAAkB;IACpC,mEAAmE;IACnE,iBAAiB,EAAE,mBAAmB;IACtC,yXAAyX;IACzX,oBAAoB,EAAE,sBAAsB;IAC5C,mGAAmG;IACnG,oBAAoB,EAAE,sBAAsB;IAC5C,iGAAiG;IACjG,mBAAmB,EAAE,qBAAqB;IAC1C,0HAA0H;IAC1H,sBAAsB,EAAE,wBAAwB;IAChD,oHAAoH;IACpH,iBAAiB,EAAE,mBAAmB;IACtC,sGAAsG;IACtG,iBAAiB,EAAE,mBAAmB;IACtC,wFAAwF;IACxF,kBAAkB,E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M,UAAU,YAAY,CAAC,IAAoB,EAAE,OAAe;IAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAAiB;IAC9B,YAAY,IAAoB,EAAE,OAAe;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,gDAAgD;AAChD,MAAM,UAAU,oBAAoB,CAAC,IAAoB,EAAE,OAAe;IACxE,OAAO,IAAI,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC"}
|
|
@@ -21,16 +21,33 @@ export type GcloudRunResult = {
|
|
|
21
21
|
readonly stdout: string;
|
|
22
22
|
readonly stderr: string;
|
|
23
23
|
};
|
|
24
|
+
/** Expected device/inode identity of the staging directory at `cwd`. */
|
|
25
|
+
export interface GcloudCwdIdentity {
|
|
26
|
+
readonly dev: number;
|
|
27
|
+
readonly ino: number;
|
|
28
|
+
}
|
|
24
29
|
/** Extra options for one gcloud invocation. */
|
|
25
30
|
export interface GcloudRunOptions {
|
|
26
31
|
/**
|
|
27
|
-
* Working directory of the subprocess.
|
|
28
|
-
* with a RELATIVE `key.json` destination from the
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
+
* Working directory of the subprocess. Only the key create sets it, to
|
|
33
|
+
* run with a RELATIVE `key.json` destination from the staging
|
|
34
|
+
* directory. When `cwdIdentity` and `cwdFd` are present, the runner
|
|
35
|
+
* launches an isolated Node wrapper (`process.execPath`) that `chdir`s
|
|
36
|
+
* into the pathname and verifies `statSync('.')` against the pinned
|
|
37
|
+
* descriptor and expected identity before invoking `gcloud` with no
|
|
38
|
+
* `cwd` option. Pinning the fd prevents inode reuse from validating a
|
|
39
|
+
* replacement. The parent process CWD is never changed. Other callers omit
|
|
40
|
+
* these fields and run
|
|
41
|
+
* `gcloud` directly (see `keyProvision.ts`).
|
|
32
42
|
*/
|
|
33
43
|
readonly cwd?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Expected staging identity captured by `prepareStageDir`. Only
|
|
46
|
+
* meaningful with `cwd`; the key-create call always sets it with `cwdFd`.
|
|
47
|
+
*/
|
|
48
|
+
readonly cwdIdentity?: GcloudCwdIdentity;
|
|
49
|
+
/** Open staging-directory descriptor kept alive through the child launch. */
|
|
50
|
+
readonly cwdFd?: number;
|
|
34
51
|
}
|
|
35
52
|
/** Runs gcloud with the given arguments and returns the process outcome. */
|
|
36
53
|
export interface GcloudRunner {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcloudRunner.d.ts","sourceRoot":"","sources":["../../../../../../src/gcloudRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"gcloudRunner.d.ts","sourceRoot":"","sources":["../../../../../../src/gcloudRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,wCAAwC;AACxC,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAChC;IACA,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAA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,KAAK,IAAI,GAAG,OAAO,CAAC;IAC9E,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC;CACpG;AAED,2FAA2F;AAC3F,MAAM,MAAM,YAAY,GAAG,CACzB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,KACnC,iBAAiB,CAAC;AAEvB,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACnD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,GAAE,YAAkC,GAAG,iBAAiB,CAyB3G;AAWD;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAqCjD"}
|
package/dist/cli/gcloudRunner.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* binary is reported distinctly (`not_found`) from a failed invocation.
|
|
9
9
|
*/
|
|
10
10
|
import { execFile, spawn } from "node:child_process";
|
|
11
|
+
import { randomBytes } from "node:crypto";
|
|
11
12
|
/**
|
|
12
13
|
* Wraps a runner so a throwing invocation becomes a sanitized failed result.
|
|
13
14
|
*
|
|
@@ -100,6 +101,14 @@ function spawnAsLoginSpawner(command, args, options) {
|
|
|
100
101
|
export function createGcloudRunner() {
|
|
101
102
|
return {
|
|
102
103
|
run(args, options) {
|
|
104
|
+
// Only the key create sets the verified CWD fields; every other
|
|
105
|
+
// caller runs gcloud directly below with no wrapper involved.
|
|
106
|
+
if (options?.cwd !== undefined && options.cwdIdentity !== undefined) {
|
|
107
|
+
if (options.cwdFd === undefined) {
|
|
108
|
+
return Promise.resolve({ status: "failed", code: null, stdout: "", stderr: "" });
|
|
109
|
+
}
|
|
110
|
+
return runKeyCreateInVerifiedCwd(args, options.cwd, options.cwdIdentity, options.cwdFd);
|
|
111
|
+
}
|
|
103
112
|
return new Promise((resolve) => {
|
|
104
113
|
execFile(GCLOUD_BINARY, [...args], {
|
|
105
114
|
encoding: "utf8",
|
|
@@ -122,4 +131,163 @@ export function createGcloudRunner() {
|
|
|
122
131
|
},
|
|
123
132
|
};
|
|
124
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Runs one gcloud invocation with its CWD bound to a verified directory
|
|
136
|
+
* object instead of a re-resolved pathname.
|
|
137
|
+
*
|
|
138
|
+
* The parent process CWD is never changed: a small isolated Node child
|
|
139
|
+
* (via `process.execPath`, no shell) `chdir`s into the staging pathname,
|
|
140
|
+
* compares `statSync('.')` with `fstatSync(3)` for the inherited pinned
|
|
141
|
+
* descriptor and the expected identity, then only on an exact match spawns
|
|
142
|
+
* `gcloud` with no `cwd` option so it inherits the wrapper's object-bound
|
|
143
|
+
* directory. A pathname replacement cannot pass by reusing the old inode.
|
|
144
|
+
*
|
|
145
|
+
* Control reporting never parses ordinary gcloud output: the wrapper
|
|
146
|
+
* appends one trailer line carrying a per-call random token
|
|
147
|
+
* (`<token> status=<word>[ code=<n>]`) to its stderr, and the gcloud
|
|
148
|
+
* child is spawned WITHOUT the token in its environment so its own
|
|
149
|
+
* output cannot forge the trailer. stdout is gcloud stdout verbatim;
|
|
150
|
+
* stderr minus the trailer is gcloud stderr verbatim.
|
|
151
|
+
*/
|
|
152
|
+
function runKeyCreateInVerifiedCwd(args, stageDir, expected, stageFd) {
|
|
153
|
+
// Per-call random token so only this invocation's wrapper can report
|
|
154
|
+
// its control statuses; gcloud output cannot guess it (and never
|
|
155
|
+
// receives it via the environment).
|
|
156
|
+
const token = randomBytes(16).toString("hex");
|
|
157
|
+
return new Promise((resolve) => {
|
|
158
|
+
const child = spawn(process.execPath, [
|
|
159
|
+
"-e",
|
|
160
|
+
STAGE_CWD_WRAPPER_SCRIPT,
|
|
161
|
+
stageDir,
|
|
162
|
+
String(expected.dev),
|
|
163
|
+
String(expected.ino),
|
|
164
|
+
JSON.stringify([...args]),
|
|
165
|
+
token,
|
|
166
|
+
], {
|
|
167
|
+
stdio: ["ignore", "pipe", "pipe", stageFd],
|
|
168
|
+
// No `cwd` or `env` override: the wrapper starts in the caller's
|
|
169
|
+
// environment and receives the pinned directory at fd 3.
|
|
170
|
+
});
|
|
171
|
+
let stdout = "";
|
|
172
|
+
let stderr = "";
|
|
173
|
+
let spawnError = null;
|
|
174
|
+
child.stdout?.setEncoding("utf8");
|
|
175
|
+
child.stderr?.setEncoding("utf8");
|
|
176
|
+
child.stdout?.on("data", (chunk) => {
|
|
177
|
+
stdout += chunk;
|
|
178
|
+
});
|
|
179
|
+
child.stderr?.on("data", (chunk) => {
|
|
180
|
+
stderr += chunk;
|
|
181
|
+
});
|
|
182
|
+
child.on("error", (error) => {
|
|
183
|
+
spawnError = error;
|
|
184
|
+
});
|
|
185
|
+
child.on("close", (exitCode) => {
|
|
186
|
+
const parsed = parseStageWrapperTrailer(stderr, token);
|
|
187
|
+
if (parsed === null) {
|
|
188
|
+
// The wrapper crashed or its output was truncated: fail closed
|
|
189
|
+
// with the same shape as a spawn failure. Never report
|
|
190
|
+
// `not_found` here; that status is reserved for the wrapper's
|
|
191
|
+
// explicit gcloud-missing trailer.
|
|
192
|
+
const code = typeof exitCode === "number"
|
|
193
|
+
? exitCode
|
|
194
|
+
: spawnError !== null && typeof spawnError.code === "number"
|
|
195
|
+
? spawnError.code
|
|
196
|
+
: null;
|
|
197
|
+
resolve({ status: "failed", code, stdout, stderr });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const gcloudStderr = stderr.slice(0, parsed.trailerIndex);
|
|
201
|
+
if (parsed.status === "cwd_mismatch" || parsed.status === "wrapper_error") {
|
|
202
|
+
// The pathname did not name the pinned directory when the wrapper
|
|
203
|
+
// bound its CWD: gcloud was never invoked.
|
|
204
|
+
resolve({ status: "failed", code: null, stdout: "", stderr: "" });
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (parsed.status === "not_found") {
|
|
208
|
+
resolve({ status: "not_found" });
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (parsed.status === "spawn_error") {
|
|
212
|
+
resolve({ status: "failed", code: null, stdout, stderr: gcloudStderr });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (parsed.status === "ok") {
|
|
216
|
+
resolve({ status: "ok", stdout, stderr: gcloudStderr });
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
resolve({ status: "failed", code: parsed.code, stdout, stderr: gcloudStderr });
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Finds this call's control trailer in the wrapper stderr.
|
|
225
|
+
*
|
|
226
|
+
* Returns null when the trailer is absent (wrapper crash/truncation).
|
|
227
|
+
* Only the exact random token line is treated as control data; ordinary
|
|
228
|
+
* gcloud output is never parsed.
|
|
229
|
+
*/
|
|
230
|
+
function parseStageWrapperTrailer(stderr, token) {
|
|
231
|
+
const trailerIndex = stderr.lastIndexOf(token);
|
|
232
|
+
if (trailerIndex < 0) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
const trailer = stderr.slice(trailerIndex);
|
|
236
|
+
const match = /^([0-9a-f]+) status=(\S+)(?: code=(\S+))?/.exec(trailer);
|
|
237
|
+
if (match === null || match[1] !== token) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const status = match[2];
|
|
241
|
+
const rawCode = match[3];
|
|
242
|
+
let code = null;
|
|
243
|
+
if (rawCode !== undefined) {
|
|
244
|
+
const numeric = Number(rawCode);
|
|
245
|
+
code = Number.isInteger(numeric) ? numeric : null;
|
|
246
|
+
}
|
|
247
|
+
return { status, code, trailerIndex };
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Isolated wrapper evaluated by the child Node (`node -e`).
|
|
251
|
+
*
|
|
252
|
+
* Uses only portable built-ins (`node:fs`, `node:child_process`): chdir
|
|
253
|
+
* into the staging pathname, compare `statSync('.')` with `fstatSync(3)`
|
|
254
|
+
* and the expected identity, then only on an exact match spawn `gcloud`
|
|
255
|
+
* with no `cwd` option (inheriting the object-bound CWD) and no shell. Control values
|
|
256
|
+
* are passed as wrapper arguments, never added to or removed from the
|
|
257
|
+
* inherited environment; the gcloud child receives the original env.
|
|
258
|
+
* Written without template literals so the outer `node -e` string needs
|
|
259
|
+
* no escaping of nested interpolation.
|
|
260
|
+
*/
|
|
261
|
+
const STAGE_CWD_WRAPPER_SCRIPT = [
|
|
262
|
+
"'use strict';",
|
|
263
|
+
"(() => {",
|
|
264
|
+
"const fs = require('node:fs');",
|
|
265
|
+
"const cp = require('node:child_process');",
|
|
266
|
+
"const [stageDir, rawDev, rawIno, rawArgs, token] = process.argv.slice(1);",
|
|
267
|
+
"const expectedDev = Number(rawDev);",
|
|
268
|
+
"const expectedIno = Number(rawIno);",
|
|
269
|
+
"let gcloudArgs;",
|
|
270
|
+
"try { gcloudArgs = JSON.parse(rawArgs); }",
|
|
271
|
+
"catch (e) { process.stderr.write(token + ' status=wrapper_error\\n'); return; }",
|
|
272
|
+
"if (!Array.isArray(gcloudArgs)) { process.stderr.write(token + ' status=wrapper_error\\n'); return; }",
|
|
273
|
+
"function report(suffix) { process.stderr.write(token + ' status=' + suffix + '\\n'); }",
|
|
274
|
+
"try { process.chdir(stageDir); }",
|
|
275
|
+
"catch (e) { report('cwd_mismatch'); return; }",
|
|
276
|
+
"let st, pinned;",
|
|
277
|
+
"try { st = fs.statSync('.'); pinned = fs.fstatSync(3); }",
|
|
278
|
+
"catch (e) { report('cwd_mismatch'); return; }",
|
|
279
|
+
"if (!st.isDirectory() || !pinned.isDirectory() || pinned.dev !== expectedDev || pinned.ino !== expectedIno || st.dev !== pinned.dev || st.ino !== pinned.ino) { report('cwd_mismatch'); return; }",
|
|
280
|
+
"let result;",
|
|
281
|
+
"try { result = cp.spawnSync('gcloud', gcloudArgs, { encoding: 'utf8', maxBuffer: 1048576 }); }",
|
|
282
|
+
"catch (e) { report('spawn_error'); return; }",
|
|
283
|
+
"if (result.stdout) process.stdout.write(result.stdout);",
|
|
284
|
+
"if (result.stderr) process.stderr.write(result.stderr);",
|
|
285
|
+
"if (result.error) {",
|
|
286
|
+
"if (result.error.code === 'ENOENT') { report('not_found'); return; }",
|
|
287
|
+
"report('spawn_error'); return;",
|
|
288
|
+
"}",
|
|
289
|
+
"if (result.status === 0) { report('ok'); return; }",
|
|
290
|
+
"report('failed code=' + String(result.status));",
|
|
291
|
+
"})();",
|
|
292
|
+
].join("\n");
|
|
125
293
|
//# sourceMappingURL=gcloudRunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcloudRunner.js","sourceRoot":"","sources":["../../../../../../src/gcloudRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"gcloudRunner.js","sourceRoot":"","sources":["../../../../../../src/gcloudRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiD1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAoB;IACnD,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,IAAuB,EAAE,OAA0B;YAC3D,IAAI,CAAC;gBACH,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YAAC,MAAM,CAAC;gBACP,iEAAiE;gBACjE,mDAAmD;gBACnD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAA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