Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(action): propagate artifact stream failures and preserve diagnostics (#1671)

Michael D'Angeloc6d0bf8d78a6
diff --git a/github-action/dist/index.cjs b/github-action/dist/index.cjs
index cf3b9b598..627758fc3 100644
--- a/github-action/dist/index.cjs
+++ b/github-action/dist/index.cjs
@@ -4010,7 +4010,7 @@ var require_webidl = __commonJS({
var require_util2 = __commonJS({
"node_modules/undici/lib/web/fetch/util.js"(exports2, module2) {
"use strict";
- var { Transform: Transform3 } = require("node:stream");
+ var { Transform: Transform4 } = require("node:stream");
var zlib2 = require("node:zlib");
var { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = require_constants3();
var { getGlobalOrigin } = require_global();
@@ -4698,7 +4698,7 @@ var require_util2 = __commonJS({
contentRange += isomorphicEncode(`${fullLength}`);
return contentRange;
}
- var InflateStream = class extends Transform3 {
+ var InflateStream = class extends Transform4 {
#zlibOptions;
/** @param {zlib.ZlibOptions} [zlibOptions] */
constructor(zlibOptions) {
@@ -6794,7 +6794,7 @@ var require_client_h2 = __commonJS({
"node_modules/undici/lib/dispatcher/client-h2.js"(exports2, module2) {
"use strict";
var assert = require("node:assert");
- var { pipeline } = require("node:stream");
+ var { pipeline: pipeline3 } = require("node:stream");
var util3 = require_util();
var {
RequestContentLengthMismatchError,
@@ -7241,7 +7241,7 @@ var require_client_h2 = __commonJS({
}
function writeStream(abort, socket, expectsPayload, h2stream, body2, client2, request2, contentLength2) {
assert(contentLength2 !== 0 || client2[kRunning] === 0, "stream body cannot be pipelined");
- const pipe = pipeline(
+ const pipe = pipeline3(
body2,
h2stream,
(err) => {
@@ -9927,7 +9927,7 @@ var require_api_stream = __commonJS({
"node_modules/undici/lib/api/api-stream.js"(exports2, module2) {
"use strict";
var assert = require("node:assert");
- var { finished, PassThrough: PassThrough3 } = require("node:stream");
+ var { finished, PassThrough: PassThrough2 } = require("node:stream");
var { InvalidArgumentError, InvalidReturnValueError } = require_errors();
var util3 = require_util();
var { getResolveErrorBodyCallback } = require_util3();
@@ -10003,7 +10003,7 @@ var require_api_stream = __commonJS({
if (this.throwOnError && statusCode >= 400) {
const parsedHeaders = responseHeaders === "raw" ? util3.parseHeaders(rawHeaders) : headers;
const contentType2 = parsedHeaders["content-type"];
- res = new PassThrough3();
+ res = new PassThrough2();
this.callback = null;
this.runInAsyncScope(
getResolveErrorBodyCallback,
@@ -10102,7 +10102,7 @@ var require_api_pipeline = __commonJS({
var {
Readable: Readable7,
Duplex,
- PassThrough: PassThrough3
+ PassThrough: PassThrough2
} = require("node:stream");
var {
InvalidArgumentError,
@@ -10282,16 +10282,16 @@ var require_api_pipeline = __commonJS({
util3.destroy(ret, err);
}
};
- function pipeline(opts, handler2) {
+ function pipeline3(opts, handler2) {
try {
const pipelineHandler = new PipelineHandler(opts, handler2);
this.dispatch({ ...opts, body: pipelineHandler.req }, pipelineHandler);
return pipelineHandler.ret;
} catch (err) {
- return new PassThrough3().destroy(err);
+ return new PassThrough2().destroy(err);
}
}
- module2.exports = pipeline;
+ module2.exports = pipeline3;
}
});
@@ -11141,13 +11141,13 @@ var require_pluralizer = __commonJS({
var require_pending_interceptors_formatter = __commonJS({
"node_modules/undici/lib/mock/pending-interceptors-formatter.js"(exports2, module2) {
"use strict";
- var { Transform: Transform3 } = require("node:stream");
+ var { Transform: Transform4 } = require("node:stream");
var { Console } = require("node:console");
var PERSISTENT = process.versions.icu ? "\u2705" : "Y ";
var NOT_PERSISTENT = process.versions.icu ? "\u274C" : "N ";
module2.exports = class PendingInterceptorsFormatter {
constructor({ disableColors } = {}) {
- this.transform = new Transform3({
+ this.transform = new Transform4({
transform(chunk, _enc, cb) {
cb(null, chunk);
}
@@ -13456,7 +13456,7 @@ var require_fetch = __commonJS({
subresourceSet
} = require_constants3();
var EE = require("node:events");
- var { Readable: Readable7, pipeline, finished } = require("node:stream");
+ var { Readable: Readable7, pipeline: pipeline3, finished } = require("node:stream");
var { addAbortListener, isErrored, isReadable, bufferToLowerCasedHeaderName } = require_util();
var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
var { getGlobalDispatcher } = require_global2();
@@ -14400,7 +14400,7 @@ var require_fetch = __commonJS({
status,
statusText,
headersList,
- body: decoders.length ? pipeline(this.body, ...decoders, (err) => {
+ body: decoders.length ? pipeline3(this.body, ...decoders, (err) => {
if (err) {
this.onError(err);
}
@@ -18189,7 +18189,7 @@ var require_util8 = __commonJS({
var require_eventsource_stream = __commonJS({
"node_modules/undici/lib/web/eventsource/eventsource-stream.js"(exports2, module2) {
"use strict";
- var { Transform: Transform3 } = require("node:stream");
+ var { Transform: Transform4 } = require("node:stream");
var { isASCIINumber, isValidLastEventId } = require_util8();
var BOM = [239, 187, 191];
var LF = 10;
@@ -18230,7 +18230,7 @@ var require_eventsource_stream = __commonJS({
}
return true;
}
- var EventSourceStream = class extends Transform3 {
+ var EventSourceStream = class extends Transform4 {
/**
* @type {eventSourceSettings}
*/
@@ -18529,7 +18529,7 @@ ${value}`;
var require_eventsource = __commonJS({
"node_modules/undici/lib/web/eventsource/eventsource.js"(exports2, module2) {
"use strict";
- var { pipeline } = require("node:stream");
+ var { pipeline: pipeline3 } = require("node:stream");
var { fetching } = require_fetch();
var { makeRequest } = require_request2();
var { webidl } = require_webidl();
@@ -18687,7 +18687,7 @@ var require_eventsource = __commonJS({
));
}
});
- pipeline(
+ pipeline3(
response.body.stream,
eventSourceStream,
(error2) => {
@@ -30222,11 +30222,11 @@ var require_stream_readable = __commonJS({
var require_stream_transform = __commonJS({
"node_modules/lazystream/node_modules/readable-stream/lib/_stream_transform.js"(exports2, module2) {
"use strict";
- module2.exports = Transform3;
+ module2.exports = Transform4;
var Duplex = require_stream_duplex();
var util3 = Object.create(require_util9());
util3.inherits = require_inherits();
- util3.inherits(Transform3, Duplex);
+ util3.inherits(Transform4, Duplex);
function afterTransform(er, data) {
var ts = this._transformState;
ts.transforming = false;
@@ -30245,8 +30245,8 @@ var require_stream_transform = __commonJS({
this._read(rs.highWaterMark);
}
}
- function Transform3(options) {
- if (!(this instanceof Transform3)) return new Transform3(options);
+ function Transform4(options) {
+ if (!(this instanceof Transform4)) return new Transform4(options);
Duplex.call(this, options);
this._transformState = {
afterTransform: afterTransform.bind(this),
@@ -30274,14 +30274,14 @@ var require_stream_transform = __commonJS({
done(this, null, null);
}
}
- Transform3.prototype.push = function(chunk, encoding) {
+ Transform4.prototype.push = function(chunk, encoding) {
this._transformState.needTransform = false;
return Duplex.prototype.push.call(this, chunk, encoding);
};
- Transform3.prototype._transform = function(chunk, encoding, cb) {
+ Transform4.prototype._transform = function(chunk, encoding, cb) {
throw new Error("_transform() is not implemented");
};
- Transform3.prototype._write = function(chunk, encoding, cb) {
+ Transform4.prototype._write = function(chunk, encoding, cb) {
var ts = this._transformState;
ts.writecb = cb;
ts.writechunk = chunk;
@@ -30291,7 +30291,7 @@ var require_stream_transform = __commonJS({
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
}
};
- Transform3.prototype._read = function(n) {
+ Transform4.prototype._read = function(n) {
var ts = this._transformState;
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
ts.transforming = true;
@@ -30300,7 +30300,7 @@ var require_stream_transform = __commonJS({
ts.needTransform = true;
}
};
- Transform3.prototype._destroy = function(err, cb) {
+ Transform4.prototype._destroy = function(err, cb) {
var _this2 = this;
Duplex.prototype._destroy.call(this, err, function(err2) {
cb(err2);
@@ -30322,16 +30322,16 @@ var require_stream_transform = __commonJS({
var require_stream_passthrough = __commonJS({
"node_modules/lazystream/node_modules/readable-stream/lib/_stream_passthrough.js"(exports2, module2) {
"use strict";
- module2.exports = PassThrough3;
- var Transform3 = require_stream_transform();
+ module2.exports = PassThrough2;
+ var Transform4 = require_stream_transform();
var util3 = Object.create(require_util9());
util3.inherits = require_inherits();
- util3.inherits(PassThrough3, Transform3);
- function PassThrough3(options) {
- if (!(this instanceof PassThrough3)) return new PassThrough3(options);
- Transform3.call(this, options);
+ util3.inherits(PassThrough2, Transform4);
+ function PassThrough2(options) {
+ if (!(this instanceof PassThrough2)) return new PassThrough2(options);
+ Transform4.call(this, options);
}
- PassThrough3.prototype._transform = function(chunk, encoding, cb) {
+ PassThrough2.prototype._transform = function(chunk, encoding, cb) {
cb(null, chunk);
};
}
@@ -30373,13 +30373,13 @@ var require_passthrough = __commonJS({
var require_lazystream = __commonJS({
"node_modules/lazystream/lib/lazystream.js"(exports2, module2) {
var util3 = require("util");
- var PassThrough3 = require_passthrough();
+ var PassThrough2 = require_passthrough();
module2.exports = {
Readable: Readable7,
Writable
};
- util3.inherits(Readable7, PassThrough3);
- util3.inherits(Writable, PassThrough3);
+ util3.inherits(Readable7, PassThrough2);
+ util3.inherits(Writable, PassThrough2);
function beforeFirstCall(instance, method, callback) {
instance[method] = function() {
delete instance[method];
@@ -30390,7 +30390,7 @@ var require_lazystream = __commonJS({
function Readable7(fn, options) {
if (!(this instanceof Readable7))
return new Readable7(fn, options);
- PassThrough3.call(this, options);
+ PassThrough2.call(this, options);
beforeFirstCall(this, "_read", function() {
var source = fn.call(this, options);
var emit = this.emit.bind(this, "error");
@@ -30402,7 +30402,7 @@ var require_lazystream = __commonJS({
function Writable(fn, options) {
if (!(this instanceof Writable))
return new Writable(fn, options);
- PassThrough3.call(this, options);
+ PassThrough2.call(this, options);
beforeFirstCall(this, "_write", function() {
var destination = fn.call(this, options);
var emit = this.emit.bind(this, "error");
@@ -31602,9 +31602,9 @@ var require_errors2 = __commonJS({
"ERR_MISSING_ARGS",
(...args) => {
assert(args.length > 0, "At least one arg needs to be specified");
- let msg;
+ let msg = "";
const len = args.length;
- args = (Array.isArray(args) ? args : [args]).map((a) => `"${a}"`).join(" or ");
+ args = (Array.isArray(args) ? args : [args]).map((a) => `"${a}"`);
switch (len) {
case 1:
msg += `The ${args[0]} argument`;
@@ -36241,15 +36241,15 @@ var require_transform = __commonJS({
"node_modules/readable-stream/lib/internal/streams/transform.js"(exports2, module2) {
"use strict";
var { ObjectSetPrototypeOf, Symbol: Symbol2 } = require_primordials();
- module2.exports = Transform3;
+ module2.exports = Transform4;
var { ERR_METHOD_NOT_IMPLEMENTED } = require_errors2().codes;
var Duplex = require_duplex();
var { getHighWaterMark } = require_state();
- ObjectSetPrototypeOf(Transform3.prototype, Duplex.prototype);
- ObjectSetPrototypeOf(Transform3, Duplex);
+ ObjectSetPrototypeOf(Transform4.prototype, Duplex.prototype);
+ ObjectSetPrototypeOf(Transform4, Duplex);
var kCallback = Symbol2("kCallback");
- function Transform3(options) {
- if (!(this instanceof Transform3)) return new Transform3(options);
+ function Transform4(options) {
+ if (!(this instanceof Transform4)) return new Transform4(options);
const readableHighWaterMark = options ? getHighWaterMark(this, options, "readableHighWaterMark", true) : null;
if (readableHighWaterMark === 0) {
options = {
@@ -36303,11 +36303,11 @@ var require_transform = __commonJS({
final.call(this);
}
}
- Transform3.prototype._final = final;
- Transform3.prototype._transform = function(chunk, encoding, callback) {
+ Transform4.prototype._final = final;
+ Transform4.prototype._transform = function(chunk, encoding, callback) {
throw new ERR_METHOD_NOT_IMPLEMENTED("_transform()");
};
- Transform3.prototype._write = function(chunk, encoding, callback) {
+ Transform4.prototype._write = function(chunk, encoding, callback) {
const rState = this._readableState;
const wState = this._writableState;
const length = rState.length;
@@ -36328,7 +36328,7 @@ var require_transform = __commonJS({
}
});
};
- Transform3.prototype._read = function() {
+ Transform4.prototype._read = function() {
if (this[kCallback]) {
const callback = this[kCallback];
this[kCallback] = null;
@@ -36343,15 +36343,15 @@ var require_passthrough2 = __commonJS({
"node_modules/readable-stream/lib/internal/streams/passthrough.js"(exports2, module2) {
"use strict";
var { ObjectSetPrototypeOf } = require_primordials();
- module2.exports = PassThrough3;
- var Transform3 = require_transform();
- ObjectSetPrototypeOf(PassThrough3.prototype, Transform3.prototype);
- ObjectSetPrototypeOf(PassThrough3, Transform3);
- function PassThrough3(options) {
- if (!(this instanceof PassThrough3)) return new PassThrough3(options);
- Transform3.call(this, options);
- }
- PassThrough3.prototype._transform = function(chunk, encoding, cb) {
+ module2.exports = PassThrough2;
+ var Transform4 = require_transform();
+ ObjectSetPrototypeOf(PassThrough2.prototype, Transform4.prototype);
+ ObjectSetPrototypeOf(PassThrough2, Transform4);
+ function PassThrough2(options) {
+ if (!(this instanceof PassThrough2)) return new PassThrough2(options);
+ Transform4.call(this, options);
+ }
+ PassThrough2.prototype._transform = function(chunk, encoding, cb) {
cb(null, chunk);
};
}
@@ -36389,7 +36389,7 @@ var require_pipeline = __commonJS({
isReadableFinished
} = require_utils2();
var AbortController2 = globalThis.AbortController || require_abort_controller().AbortController;
- var PassThrough3;
+ var PassThrough2;
var Readable7;
var addAbortListener;
function destroyer(stream4, reading, writing) {
@@ -36514,7 +36514,7 @@ var require_pipeline = __commonJS({
}
}
}
- function pipeline(...streams) {
+ function pipeline3(...streams) {
return pipelineImpl(streams, once(popCallback(streams)));
}
function pipelineImpl(streams, callback, opts) {
@@ -36622,10 +36622,10 @@ var require_pipeline = __commonJS({
}
} else {
var _ret2;
- if (!PassThrough3) {
- PassThrough3 = require_passthrough2();
+ if (!PassThrough2) {
+ PassThrough2 = require_passthrough2();
}
- const pt = new PassThrough3({
+ const pt = new PassThrough2({
objectMode: true
});
const then = (_ret2 = ret) === null || _ret2 === void 0 ? void 0 : _ret2.then;
@@ -36780,7 +36780,7 @@ var require_pipeline = __commonJS({
}
module2.exports = {
pipelineImpl,
- pipeline
+ pipeline: pipeline3
};
}
});
@@ -36789,7 +36789,7 @@ var require_pipeline = __commonJS({
var require_compose = __commonJS({
"node_modules/readable-stream/lib/internal/streams/compose.js"(exports2, module2) {
"use strict";
- var { pipeline } = require_pipeline();
+ var { pipeline: pipeline3 } = require_pipeline();
var Duplex = require_duplex();
var { destroyer } = require_destroy2();
var {
@@ -36849,7 +36849,7 @@ var require_compose = __commonJS({
}
}
const head = streams[0];
- const tail = pipeline(streams, onfinished);
+ const tail = pipeline3(streams, onfinished);
const writable = !!(isWritable(head) || isWritableStream(head) || isTransformStream(head));
const readable = !!(isReadable(tail) || isReadableStream3(tail) || isTransformStream(tail));
d = new Duplex({
@@ -37392,7 +37392,7 @@ var require_promises = __commonJS({
var { pipelineImpl: pl } = require_pipeline();
var { finished } = require_end_of_stream();
require_stream2();
- function pipeline(...streams) {
+ function pipeline3(...streams) {
return new Promise2((resolve7, reject) => {
let signal;
let end;
@@ -37420,7 +37420,7 @@ var require_promises = __commonJS({
}
module2.exports = {
finished,
- pipeline
+ pipeline: pipeline3
};
}
});
@@ -37440,7 +37440,7 @@ var require_stream2 = __commonJS({
} = require_errors2();
var compose = require_compose();
var { setDefaultHighWaterMark, getDefaultHighWaterMark } = require_state();
- var { pipeline } = require_pipeline();
+ var { pipeline: pipeline3 } = require_pipeline();
var { destroyer } = require_destroy2();
var eos = require_end_of_stream();
var promises4 = require_promises();
@@ -37504,7 +37504,7 @@ var require_stream2 = __commonJS({
Stream2.Duplex = require_duplex();
Stream2.Transform = require_transform();
Stream2.PassThrough = require_passthrough2();
- Stream2.pipeline = pipeline;
+ Stream2.pipeline = pipeline3;
var { addAbortSignal } = require_add_abort_signal();
Stream2.addAbortSignal = addAbortSignal;
Stream2.finished = eos;
@@ -37520,7 +37520,7 @@ var require_stream2 = __commonJS({
return promises4;
}
});
- ObjectDefineProperty(pipeline, customPromisify, {
+ ObjectDefineProperty(pipeline3, customPromisify, {
__proto__: null,
enumerable: true,
get() {
@@ -45384,7 +45384,7 @@ var require_archiver_utils = __commonJS({
var normalizePath = require_normalize_path();
var defaults2 = require_defaults();
var Stream2 = require("stream").Stream;
- var PassThrough3 = require_ours().PassThrough;
+ var PassThrough2 = require_ours().PassThrough;
var utils = module2.exports = {};
utils.file = require_file2();
utils.collectStream = function(source, callback) {
@@ -45435,7 +45435,7 @@ var require_archiver_utils = __commonJS({
} else if (typeof source === "string") {
return Buffer.from(source);
} else if (utils.isStream(source)) {
- return source.pipe(new PassThrough3());
+ return source.pipe(new PassThrough2());
}
return source;
};
@@ -45536,7 +45536,7 @@ var require_core = __commonJS({
var util3 = require_archiver_utils();
var inherits = require("util").inherits;
var ArchiverError = require_error();
- var Transform3 = require_ours().Transform;
+ var Transform4 = require_ours().Transform;
var win32 = process.platform === "win32";
var Archiver = function(format, options) {
if (!(this instanceof Archiver)) {
@@ -45550,7 +45550,7 @@ var require_core = __commonJS({
highWaterMark: 1024 * 1024,
statConcurrency: 4
});
- Transform3.call(this, options);
+ Transform4.call(this, options);
this._format = false;
this._module = false;
this._pending = 0;
@@ -45572,7 +45572,7 @@ var require_core = __commonJS({
};
this._streams = [];
};
- inherits(Archiver, Transform3);
+ inherits(Archiver, Transform4);
Archiver.prototype._abort = function() {
this._state.aborted = true;
this._queue.kill();
@@ -46518,7 +46518,7 @@ var require_zip_archive_entry = __commonJS({
var require_util12 = __commonJS({
"node_modules/compress-commons/lib/util/index.js"(exports2, module2) {
var Stream2 = require("stream").Stream;
- var PassThrough3 = require_ours().PassThrough;
+ var PassThrough2 = require_ours().PassThrough;
var isStream = require_is_stream();
var util3 = module2.exports = {};
util3.normalizeInputSource = function(source) {
@@ -46527,7 +46527,7 @@ var require_util12 = __commonJS({
} else if (typeof source === "string") {
return Buffer.from(source);
} else if (isStream(source) && !source._readableState) {
- var normalized = new PassThrough3();
+ var normalized = new PassThrough2();
source.pipe(normalized);
return normalized;
}
@@ -46541,14 +46541,14 @@ var require_archive_output_stream = __commonJS({
"node_modules/compress-commons/lib/archivers/archive-output-stream.js"(exports2, module2) {
var inherits = require("util").inherits;
var isStream = require_is_stream();
- var Transform3 = require_ours().Transform;
+ var Transform4 = require_ours().Transform;
var ArchiveEntry = require_archive_entry();
var util3 = require_util12();
var ArchiveOutputStream = module2.exports = function(options) {
if (!(this instanceof ArchiveOutputStream)) {
return new ArchiveOutputStream(options);
}
- Transform3.call(this, options);
+ Transform4.call(this, options);
this.offset = 0;
this._archive = {
finish: false,
@@ -46556,7 +46556,7 @@ var require_archive_output_stream = __commonJS({
processing: false
};
};
- inherits(ArchiveOutputStream, Transform3);
+ inherits(ArchiveOutputStream, Transform4);
ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) {
};
ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) {
@@ -46619,7 +46619,7 @@ var require_archive_output_stream = __commonJS({
if (chunk) {
this.offset += chunk.length;
}
- return Transform3.prototype.write.call(this, chunk, cb);
+ return Transform4.prototype.write.call(this, chunk, cb);
};
}
});
@@ -46726,9 +46726,9 @@ var require_crc32 = __commonJS({
var require_crc32_stream = __commonJS({
"node_modules/crc32-stream/lib/crc32-stream.js"(exports2, module2) {
"use strict";
- var { Transform: Transform3 } = require_ours();
+ var { Transform: Transform4 } = require_ours();
var crc32 = require_crc32();
- var CRC32Stream = class extends Transform3 {
+ var CRC32Stream = class extends Transform4 {
constructor(options) {
super(options);
this.checksum = Buffer.allocUnsafe(4);
@@ -48394,11 +48394,11 @@ var require_streamx = __commonJS({
}
}
static deferred(fn, opts) {
- const out = new PassThrough3(opts);
+ const out = new PassThrough2(opts);
fn().then((src) => {
if (src === null) return out.end();
if (out.destroying) return;
- pipeline(src, out, noop3);
+ pipeline3(src, out, noop3);
}).catch((err) => out.destroy(err));
return out;
}
@@ -48630,7 +48630,7 @@ var require_streamx = __commonJS({
return this;
}
};
- var Transform3 = class extends Duplex {
+ var Transform4 = class extends Duplex {
constructor(opts) {
super(opts);
this._transformState = new TransformState(this);
@@ -48674,7 +48674,7 @@ var require_streamx = __commonJS({
this._flush(transformAfterFlush.bind(this));
}
};
- var PassThrough3 = class extends Transform3 {
+ var PassThrough2 = class extends Transform4 {
};
function transformAfterFlush(err, data) {
const cb = this._transformState.afterFinal;
@@ -48685,13 +48685,13 @@ var require_streamx = __commonJS({
}
function pipelinePromise(...streams) {
return new Promise((resolve7, reject) => {
- return pipeline(...streams, (err) => {
+ return pipeline3(...streams, (err) => {
if (err) return reject(err);
resolve7();
});
});
}
- function pipeline(stream4, ...streams) {
+ function pipeline3(stream4, ...streams) {
const all = Array.isArray(stream4) ? [...stream4, ...streams] : [stream4, ...streams];
const done = all.length && typeof all[all.length - 1] === "function" ? all.pop() : null;
if (all.length < 2) throw StreamError.BAD_ARGUMENT("Pipeline requires at least 2 streams");
@@ -48789,7 +48789,7 @@ var require_streamx = __commonJS({
return s._writev !== Writable.prototype._writev && s._writev !== Duplex.prototype._writev;
}
module2.exports = {
- pipeline,
+ pipeline: pipeline3,
pipelinePromise,
isStream,
isStreamx,
@@ -48803,9 +48803,9 @@ var require_streamx = __commonJS({
Writable,
Readable: Readable7,
Duplex,
- Transform: Transform3,
+ Transform: Transform4,
// Export PassThrough for compatibility with Node.js core's stream module
- PassThrough: PassThrough3
+ PassThrough: PassThrough2
};
}
});
@@ -50068,7 +50068,7 @@ var require_dist4 = __commonJS({
var require_json = __commonJS({
"node_modules/archiver/lib/plugins/json.js"(exports2, module2) {
var inherits = require("util").inherits;
- var Transform3 = require_ours().Transform;
+ var Transform4 = require_ours().Transform;
var crc32 = require_dist4();
var util3 = require_archiver_utils();
var Json = function(options) {
@@ -50076,14 +50076,14 @@ var require_json = __commonJS({
return new Json(options);
}
options = this.options = util3.defaults(options, {});
- Transform3.call(this, options);
+ Transform4.call(this, options);
this.supports = {
directory: true,
symlink: true
};
this.files = [];
};
- inherits(Json, Transform3);
+ inherits(Json, Transform4);
Json.prototype._transform = function(chunk, encoding, callback) {
callback(null, chunk);
};
@@ -51884,13 +51884,13 @@ var require_binary = __commonJS({
// node_modules/unzip-stream/lib/matcher-stream.js
var require_matcher_stream = __commonJS({
"node_modules/unzip-stream/lib/matcher-stream.js"(exports2, module2) {
- var Transform3 = require("stream").Transform;
+ var Transform4 = require("stream").Transform;
var util3 = require("util");
function MatcherStream(patternDesc, matchFn) {
if (!(this instanceof MatcherStream)) {
return new MatcherStream();
}
- Transform3.call(this);
+ Transform4.call(this);
var p = typeof patternDesc === "object" ? patternDesc.pattern : patternDesc;
this.pattern = Buffer.isBuffer(p) ? p : Buffer.from(p);
this.requiredLength = this.pattern.length;
@@ -51899,7 +51899,7 @@ var require_matcher_stream = __commonJS({
this.bytesSoFar = 0;
this.matchFn = matchFn;
}
- util3.inherits(MatcherStream, Transform3);
+ util3.inherits(MatcherStream, Transform4);
MatcherStream.prototype.checkDataChunk = function(ignoreMatchZero) {
var enoughData = this.data.length >= this.requiredLength;
if (!enoughData) {
@@ -52579,7 +52579,7 @@ var require_unzip_stream = __commonJS({
// node_modules/unzip-stream/lib/parser-stream.js
var require_parser_stream = __commonJS({
"node_modules/unzip-stream/lib/parser-stream.js"(exports2, module2) {
- var Transform3 = require("stream").Transform;
+ var Transform4 = require("stream").Transform;
var util3 = require("util");
var UnzipStream = require_unzip_stream();
function ParserStream(opts) {
@@ -52587,7 +52587,7 @@ var require_parser_stream = __commonJS({
return new ParserStream(opts);
}
var transformOpts = opts || {};
- Transform3.call(this, { readableObjectMode: true });
+ Transform4.call(this, { readableObjectMode: true });
this.opts = opts || {};
this.unzipStream = new UnzipStream(this.opts);
var self2 = this;
@@ -52598,7 +52598,7 @@ var require_parser_stream = __commonJS({
self2.emit("error", error2);
});
}
- util3.inherits(ParserStream, Transform3);
+ util3.inherits(ParserStream, Transform4);
ParserStream.prototype._transform = function(chunk, encoding, cb) {
this.unzipStream.write(chunk, encoding, cb);
};
@@ -52613,13 +52613,13 @@ var require_parser_stream = __commonJS({
};
ParserStream.prototype.on = function(eventName, fn) {
if (eventName === "entry") {
- return Transform3.prototype.on.call(this, "data", fn);
+ return Transform4.prototype.on.call(this, "data", fn);
}
- return Transform3.prototype.on.call(this, eventName, fn);
+ return Transform4.prototype.on.call(this, eventName, fn);
};
ParserStream.prototype.drainAll = function() {
this.unzipStream.drainAll();
- return this.pipe(new Transform3({ objectMode: true, transform: function(d, e, cb) {
+ return this.pipe(new Transform4({ objectMode: true, transform: function(d, e, cb) {
cb();
} }));
};
@@ -52722,12 +52722,12 @@ var require_extract2 = __commonJS({
var path6 = require("path");
var util3 = require("util");
var mkdirp = require_mkdirp();
- var Transform3 = require("stream").Transform;
+ var Transform4 = require("stream").Transform;
var UnzipStream = require_unzip_stream();
function Extract(opts) {
if (!(this instanceof Extract))
return new Extract(opts);
- Transform3.call(this);
+ Transform4.call(this);
this.opts = opts || {};
this.unzipStream = new UnzipStream(this.opts);
this.unfinishedEntries = 0;
@@ -52739,7 +52739,7 @@ var require_extract2 = __commonJS({
self2.emit("error", error2);
});
}
- util3.inherits(Extract, Transform3);
+ util3.inherits(Extract, Transform4);
Extract.prototype._transform = function(chunk, encoding, cb) {
this.unzipStream.write(chunk, encoding, cb);
};
@@ -55550,7 +55550,7 @@ function saveState(name, value) {
}
// src/main.ts
-var import_promises9 = require("node:fs/promises");
+var import_promises10 = require("node:fs/promises");
// src/inputs.ts
function parseInputs(read, workspace) {
@@ -58859,12 +58859,12 @@ var HttpPipeline = class _HttpPipeline {
}
sendRequest(httpClient2, request2) {
const policies = this.getOrderedPolicies();
- const pipeline = policies.reduceRight((next, policy) => {
+ const pipeline3 = policies.reduceRight((next, policy) => {
return (req) => {
return policy.sendRequest(req, next);
};
}, (req) => httpClient2.sendRequest(req));
- return pipeline(request2);
+ return pipeline3(request2);
}
getOrderedPolicies() {
if (!this._orderedPolicies) {
@@ -60824,31 +60824,31 @@ function wrapAbortSignalLikePolicy() {
// node_modules/@azure/core-rest-pipeline/dist/esm/createPipelineFromOptions.js
function createPipelineFromOptions2(options) {
- const pipeline = createEmptyPipeline2();
+ const pipeline3 = createEmptyPipeline2();
if (isNodeLike2) {
if (options.agent) {
- pipeline.addPolicy(agentPolicy2(options.agent));
+ pipeline3.addPolicy(agentPolicy2(options.agent));
}
if (options.tlsOptions) {
- pipeline.addPolicy(tlsPolicy2(options.tlsOptions));
- }
- pipeline.addPolicy(proxyPolicy2(options.proxyOptions));
- pipeline.addPolicy(decompressResponsePolicy2());
- }
- pipeline.addPolicy(wrapAbortSignalLikePolicy());
- pipeline.addPolicy(formDataPolicy2(), { beforePolicies: [multipartPolicyName2] });
- pipeline.addPolicy(userAgentPolicy2(options.userAgentOptions));
- pipeline.addPolicy(setClientRequestIdPolicy(options.telemetryOptions?.clientRequestIdHeaderName));
- pipeline.addPolicy(multipartPolicy2(), { afterPhase: "Deserialize" });
- pipeline.addPolicy(defaultRetryPolicy2(options.retryOptions), { phase: "Retry" });
- pipeline.addPolicy(tracingPolicy({ ...options.userAgentOptions, ...options.loggingOptions }), {
+ pipeline3.addPolicy(tlsPolicy2(options.tlsOptions));
+ }
+ pipeline3.addPolicy(proxyPolicy2(options.proxyOptions));
+ pipeline3.addPolicy(decompressResponsePolicy2());
+ }
+ pipeline3.addPolicy(wrapAbortSignalLikePolicy());
+ pipeline3.addPolicy(formDataPolicy2(), { beforePolicies: [multipartPolicyName2] });
+ pipeline3.addPolicy(userAgentPolicy2(options.userAgentOptions));
+ pipeline3.addPolicy(setClientRequestIdPolicy(options.telemetryOptions?.clientRequestIdHeaderName));
+ pipeline3.addPolicy(multipartPolicy2(), { afterPhase: "Deserialize" });
+ pipeline3.addPolicy(defaultRetryPolicy2(options.retryOptions), { phase: "Retry" });
+ pipeline3.addPolicy(tracingPolicy({ ...options.userAgentOptions, ...options.loggingOptions }), {
afterPhase: "Retry"
});
if (isNodeLike2) {
- pipeline.addPolicy(redirectPolicy2(options.redirectOptions), { afterPhase: "Retry" });
+ pipeline3.addPolicy(redirectPolicy2(options.redirectOptions), { afterPhase: "Retry" });
}
- pipeline.addPolicy(logPolicy2(options.loggingOptions), { afterPhase: "Sign" });
- return pipeline;
+ pipeline3.addPolicy(logPolicy2(options.loggingOptions), { afterPhase: "Sign" });
+ return pipeline3;
}
// node_modules/@azure/core-rest-pipeline/dist/esm/defaultHttpClient.js
@@ -61175,8 +61175,8 @@ function createDisableKeepAlivePolicy() {
}
};
}
-function pipelineContainsDisableKeepAlivePolicy(pipeline) {
- return pipeline.getOrderedPolicies().some((policy) => policy.name === disableKeepAlivePolicyName);
+function pipelineContainsDisableKeepAlivePolicy(pipeline3) {
+ return pipeline3.getOrderedPolicies().some((policy) => policy.name === disableKeepAlivePolicyName);
}
// node_modules/@azure/core-client/dist/esm/base64.js
@@ -62431,18 +62431,18 @@ function prepareXMLRootList(obj, elementName, xmlNamespaceKey, xmlNamespace) {
// node_modules/@azure/core-client/dist/esm/pipeline.js
function createClientPipeline(options = {}) {
- const pipeline = createPipelineFromOptions2(options ?? {});
+ const pipeline3 = createPipelineFromOptions2(options ?? {});
if (options.credentialOptions) {
- pipeline.addPolicy(bearerTokenAuthenticationPolicy({
+ pipeline3.addPolicy(bearerTokenAuthenticationPolicy({
credential: options.credentialOptions.credential,
scopes: options.credentialOptions.credentialScopes
}));
}
- pipeline.addPolicy(serializationPolicy(options.serializationOptions), { phase: "Serialize" });
- pipeline.addPolicy(deserializationPolicy(options.deserializationOptions), {
+ pipeline3.addPolicy(serializationPolicy(options.serializationOptions), { phase: "Serialize" });
+ pipeline3.addPolicy(deserializationPolicy(options.deserializationOptions), {
phase: "Deserialize"
});
- return pipeline;
+ return pipeline3;
}
// node_modules/@azure/core-client/dist/esm/httpClientCache.js
@@ -72891,11 +72891,11 @@ var PathStylePorts2 = [
];
// node_modules/@azure/storage-blob/dist/esm/Pipeline.js
-function isPipelineLike(pipeline) {
- if (!pipeline || typeof pipeline !== "object") {
+function isPipelineLike(pipeline3) {
+ if (!pipeline3 || typeof pipeline3 !== "object") {
return false;
}
- const castPipeline = pipeline;
+ const castPipeline = pipeline3;
return Array.isArray(castPipeline.factories) && typeof castPipeline.options === "object" && typeof castPipeline.toServiceClientOptions === "function";
}
var Pipeline = class {
@@ -72934,11 +72934,11 @@ function newPipeline(credential, pipelineOptions = {}) {
if (!credential) {
credential = new AnonymousCredential();
}
- const pipeline = new Pipeline([], pipelineOptions);
- pipeline._credential = credential;
- return pipeline;
+ const pipeline3 = new Pipeline([], pipelineOptions);
+ pipeline3._credential = credential;
+ return pipeline3;
}
-function processDownlevelPipeline(pipeline) {
+function processDownlevelPipeline(pipeline3) {
const knownFactoryFunctions = [
isAnonymousCredential,
isStorageSharedKeyCredential,
@@ -72948,8 +72948,8 @@ function processDownlevelPipeline(pipeline) {
isStorageTelemetryPolicyFactory,
isCoreHttpPolicyFactory
];
- if (pipeline.factories.length) {
- const novelFactories = pipeline.factories.filter((factory) => {
+ if (pipeline3.factories.length) {
+ const novelFactories = pipeline3.factories.filter((factory) => {
return !knownFactoryFunctions.some((knownFactory) => knownFactory(factory));
});
if (novelFactories.length) {
@@ -72962,14 +72962,14 @@ function processDownlevelPipeline(pipeline) {
}
return void 0;
}
-function getCoreClientOptions(pipeline) {
- const { httpClient: v1Client, ...restOptions } = pipeline.options;
- let httpClient2 = pipeline._coreHttpClient;
+function getCoreClientOptions(pipeline3) {
+ const { httpClient: v1Client, ...restOptions } = pipeline3.options;
+ let httpClient2 = pipeline3._coreHttpClient;
if (!httpClient2) {
httpClient2 = v1Client ? convertHttpClient(v1Client) : getCachedDefaultHttpClient2();
- pipeline._coreHttpClient = httpClient2;
+ pipeline3._coreHttpClient = httpClient2;
}
- let corePipeline = pipeline._corePipeline;
+ let corePipeline = pipeline3._corePipeline;
if (!corePipeline) {
const packageDetails = `azsdk-js-azure-storage-blob/${SDK_VERSION3}`;
const userAgentPrefix = restOptions.userAgentOptions && restOptions.userAgentOptions.userAgentPrefix ? `${restOptions.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`;
@@ -73010,11 +73010,11 @@ function getCoreClientOptions(pipeline) {
corePipeline.addPolicy(storageRetryPolicy(restOptions.retryOptions), { phase: "Retry" });
corePipeline.addPolicy(storageRequestFailureDetailsParserPolicy());
corePipeline.addPolicy(storageBrowserPolicy());
- const downlevelResults = processDownlevelPipeline(pipeline);
+ const downlevelResults = processDownlevelPipeline(pipeline3);
if (downlevelResults) {
corePipeline.addPolicy(downlevelResults.wrappedPolicies, downlevelResults.afterRetry ? { afterPhase: "Retry" } : void 0);
}
- const credential = getCredentialFromPipeline(pipeline);
+ const credential = getCredentialFromPipeline(pipeline3);
if (isTokenCredential(credential)) {
corePipeline.addPolicy(bearerTokenAuthenticationPolicy({
credential,
@@ -73027,7 +73027,7 @@ function getCoreClientOptions(pipeline) {
accountKey: credential.accountKey
}), { phase: "Sign" });
}
- pipeline._corePipeline = corePipeline;
+ pipeline3._corePipeline = corePipeline;
}
return {
...restOptions,
@@ -73036,12 +73036,12 @@ function getCoreClientOptions(pipeline) {
pipeline: corePipeline
};
}
-function getCredentialFromPipeline(pipeline) {
- if (pipeline._credential) {
- return pipeline._credential;
+function getCredentialFromPipeline(pipeline3) {
+ if (pipeline3._credential) {
+ return pipeline3._credential;
}
let credential = new AnonymousCredential();
- for (const factory of pipeline.factories) {
+ for (const factory of pipeline3.factories) {
if (isTokenCredential(factory.credential)) {
credential = factory.credential;
} else if (isStorageSharedKeyCredential(factory)) {
@@ -87183,13 +87183,13 @@ var StorageClient2 = class {
* @param url - url to resource
* @param pipeline - request policy pipeline.
*/
- constructor(url2, pipeline) {
+ constructor(url2, pipeline3) {
this.url = escapeURLPath(url2);
this.accountName = getAccountNameFromUrl(url2);
- this.pipeline = pipeline;
- this.storageClientContext = new StorageContextClient(this.url, getCoreClientOptions(pipeline));
+ this.pipeline = pipeline3;
+ this.storageClientContext = new StorageContextClient(this.url, getCoreClientOptions(pipeline3));
this.isHttps = iEqual(getURLScheme(this.url) || "", "https");
- this.credential = getCredentialFromPipeline(pipeline);
+ this.credential = getCredentialFromPipeline(pipeline3);
const storageClientContext = this.storageClientContext;
storageClientContext.requestContentType = void 0;
}
@@ -91047,22 +91047,22 @@ var BlobClient = class _BlobClient extends StorageClient2 {
}
constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, options) {
options = options || {};
- let pipeline;
+ let pipeline3;
let url2;
if (isPipelineLike(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
- pipeline = credentialOrPipelineOrContainerName;
+ pipeline3 = credentialOrPipelineOrContainerName;
options = blobNameOrOptions;
} else if (isNodeLike2 && credentialOrPipelineOrContainerName instanceof StorageSharedKeyCredential || credentialOrPipelineOrContainerName instanceof AnonymousCredential || isTokenCredential(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
options = blobNameOrOptions;
- pipeline = newPipeline(credentialOrPipelineOrContainerName, options);
+ pipeline3 = newPipeline(credentialOrPipelineOrContainerName, options);
} else if (!credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName !== "string") {
url2 = urlOrConnectionString;
if (blobNameOrOptions && typeof blobNameOrOptions !== "string") {
options = blobNameOrOptions;
}
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else if (credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName === "string" && blobNameOrOptions && typeof blobNameOrOptions === "string") {
const containerName = credentialOrPipelineOrContainerName;
const blobName = blobNameOrOptions;
@@ -91074,20 +91074,20 @@ var BlobClient = class _BlobClient extends StorageClient2 {
if (!options.proxyOptions) {
options.proxyOptions = getDefaultProxySettings2(extractedCreds.proxyUri);
}
- pipeline = newPipeline(sharedKeyCredential, options);
+ pipeline3 = newPipeline(sharedKeyCredential, options);
} else {
throw new Error("Account connection string is only supported in Node.js environment");
}
} else if (extractedCreds.kind === "SASConnString") {
url2 = appendToURLPath(appendToURLPath(extractedCreds.url, encodeURIComponent(containerName)), encodeURIComponent(blobName)) + "?" + extractedCreds.accountSas;
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else {
throw new Error("Connection string must be either an Account connection string or a SAS connection string");
}
} else {
throw new Error("Expecting non-empty strings for containerName and blobName parameters");
}
- super(url2, pipeline);
+ super(url2, pipeline3);
({ blobName: this._name, containerName: this._containerName } = this.getBlobAndContainerNamesFromUrl());
this.blobContext = this.storageClientContext.blob;
this._snapshot = getURLParameter(this.url, URLConstants2.Parameters.SNAPSHOT);
@@ -92090,21 +92090,21 @@ var AppendBlobClient = class _AppendBlobClient extends BlobClient {
*/
appendBlobContext;
constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, options) {
- let pipeline;
+ let pipeline3;
let url2;
options = options || {};
if (isPipelineLike(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
- pipeline = credentialOrPipelineOrContainerName;
+ pipeline3 = credentialOrPipelineOrContainerName;
options = blobNameOrOptions;
} else if (isNodeLike2 && credentialOrPipelineOrContainerName instanceof StorageSharedKeyCredential || credentialOrPipelineOrContainerName instanceof AnonymousCredential || isTokenCredential(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
options = blobNameOrOptions;
- pipeline = newPipeline(credentialOrPipelineOrContainerName, options);
+ pipeline3 = newPipeline(credentialOrPipelineOrContainerName, options);
} else if (!credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName !== "string") {
url2 = urlOrConnectionString;
options = blobNameOrOptions;
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else if (credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName === "string" && blobNameOrOptions && typeof blobNameOrOptions === "string") {
const containerName = credentialOrPipelineOrContainerName;
const blobName = blobNameOrOptions;
@@ -92116,20 +92116,20 @@ var AppendBlobClient = class _AppendBlobClient extends BlobClient {
if (!options.proxyOptions) {
options.proxyOptions = getDefaultProxySettings2(extractedCreds.proxyUri);
}
- pipeline = newPipeline(sharedKeyCredential, options);
+ pipeline3 = newPipeline(sharedKeyCredential, options);
} else {
throw new Error("Account connection string is only supported in Node.js environment");
}
} else if (extractedCreds.kind === "SASConnString") {
url2 = appendToURLPath(appendToURLPath(extractedCreds.url, encodeURIComponent(containerName)), encodeURIComponent(blobName)) + "?" + extractedCreds.accountSas;
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else {
throw new Error("Connection string must be either an Account connection string or a SAS connection string");
}
} else {
throw new Error("Expecting non-empty strings for containerName and blobName parameters");
}
- super(url2, pipeline);
+ super(url2, pipeline3);
this.appendBlobContext = this.storageClientContext.appendBlob;
this.blobClientConfig = options;
}
@@ -92370,23 +92370,23 @@ var BlockBlobClient = class _BlockBlobClient extends BlobClient {
*/
blockBlobContext;
constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, options) {
- let pipeline;
+ let pipeline3;
let url2;
options = options || {};
if (isPipelineLike(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
- pipeline = credentialOrPipelineOrContainerName;
+ pipeline3 = credentialOrPipelineOrContainerName;
options = blobNameOrOptions;
} else if (isNodeLike2 && credentialOrPipelineOrContainerName instanceof StorageSharedKeyCredential || credentialOrPipelineOrContainerName instanceof AnonymousCredential || isTokenCredential(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
options = blobNameOrOptions;
- pipeline = newPipeline(credentialOrPipelineOrContainerName, options);
+ pipeline3 = newPipeline(credentialOrPipelineOrContainerName, options);
} else if (!credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName !== "string") {
url2 = urlOrConnectionString;
if (blobNameOrOptions && typeof blobNameOrOptions !== "string") {
options = blobNameOrOptions;
}
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else if (credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName === "string" && blobNameOrOptions && typeof blobNameOrOptions === "string") {
const containerName = credentialOrPipelineOrContainerName;
const blobName = blobNameOrOptions;
@@ -92398,20 +92398,20 @@ var BlockBlobClient = class _BlockBlobClient extends BlobClient {
if (!options.proxyOptions) {
options.proxyOptions = getDefaultProxySettings2(extractedCreds.proxyUri);
}
- pipeline = newPipeline(sharedKeyCredential, options);
+ pipeline3 = newPipeline(sharedKeyCredential, options);
} else {
throw new Error("Account connection string is only supported in Node.js environment");
}
} else if (extractedCreds.kind === "SASConnString") {
url2 = appendToURLPath(appendToURLPath(extractedCreds.url, encodeURIComponent(containerName)), encodeURIComponent(blobName)) + "?" + extractedCreds.accountSas;
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else {
throw new Error("Connection string must be either an Account connection string or a SAS connection string");
}
} else {
throw new Error("Expecting non-empty strings for containerName and blobName parameters");
}
- super(url2, pipeline);
+ super(url2, pipeline3);
this.blockBlobContext = this.storageClientContext.blockBlob;
this._blobContext = this.storageClientContext.blob;
this.blobClientConfig = options;
@@ -92986,21 +92986,21 @@ var PageBlobClient = class _PageBlobClient extends BlobClient {
*/
pageBlobContext;
constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, options) {
- let pipeline;
+ let pipeline3;
let url2;
options = options || {};
if (isPipelineLike(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
- pipeline = credentialOrPipelineOrContainerName;
+ pipeline3 = credentialOrPipelineOrContainerName;
options = blobNameOrOptions;
} else if (isNodeLike2 && credentialOrPipelineOrContainerName instanceof StorageSharedKeyCredential || credentialOrPipelineOrContainerName instanceof AnonymousCredential || isTokenCredential(credentialOrPipelineOrContainerName)) {
url2 = urlOrConnectionString;
options = blobNameOrOptions;
- pipeline = newPipeline(credentialOrPipelineOrContainerName, options);
+ pipeline3 = newPipeline(credentialOrPipelineOrContainerName, options);
} else if (!credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName !== "string") {
url2 = urlOrConnectionString;
options = blobNameOrOptions;
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else if (credentialOrPipelineOrContainerName && typeof credentialOrPipelineOrContainerName === "string" && blobNameOrOptions && typeof blobNameOrOptions === "string") {
const containerName = credentialOrPipelineOrContainerName;
const blobName = blobNameOrOptions;
@@ -93012,20 +93012,20 @@ var PageBlobClient = class _PageBlobClient extends BlobClient {
if (!options.proxyOptions) {
options.proxyOptions = getDefaultProxySettings2(extractedCreds.proxyUri);
}
- pipeline = newPipeline(sharedKeyCredential, options);
+ pipeline3 = newPipeline(sharedKeyCredential, options);
} else {
throw new Error("Account connection string is only supported in Node.js environment");
}
} else if (extractedCreds.kind === "SASConnString") {
url2 = appendToURLPath(appendToURLPath(extractedCreds.url, encodeURIComponent(containerName)), encodeURIComponent(blobName)) + "?" + extractedCreds.accountSas;
- pipeline = newPipeline(new AnonymousCredential(), options);
+ pipeline3 = newPipeline(new AnonymousCredential(), options);
} else {
throw new Error("Connection string must be either an Account connection string or a SAS connection string");
}
} else {
throw new Error("Expecting non-empty strings for containerName and blobName parameters");
}
- super(url2, pipeline);
+ super(url2, pipeline3);
this.pageBlobContext = this.storageClientContext.pageBlob;
this.blobClientConfig = options;
}
@@ -93734,6 +93734,7 @@ var KnownEncryptionAlgorithmType2;
// node_modules/@actions/artifact/lib/internal/upload/blob-upload.js
var crypto2 = __toESM(require("crypto"), 1);
var stream = __toESM(require("stream"), 1);
+var import_promises5 = require("node:stream/promises");
var __awaiter7 = function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve7) {
@@ -93795,14 +93796,20 @@ function uploadToBlobStorage(authenticatedUploadURL, uploadStream, contentType2)
abortSignal: abortController.signal
};
let sha256Hash = void 0;
- const blobUploadStream = new stream.PassThrough();
const hashStream = crypto2.createHash("sha256");
- uploadStream.pipe(blobUploadStream);
- uploadStream.pipe(hashStream).setEncoding("hex");
+ const blobUploadStream = new stream.Transform({
+ transform(chunk, encoding, callback) {
+ hashStream.update(chunk);
+ callback(null, chunk);
+ }
+ });
info("Beginning upload of artifact content to blob storage");
try {
yield Promise.race([
- blockBlobClient.uploadStream(blobUploadStream, bufferSize, maxConcurrency, options),
+ Promise.all([
+ (0, import_promises5.pipeline)(uploadStream, blobUploadStream, { signal: abortController.signal }),
+ blockBlobClient.uploadStream(blobUploadStream, bufferSize, maxConcurrency, options)
+ ]),
chunkTimer(getUploadChunkTimeout())
]);
} catch (error2) {
@@ -93814,8 +93821,7 @@ function uploadToBlobStorage(authenticatedUploadURL, uploadStream, contentType2)
abortController.abort();
}
info("Finished uploading artifact content to blob storage!");
- hashStream.end();
- sha256Hash = hashStream.read();
+ sha256Hash = hashStream.digest("hex");
info(`SHA256 digest of uploaded artifact is ${sha256Hash}`);
if (uploadByteCount === 0) {
warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`);
@@ -93828,13 +93834,14 @@ function uploadToBlobStorage(authenticatedUploadURL, uploadStream, contentType2)
}
// node_modules/@actions/artifact/lib/internal/upload/zip.js
-var import_promises6 = require("fs/promises");
+var import_promises7 = require("fs/promises");
+var import_node_stream7 = require("node:stream");
var import_archiver = __toESM(require_archiver(), 1);
// node_modules/@actions/artifact/lib/internal/upload/stream.js
var stream2 = __toESM(require("stream"), 1);
var fs5 = __toESM(require("fs"), 1);
-var import_promises5 = require("fs/promises");
+var import_promises6 = require("fs/promises");
var __awaiter8 = function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve7) {
@@ -93881,7 +93888,7 @@ function createRawFileUploadStream(filePath) {
let sourcePath = filePath;
const stats = yield fs5.promises.lstat(filePath);
if (stats.isSymbolicLink()) {
- sourcePath = yield (0, import_promises5.realpath)(filePath);
+ sourcePath = yield (0, import_promises6.realpath)(filePath);
}
const fileStream = fs5.createReadStream(sourcePath, {
highWaterMark: bufferSize
@@ -93932,7 +93939,13 @@ function createZipUploadStream(uploadSpecification_1) {
highWaterMark: getUploadChunkSize(),
zlib: { level: compressionLevel }
});
- zip.on("error", zipErrorCallback);
+ const bufferSize = getUploadChunkSize();
+ const zipUploadStream = new WaterMarkedUploadStream(bufferSize);
+ debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`);
+ debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`);
+ (0, import_node_stream7.pipeline)(zip, zipUploadStream, (error2) => {
+ if (error2) zipErrorCallback(error2);
+ });
zip.on("warning", zipWarningCallback);
zip.on("finish", zipFinishCallback);
zip.on("end", zipEndCallback);
@@ -93940,7 +93953,7 @@ function createZipUploadStream(uploadSpecification_1) {
if (file.sourcePath !== null) {
let sourcePath = file.sourcePath;
if (file.stats.isSymbolicLink()) {
- sourcePath = yield (0, import_promises6.realpath)(file.sourcePath);
+ sourcePath = yield (0, import_promises7.realpath)(file.sourcePath);
}
zip.file(sourcePath, {
name: file.destinationPath
@@ -93949,19 +93962,13 @@ function createZipUploadStream(uploadSpecification_1) {
zip.append("", { name: file.destinationPath });
}
}
- const bufferSize = getUploadChunkSize();
- const zipUploadStream = new WaterMarkedUploadStream(bufferSize);
- debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`);
- debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`);
- zip.pipe(zipUploadStream);
- zip.finalize();
+ zip.finalize().catch((error2) => zip.destroy(error2));
return zipUploadStream;
});
}
var zipErrorCallback = (error2) => {
error("An error has occurred while creating the zip file for upload");
info(error2);
- throw new Error("An error has occurred during zip creation for the artifact");
};
var zipWarningCallback = (error2) => {
if (error2.code === "ENOENT") {
@@ -94151,7 +94158,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
}
// node_modules/@actions/artifact/lib/internal/download/download-artifact.js
-var import_promises7 = __toESM(require("fs/promises"), 1);
+var import_promises8 = __toESM(require("fs/promises"), 1);
var fsSync = __toESM(require("fs"), 1);
var crypto3 = __toESM(require("crypto"), 1);
var stream3 = __toESM(require("stream"), 1);
@@ -98359,7 +98366,7 @@ var scrubQueryParameters = (url2) => {
function exists2(path6) {
return __awaiter12(this, void 0, void 0, function* () {
try {
- yield import_promises7.default.access(path6);
+ yield import_promises8.default.access(path6);
return true;
} catch (error2) {
if (error2.code === "ENOENT") {
@@ -98534,7 +98541,7 @@ function resolveOrCreateDirectory() {
return __awaiter12(this, arguments, void 0, function* (downloadPath = getGitHubWorkspaceDir()) {
if (!(yield exists2(downloadPath))) {
debug(`Artifact destination folder does not exist, creating: ${downloadPath}`);
- yield import_promises7.default.mkdir(downloadPath, { recursive: true });
+ yield import_promises8.default.mkdir(downloadPath, { recursive: true });
} else {
debug(`Artifact destination folder already exists: ${downloadPath}`);
}
@@ -99134,7 +99141,7 @@ If the error persists, please check whether Actions and API requests are operati
var client = new DefaultArtifactClient();
// src/artifacts.ts
-var import_promises8 = require("node:fs/promises");
+var import_promises9 = require("node:fs/promises");
var import_node_path6 = require("node:path");
async function collectReports(result) {
const reports = /* @__PURE__ */ new Map();
@@ -99152,18 +99159,18 @@ async function collectReports(result) {
}
async function uploadReports(reports, inputs, tempRoot) {
if (!reports.size) throw new Error("Artifact upload requested, but no validated reports are available.");
- const staging = await (0, import_promises8.mkdtemp)((0, import_node_path6.join)(tempRoot, "codex-security-upload-"));
- await (0, import_promises8.chmod)(staging, 448);
+ const staging = await (0, import_promises9.mkdtemp)((0, import_node_path6.join)(tempRoot, "codex-security-upload-"));
+ await (0, import_promises9.chmod)(staging, 448);
try {
const files = [];
for (const [name, bytes] of reports) {
const dest = (0, import_node_path6.join)(staging, name === "exports/results.sarif" ? "results.sarif" : name);
- await (0, import_promises8.writeFile)(dest, bytes, { mode: 384, flag: "wx" });
+ await (0, import_promises9.writeFile)(dest, bytes, { mode: 384, flag: "wx" });
files.push(dest);
}
await new DefaultArtifactClient().uploadArtifact(inputs.artifactName, files, staging, { retentionDays: inputs.retentionDays, compressionLevel: 0 });
} finally {
- await (0, import_promises8.rm)(staging, { recursive: true, force: true });
+ await (0, import_promises9.rm)(staging, { recursive: true, force: true });
}
}
@@ -99247,7 +99254,7 @@ var OUTPUT_NAMES = [
async function context5() {
const path6 = process.env.GITHUB_EVENT_PATH;
if (!path6) throw new Error("GITHUB_EVENT_PATH is required; run this action in GitHub Actions.");
- const payload = JSON.parse(await (0, import_promises9.readFile)(path6, "utf8"));
+ const payload = JSON.parse(await (0, import_promises10.readFile)(path6, "utf8"));
if (!payload || typeof payload !== "object" || Array.isArray(payload)) throw new Error("Invalid GitHub event payload.");
return {
eventName: process.env.GITHUB_EVENT_NAME ?? "",
@@ -99318,7 +99325,7 @@ async function runAction(actionRoot, overrides = {}) {
if (!inputs.dryRun && credentials.provider !== "amazon-bedrock" && (!credentials.apiKey || /[\r\n\u0000]/.test(credentials.apiKey))) {
throw new Error(credentials.provider === "openai" ? "Set CODEX_SECURITY_API_KEY in Actions secrets (or Dependabot secrets for Dependabot runs) and pass it as OPENAI_API_KEY to this step. No scan was started." : `Pass ${API_KEY_ENVIRONMENT_VARIABLES[credentials.provider]} from Actions secrets to this step. No scan was started.`);
}
- tempRoot = await (0, import_promises9.realpath)(process.env.RUNNER_TEMP ?? "");
+ tempRoot = await (0, import_promises10.realpath)(process.env.RUNNER_TEMP ?? "");
if (!process.env.RUNNER_TEMP) throw new Error("RUNNER_TEMP is required.");
info(`Preparing Codex Security ${SUPPORTED_CLI_VERSION}. Scope: ${inputs.scope}; mode: ${inputs.mode}; effort: ${inputs.effort}.`);
const preparationStarted = performance.now();
diff --git a/github-action/package.json b/github-action/package.json
index 2a64f7704..6bc609f7d 100644
--- a/github-action/package.json
+++ b/github-action/package.json
@@ -16,7 +16,8 @@
"check-metadata": "node --import tsx scripts/check-metadata.ts",
"docs": "node scripts/generate-input-docs.mjs",
"check-docs": "node scripts/generate-input-docs.mjs --check",
- "validate": "npm run typecheck && npm test && npm run check-metadata && npm run check-docs && npm run check-dist"
+ "validate": "npm run typecheck && npm test && npm run check-metadata && npm run check-docs && npm run check-dist",
+ "pretest": "node scripts/apply-patches.mjs"
},
"dependencies": {
"@actions/artifact": "6.3.1",
diff --git a/github-action/patches/@actions+artifact+6.3.1.patch b/github-action/patches/@actions+artifact+6.3.1.patch
new file mode 100644
index 000000000..c7a89d6eb
--- /dev/null
+++ b/github-action/patches/@actions+artifact+6.3.1.patch
@@ -0,0 +1,95 @@
+diff --git a/node_modules/@actions/artifact/lib/internal/upload/blob-upload.js b/node_modules/@actions/artifact/lib/internal/upload/blob-upload.js
+--- a/node_modules/@actions/artifact/lib/internal/upload/blob-upload.js
++++ b/node_modules/@actions/artifact/lib/internal/upload/blob-upload.js
+@@ -12,6 +12,7 @@
+ import * as core from '@actions/core';
+ import * as crypto from 'crypto';
+ import * as stream from 'stream';
++import { pipeline } from 'node:stream/promises';
+ import { NetworkError } from '../shared/errors.js';
+ export function uploadToBlobStorage(authenticatedUploadURL, uploadStream, contentType) {
+ return __awaiter(this, void 0, void 0, function* () {
+@@ -47,14 +48,20 @@
+ abortSignal: abortController.signal
+ };
+ let sha256Hash = undefined;
+- const blobUploadStream = new stream.PassThrough();
+ const hashStream = crypto.createHash('sha256');
+- uploadStream.pipe(blobUploadStream); // This stream is used for the upload
+- uploadStream.pipe(hashStream).setEncoding('hex'); // This stream is used to compute a hash of the content for integrity check
++ const blobUploadStream = new stream.Transform({
++ transform(chunk, encoding, callback) {
++ hashStream.update(chunk);
++ callback(null, chunk);
++ }
++ });
+ core.info('Beginning upload of artifact content to blob storage');
+ try {
+ yield Promise.race([
+- blockBlobClient.uploadStream(blobUploadStream, bufferSize, maxConcurrency, options),
++ Promise.all([
++ pipeline(uploadStream, blobUploadStream, { signal: abortController.signal }),
++ blockBlobClient.uploadStream(blobUploadStream, bufferSize, maxConcurrency, options)
++ ]),
+ chunkTimer(getUploadChunkTimeout())
+ ]);
+ }
+@@ -68,8 +75,7 @@
+ abortController.abort();
+ }
+ core.info('Finished uploading artifact content to blob storage!');
+- hashStream.end();
+- sha256Hash = hashStream.read();
++ sha256Hash = hashStream.digest('hex');
+ core.info(`SHA256 digest of uploaded artifact is ${sha256Hash}`);
+ if (uploadByteCount === 0) {
+ core.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`);
+diff --git a/node_modules/@actions/artifact/lib/internal/upload/zip.js b/node_modules/@actions/artifact/lib/internal/upload/zip.js
+--- a/node_modules/@actions/artifact/lib/internal/upload/zip.js
++++ b/node_modules/@actions/artifact/lib/internal/upload/zip.js
+@@ -8,6 +8,7 @@
+ });
+ };
+ import { realpath } from 'fs/promises';
++import { pipeline } from 'node:stream';
+ import archiver from 'archiver';
+ import * as core from '@actions/core';
+ import { getUploadChunkSize } from '../shared/config.js';
+@@ -20,8 +21,14 @@
+ highWaterMark: getUploadChunkSize(),
+ zlib: { level: compressionLevel }
+ });
++ const bufferSize = getUploadChunkSize();
++ const zipUploadStream = new WaterMarkedUploadStream(bufferSize);
++ core.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`);
++ core.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`);
++ pipeline(zip, zipUploadStream, error => {
++ if (error) zipErrorCallback(error);
++ });
+ // register callbacks for various events during the zip lifecycle
+- zip.on('error', zipErrorCallback);
+ zip.on('warning', zipWarningCallback);
+ zip.on('finish', zipFinishCallback);
+ zip.on('end', zipEndCallback);
+@@ -42,12 +49,7 @@
+ zip.append('', { name: file.destinationPath });
+ }
+ }
+- const bufferSize = getUploadChunkSize();
+- const zipUploadStream = new WaterMarkedUploadStream(bufferSize);
+- core.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`);
+- core.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`);
+- zip.pipe(zipUploadStream);
+- zip.finalize();
++ zip.finalize().catch(error => zip.destroy(error));
+ return zipUploadStream;
+ });
+ }
+@@ -55,7 +57,6 @@
+ const zipErrorCallback = (error) => {
+ core.error('An error has occurred while creating the zip file for upload');
+ core.info(error);
+- throw new Error('An error has occurred during zip creation for the artifact');
+ };
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const zipWarningCallback = (error) => {
diff --git a/github-action/patches/README.md b/github-action/patches/README.md
new file mode 100644
index 000000000..0be0a9513
--- /dev/null
+++ b/github-action/patches/README.md
@@ -0,0 +1,8 @@
+# Action dependency patches
+
+- @actions/artifact: propagate archive and input-stream errors to the upload promise, cancel streams on upload failure, and hash the bytes forwarded to storage.
+- readable-stream: preserve missing-argument names and initialize the diagnostic before concatenating it.
+
+The build applies these patches explicitly with git apply because CI uses npm ci --ignore-scripts. The test pre-hook applies the same patches before testing the installed dependencies. Patch contents are included in the release build-input hashes.
+
+When updating either dependency, review whether upstream has fixed the behavior, refresh or remove its patch, regenerate the distribution, and run npm run validate. The regression tests cover the affected runtime behavior.
diff --git a/github-action/patches/readable-stream+4.7.0.patch b/github-action/patches/readable-stream+4.7.0.patch
new file mode 100644
index 000000000..a9bf3d85e
--- /dev/null
+++ b/github-action/patches/readable-stream+4.7.0.patch
@@ -0,0 +1,15 @@
+diff --git a/node_modules/readable-stream/lib/ours/errors.js b/node_modules/readable-stream/lib/ours/errors.js
+--- a/node_modules/readable-stream/lib/ours/errors.js
++++ b/node_modules/readable-stream/lib/ours/errors.js
+@@ -282,9 +282,9 @@
+ 'ERR_MISSING_ARGS',
+ (...args) => {
+ assert(args.length > 0, 'At least one arg needs to be specified')
+- let msg
++ let msg = ''
+ const len = args.length
+- args = (Array.isArray(args) ? args : [args]).map((a) => `"${a}"`).join(' or ')
++ args = (Array.isArray(args) ? args : [args]).map((a) => `"${a}"`)
+ switch (len) {
+ case 1:
+ msg += `The ${args[0]} argument`
diff --git a/github-action/scripts/apply-patches.mjs b/github-action/scripts/apply-patches.mjs
new file mode 100644
index 000000000..9b59c76a9
--- /dev/null
+++ b/github-action/scripts/apply-patches.mjs
@@ -0,0 +1,14 @@
+import { execFileSync, spawnSync } from 'node:child_process';
+import { readdir } from 'node:fs/promises';
+import { basename, resolve } from 'node:path';
+
+const root = resolve(import.meta.dirname, '..');
+const patches = (await readdir(resolve(root, 'patches'))).filter(name => name.endsWith('.patch')).sort();
+const options = { cwd: resolve(root, '..') };
+for (const name of patches) {
+ const patch = resolve(root, 'patches', name);
+ const args = ['apply', '--directory=' + basename(root)];
+ // Builds and tests can run consecutively against the same installation.
+ if (spawnSync('git', [...args, '--reverse', '--check', patch], options).status === 0) continue;
+ execFileSync('git', [...args, patch], { ...options, stdio: 'inherit' });
+}
diff --git a/github-action/scripts/build.mjs b/github-action/scripts/build.mjs
index a3ad6c0f8..be04f85ce 100644
--- a/github-action/scripts/build.mjs
+++ b/github-action/scripts/build.mjs
@@ -1,10 +1,12 @@
import { build } from 'esbuild';
+import './apply-patches.mjs';
import { readFile, readdir, mkdir, writeFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
import { resolve, relative } from 'node:path';
const check = process.argv.includes('--check');
const root = resolve(import.meta.dirname, '..');
+const patches = (await readdir(resolve(root, 'patches'))).filter(name => name.endsWith('.patch')).sort();
const hash = value => createHash('sha256').update(value).digest('hex');
const bundle = await build({
absWorkingDir: root, entryPoints: {index: 'src/entry.ts', post: 'src/post.ts'}, outdir: 'dist',
@@ -33,7 +35,7 @@ const manifest = {
actionVersion, status: 'unreleased', nodeRuntime: 'node24', platform: 'linux-x64', cliVersion,
sourceSha256: sourceHash.digest('hex'), actionLockSha256: hash(await readFile(resolve(root, 'package-lock.json'))),
runtimeLockSha256: hash(cliLockBytes),
- buildInputs: Object.fromEntries(await Promise.all(['../action.yml', 'package.json', 'runtime/package.json', 'scripts/build.mjs'].map(async path => [path, {sha256: hash(await readFile(resolve(root, path)))}]))),
+ buildInputs: Object.fromEntries(await Promise.all(['../action.yml', 'package.json', 'runtime/package.json', 'scripts/build.mjs', 'scripts/apply-patches.mjs', ...patches.map(name => 'patches/' + name)].map(async path => [path, {sha256: hash(await readFile(resolve(root, path)))}]))),
files: Object.fromEntries([...generated].map(([path, bytes]) => [path, {sha256: hash(bytes), bytes: bytes.length}])),
};
const sbom = {
diff --git a/github-action/tests/dependency-patches.test.mjs b/github-action/tests/dependency-patches.test.mjs
new file mode 100644
index 000000000..569e3dd8c
--- /dev/null
+++ b/github-action/tests/dependency-patches.test.mjs
@@ -0,0 +1,146 @@
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { createRequire } from 'node:module';
+import { PassThrough, Readable } from 'node:stream';
+import { setImmediate } from 'node:timers/promises';
+import test from 'node:test';
+import { BlobClient } from '@azure/storage-blob';
+import archiver from 'archiver';
+import { uploadToBlobStorage } from '../node_modules/@actions/artifact/lib/internal/upload/blob-upload.js';
+import { createZipUploadStream } from '../node_modules/@actions/artifact/lib/internal/upload/zip.js';
+
+const require = createRequire(import.meta.url);
+const { compose } = require('readable-stream');
+const { codes: { ERR_MISSING_ARGS } } = require('readable-stream/lib/ours/errors.js');
+const uploadUrl = 'https://example.invalid/artifact';
+
+function mockUpload(t, implementation) {
+ t.mock.method(BlobClient.prototype, 'getBlockBlobClient', () => ({
+ uploadStream: implementation,
+ }));
+}
+
+test('missing stream arguments retain their names and TypeError', () => {
+ assert.throws(() => compose(), {
+ name: 'TypeError',
+ code: 'ERR_MISSING_ARGS',
+ message: 'The "streams" argument must be specified',
+ });
+ for (const [names, message] of [
+ [['source', 'destination'], 'The "source" and "destination" arguments must be specified'],
+ [['source', 'destination', 'callback'], 'The "source", "destination", and "callback" arguments must be specified'],
+ ]) {
+ const error = new ERR_MISSING_ARGS(...names);
+ assert.ok(error instanceof TypeError);
+ assert.equal(error.code, 'ERR_MISSING_ARGS');
+ assert.equal(error.message, message);
+ }
+});
+
+test('artifact upload preserves bytes, upload size, and SHA-256', async t => {
+ const chunks = [Buffer.from('first report\n'), Buffer.from('second report\n')];
+ let uploaded;
+ mockUpload(t, async (input, _bufferSize, _concurrency, options) => {
+ const received = [];
+ for await (const chunk of input) received.push(chunk);
+ uploaded = Buffer.concat(received);
+ options.onProgress({ loadedBytes: uploaded.length });
+ assert.equal(options.blobHTTPHeaders.blobContentType, 'application/zip');
+ });
+ const result = await uploadToBlobStorage(uploadUrl, Readable.from(chunks), 'application/zip');
+ const expected = Buffer.concat(chunks);
+ assert.deepEqual(uploaded, expected);
+ assert.deepEqual(result, {
+ uploadSize: expected.length,
+ sha256Hash: createHash('sha256').update(expected).digest('hex'),
+ });
+});
+
+test('source failures reject artifact upload with the original error', { timeout: 5000 }, async t => {
+ const source = new PassThrough();
+ const failure = new Error('Synthetic report read failure');
+ let destination;
+ let signal;
+ mockUpload(t, async (input, _bufferSize, _concurrency, options) => {
+ destination = input;
+ signal = options.abortSignal;
+ for await (const _chunk of input) { /* Consume the upload stream. */ }
+ });
+ const upload = uploadToBlobStorage(uploadUrl, source, 'application/zip');
+ source.write('partial report');
+ source.destroy(failure);
+ await assert.rejects(upload, error => error === failure);
+ assert.equal(destination.destroyed, true);
+ assert.equal(signal.aborted, true);
+});
+
+test('remote upload failures cancel the source stream', { timeout: 5000 }, async t => {
+ const source = new PassThrough();
+ const failure = new Error('Synthetic upload failure');
+ let destination;
+ mockUpload(t, async input => {
+ destination = input;
+ throw failure;
+ });
+ await assert.rejects(uploadToBlobStorage(uploadUrl, source, 'application/zip'), error => error === failure);
+ assert.equal(source.destroyed, true);
+ assert.equal(destination.destroyed, true);
+});
+
+test('archive errors reject upload without an uncaught error or rejection', { timeout: 5000 }, async t => {
+ const create = archiver.create;
+ let archive;
+ t.mock.method(archiver, 'create', (...args) => {
+ archive = create(...args);
+ return archive;
+ });
+ mockUpload(t, async input => {
+ for await (const _chunk of input) { /* Consume the upload stream. */ }
+ });
+ const source = await createZipUploadStream([{ sourcePath: null, destinationPath: 'reports/' }]);
+ const upload = uploadToBlobStorage(uploadUrl, source, 'application/zip');
+ const failure = new Error('Synthetic archive compression failure');
+ // Exercise both the archive error event and its finalize() rejection.
+ archive._module.engine.emit('error', failure);
+ await assert.rejects(upload, error => error === failure);
+ await setImmediate();
+ assert.equal(source.destroyed, true);
+ assert.equal(archive.destroyed, true);
+});
+
+test('a completed ZIP archive still uploads successfully', { timeout: 5000 }, async t => {
+ let uploaded;
+ mockUpload(t, async (input, _bufferSize, _concurrency, options) => {
+ const received = [];
+ for await (const chunk of input) received.push(chunk);
+ uploaded = Buffer.concat(received);
+ options.onProgress({ loadedBytes: uploaded.length });
+ });
+ const source = await createZipUploadStream([{ sourcePath: null, destinationPath: 'reports/' }]);
+ const result = await uploadToBlobStorage(uploadUrl, source, 'application/zip');
+ assert.equal(uploaded.readUInt32LE(0), 0x04034b50);
+ assert.equal(uploaded.readUInt32LE(uploaded.length - 22), 0x06054b50);
+ assert.equal(result.uploadSize, uploaded.length);
+ assert.equal(result.sha256Hash, createHash('sha256').update(uploaded).digest('hex'));
+});
+
+test('archive errors during file registration reach the returned stream', { timeout: 5000 }, async t => {
+ const create = archiver.create;
+ const failure = new Error('Synthetic archive source failure');
+ t.mock.method(archiver, 'create', (...args) => {
+ const archive = create(...args);
+ archive.file = () => {
+ archive.emit('error', failure);
+ return archive;
+ };
+ return archive;
+ });
+ mockUpload(t, async input => {
+ for await (const _chunk of input) { /* Consume the upload stream. */ }
+ });
+ const source = await createZipUploadStream([{
+ sourcePath: 'report.json', destinationPath: 'report.json',
+ stats: { isSymbolicLink: () => false },
+ }]);
+ await assert.rejects(uploadToBlobStorage(uploadUrl, source, 'application/zip'), error => error === failure);
+});
diff --git a/sdk/typescript/tests-ts/package-tar-listing.test.ts b/sdk/typescript/tests-ts/package-tar-listing.test.ts
index 0a0b818d0..9acf56445 100644
--- a/sdk/typescript/tests-ts/package-tar-listing.test.ts
+++ b/sdk/typescript/tests-ts/package-tar-listing.test.ts
@@ -249,6 +249,44 @@ function installPackage(
);
}
+function checkPackage(
+ root: string,
+ archivePath: string,
+ contractPath: string,
+ environment: NodeJS.ProcessEnv,
+): Promise<{ status: number; stderr: string }> {
+ return new Promise((resolve, reject) => {
+ execFile(
+ commandPath("node"),
+ [
+ fileURLToPath(new URL("../scripts/check-package.mjs", import.meta.url)),
+ archivePath,
+ contractPath,
+ ],
+ {
+ cwd: root,
+ env: environment,
+ encoding: "utf8",
+ timeout: 30_000,
+ windowsHide: true,
+ },
+ (error, _stdout, stderr) => {
+ if (error === null) {
+ resolve({ status: 0, stderr });
+ } else if (
+ typeof error.code === "number" &&
+ !error.killed &&
+ !error.signal
+ ) {
+ resolve({ status: error.code, stderr });
+ } else {
+ reject(error);
+ }
+ },
+ );
+ });
+}
+
describe("npm package tar listings", () => {
test("accepts regular entries with Unix or Windows line endings", () => {
const file = "-rw-r--r-- package/package.json";
@@ -690,22 +728,11 @@ describe("npm package tar listings", () => {
).toBe(compatible);
if (overwrite)
expect(readFileSync(installedLogo).equals(stored)).toBe(true);
- const checked = spawnSync(
- commandPath("node"),
- [
- fileURLToPath(
- new URL("../scripts/check-package.mjs", import.meta.url),
- ),
- archivePath,
- contractPath,
- ],
- {
- cwd: root,
- env: environment,
- encoding: "utf8",
- timeout: 30_000,
- windowsHide: true,
- },
+ const checked = await checkPackage(
+ root,
+ archivePath,
+ contractPath,
+ environment,
);
expect({
status: checked.status,
@@ -854,22 +881,11 @@ describe("npm package tar listings", () => {
);
const contractPath = join(root, "contract.json");
writeFileSync(contractPath, JSON.stringify(pluginContract));
- const checked = spawnSync(
- commandPath("node"),
- [
- fileURLToPath(
- new URL("../scripts/check-package.mjs", import.meta.url),
- ),
- archivePath,
- contractPath,
- ],
- {
- cwd: root,
- env: environment,
- encoding: "utf8",
- timeout: 30_000,
- windowsHide: true,
- },
+ const checked = await checkPackage(
+ root,
+ archivePath,
+ contractPath,
+ environment,
);
expect({
status: checked.status,