UNPKG

cdk-insights

Version:

AWS CDK security and cost analysis tool with AI-powered insights

1,404 lines (1,392 loc) 46.8 MB
#!/usr/bin/env node "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // node_modules/constructs/lib/dependency.js var require_dependency = __commonJS({ "node_modules/constructs/lib/dependency.js"(exports2) { "use strict"; var _a2; var _b; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.Dependable = exports2.DependencyGroup = void 0; var JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti"); var DependencyGroup = class { constructor(...deps) { this._deps = new Array(); const self2 = this; Dependable.implement(this, { get dependencyRoots() { const result = new Array(); for (const d3 of self2._deps) { result.push(...Dependable.of(d3).dependencyRoots); } return result; } }); this.add(...deps); } /** * Add a construct to the dependency roots */ add(...scopes) { this._deps.push(...scopes); } }; exports2.DependencyGroup = DependencyGroup; _a2 = JSII_RTTI_SYMBOL_1; DependencyGroup[_a2] = { fqn: "constructs.DependencyGroup", version: "10.4.2" }; var DEPENDABLE_SYMBOL = Symbol.for("@aws-cdk/core.DependableTrait"); var Dependable = class { /** * Turn any object into an IDependable. */ static implement(instance, trait) { instance[DEPENDABLE_SYMBOL] = trait; } /** * Return the matching Dependable for the given class instance. */ static of(instance) { const ret = instance[DEPENDABLE_SYMBOL]; if (!ret) { throw new Error(`${instance} does not implement IDependable. Use "Dependable.implement()" to implement`); } return ret; } /** * Return the matching Dependable for the given class instance. * @deprecated use `of` */ static get(instance) { return this.of(instance); } }; exports2.Dependable = Dependable; _b = JSII_RTTI_SYMBOL_1; Dependable[_b] = { fqn: "constructs.Dependable", version: "10.4.2" }; } }); // node_modules/constructs/lib/private/stack-trace.js var require_stack_trace = __commonJS({ "node_modules/constructs/lib/private/stack-trace.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.captureStackTrace = void 0; function captureStackTrace(below) { below = below || captureStackTrace; const object = { stack: "" }; const previousLimit = Error.stackTraceLimit; try { Error.stackTraceLimit = Number.MAX_SAFE_INTEGER; Error.captureStackTrace(object, below); } finally { Error.stackTraceLimit = previousLimit; } if (!object.stack) { return []; } return object.stack.split("\n").slice(1).map((s3) => s3.replace(/^\s*at\s+/, "")); } exports2.captureStackTrace = captureStackTrace; } }); // node_modules/constructs/lib/private/uniqueid.js var require_uniqueid = __commonJS({ "node_modules/constructs/lib/private/uniqueid.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.addressOf = void 0; var crypto5 = require("crypto"); var HIDDEN_ID = "Default"; function addressOf(components) { const hash = crypto5.createHash("sha1"); for (const c3 of components) { if (c3 === HIDDEN_ID) { continue; } hash.update(c3); hash.update("\n"); } return "c8" + hash.digest("hex"); } exports2.addressOf = addressOf; } }); // node_modules/constructs/lib/construct.js var require_construct = __commonJS({ "node_modules/constructs/lib/construct.js"(exports2) { "use strict"; var _a2; var _b; var _c; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RootConstruct = exports2.ConstructOrder = exports2.Construct = exports2.Node = void 0; var JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti"); var dependency_1 = require_dependency(); var stack_trace_1 = require_stack_trace(); var uniqueid_1 = require_uniqueid(); var CONSTRUCT_SYM = Symbol.for("constructs.Construct"); var Node = class _Node { /** * Returns the node associated with a construct. * @param construct the construct * * @deprecated use `construct.node` instead */ static of(construct) { return construct.node; } constructor(host, scope, id) { this.host = host; this._locked = false; this._children = {}; this._context = {}; this._metadata = new Array(); this._dependencies = /* @__PURE__ */ new Set(); this._validations = new Array(); id = id ?? ""; this.id = sanitizeId(id); this.scope = scope; if (scope && !this.id) { throw new Error("Only root constructs may have an empty ID"); } scope?.node.addChild(host, this.id); } /** * The full, absolute path of this construct in the tree. * * Components are separated by '/'. */ get path() { const components = []; for (const scope of this.scopes) { if (scope.node.id) { components.push(scope.node.id); } } return components.join(_Node.PATH_SEP); } /** * Returns an opaque tree-unique address for this construct. * * Addresses are 42 characters hexadecimal strings. They begin with "c8" * followed by 40 lowercase hexadecimal characters (0-9a-f). * * Addresses are calculated using a SHA-1 of the components of the construct * path. * * To enable refactoring of construct trees, constructs with the ID `Default` * will be excluded from the calculation. In those cases constructs in the * same tree may have the same address. * * @example c83a2846e506bcc5f10682b564084bca2d275709ee */ get addr() { if (!this._addr) { this._addr = (0, uniqueid_1.addressOf)(this.scopes.map((c3) => c3.node.id)); } return this._addr; } /** * Return a direct child by id, or undefined * * @param id Identifier of direct child * @returns the child if found, or undefined */ tryFindChild(id) { return this._children[sanitizeId(id)]; } /** * Return a direct child by id * * Throws an error if the child is not found. * * @param id Identifier of direct child * @returns Child with the given id. */ findChild(id) { const ret = this.tryFindChild(id); if (!ret) { throw new Error(`No child with id: '${id}'`); } return ret; } /** * Returns the child construct that has the id `Default` or `Resource"`. * This is usually the construct that provides the bulk of the underlying functionality. * Useful for modifications of the underlying construct that are not available at the higher levels. * * @throws if there is more than one child * @returns a construct or undefined if there is no default child */ get defaultChild() { if (this._defaultChild !== void 0) { return this._defaultChild; } const resourceChild = this.tryFindChild("Resource"); const defaultChild = this.tryFindChild("Default"); if (resourceChild && defaultChild) { throw new Error(`Cannot determine default child for ${this.path}. There is both a child with id "Resource" and id "Default"`); } return defaultChild || resourceChild; } /** * Override the defaultChild property. * * This should only be used in the cases where the correct * default child is not named 'Resource' or 'Default' as it * should be. * * If you set this to undefined, the default behavior of finding * the child named 'Resource' or 'Default' will be used. */ set defaultChild(value) { this._defaultChild = value; } /** * All direct children of this construct. */ get children() { return Object.values(this._children); } /** * Return this construct and all of its children in the given order */ findAll(order = ConstructOrder.PREORDER) { const ret = new Array(); visit(this.host); return ret; function visit(c3) { if (order === ConstructOrder.PREORDER) { ret.push(c3); } for (const child of c3.node.children) { visit(child); } if (order === ConstructOrder.POSTORDER) { ret.push(c3); } } } /** * This can be used to set contextual values. * Context must be set before any children are added, since children may consult context info during construction. * If the key already exists, it will be overridden. * @param key The context key * @param value The context value */ setContext(key, value) { if (this.children.length > 0) { const names = this.children.map((c3) => c3.node.id); throw new Error("Cannot set context after children have been added: " + names.join(",")); } this._context[key] = value; } /** * Retrieves a value from tree context if present. Otherwise, would throw an error. * * Context is usually initialized at the root, but can be overridden at any point in the tree. * * @param key The context key * @returns The context value or throws error if there is no context value for this key */ getContext(key) { const value = this._context[key]; if (value !== void 0) { return value; } if (value === void 0 && !this.scope?.node) { throw new Error(`No context value present for ${key} key`); } return this.scope && this.scope.node.getContext(key); } /** * Retrieves the all context of a node from tree context. * * Context is usually initialized at the root, but can be overridden at any point in the tree. * * @param defaults Any keys to override the retrieved context * @returns The context object or an empty object if there is discovered context */ getAllContext(defaults) { return this.scopes.reverse().reduce((a3, s3) => ({ ...s3.node._context, ...a3 }), { ...defaults }); } /** * Retrieves a value from tree context. * * Context is usually initialized at the root, but can be overridden at any point in the tree. * * @param key The context key * @returns The context value or `undefined` if there is no context value for this key. */ tryGetContext(key) { const value = this._context[key]; if (value !== void 0) { return value; } return this.scope && this.scope.node.tryGetContext(key); } /** * An immutable array of metadata objects associated with this construct. * This can be used, for example, to implement support for deprecation notices, source mapping, etc. */ get metadata() { return [...this._metadata]; } /** * Adds a metadata entry to this construct. * Entries are arbitrary values and will also include a stack trace to allow tracing back to * the code location for when the entry was added. It can be used, for example, to include source * mapping in CloudFormation templates to improve diagnostics. * Note that construct metadata is not the same as CloudFormation resource metadata and is never written to the CloudFormation template. * The metadata entries are written to the Cloud Assembly Manifest if the `treeMetadata` property is specified in the props of the App that contains this Construct. * * @param type a string denoting the type of metadata * @param data the value of the metadata (can be a Token). If null/undefined, metadata will not be added. * @param options options */ addMetadata(type, data, options = {}) { if (data == null) { return; } const shouldTrace = options.stackTrace ?? false; const trace = shouldTrace ? (0, stack_trace_1.captureStackTrace)(options.traceFromFunction ?? this.addMetadata) : void 0; this._metadata.push({ type, data, trace }); } /** * All parent scopes of this construct. * * @returns a list of parent scopes. The last element in the list will always * be the current construct and the first element will be the root of the * tree. */ get scopes() { const ret = new Array(); let curr = this.host; while (curr) { ret.unshift(curr); curr = curr.node.scope; } return ret; } /** * Returns the root of the construct tree. * @returns The root of the construct tree. */ get root() { return this.scopes[0]; } /** * Returns true if this construct or the scopes in which it is defined are * locked. */ get locked() { if (this._locked) { return true; } if (this.scope && this.scope.node.locked) { return true; } return false; } /** * Add an ordering dependency on another construct. * * An `IDependable` */ addDependency(...deps) { for (const d3 of deps) { this._dependencies.add(d3); } } /** * Return all dependencies registered on this node (non-recursive). */ get dependencies() { const result = new Array(); for (const dep of this._dependencies) { for (const root of dependency_1.Dependable.of(dep).dependencyRoots) { result.push(root); } } return result; } /** * Remove the child with the given name, if present. * * @returns Whether a child with the given name was deleted. */ tryRemoveChild(childName) { if (!(childName in this._children)) { return false; } delete this._children[childName]; return true; } /** * Adds a validation to this construct. * * When `node.validate()` is called, the `validate()` method will be called on * all validations and all errors will be returned. * * @param validation The validation object */ addValidation(validation) { this._validations.push(validation); } /** * Validates this construct. * * Invokes the `validate()` method on all validations added through * `addValidation()`. * * @returns an array of validation error messages associated with this * construct. */ validate() { return this._validations.flatMap((v6) => v6.validate()); } /** * Locks this construct from allowing more children to be added. After this * call, no more children can be added to this construct or to any children. */ lock() { this._locked = true; } /** * Adds a child construct to this node. * * @param child The child construct * @param childName The type name of the child construct. * @returns The resolved path part name of the child */ addChild(child, childName) { if (this.locked) { if (!this.path) { throw new Error("Cannot add children during synthesis"); } throw new Error(`Cannot add children to "${this.path}" during synthesis`); } if (this._children[childName]) { const name = this.id ?? ""; const typeName = this.host.constructor.name; throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? " [" + name + "]" : ""}`); } this._children[childName] = child; } }; exports2.Node = Node; _a2 = JSII_RTTI_SYMBOL_1; Node[_a2] = { fqn: "constructs.Node", version: "10.4.2" }; Node.PATH_SEP = "/"; var Construct = class { /** * Checks if `x` is a construct. * * Use this method instead of `instanceof` to properly detect `Construct` * instances, even when the construct library is symlinked. * * Explanation: in JavaScript, multiple copies of the `constructs` library on * disk are seen as independent, completely different libraries. As a * consequence, the class `Construct` in each copy of the `constructs` library * is seen as a different class, and an instance of one class will not test as * `instanceof` the other class. `npm install` will not create installations * like this, but users may manually symlink construct libraries together or * use a monorepo tool: in those cases, multiple copies of the `constructs` * library can be accidentally installed, and `instanceof` will behave * unpredictably. It is safest to avoid using `instanceof`, and using * this type-testing method instead. * * @returns true if `x` is an object created from a class which extends `Construct`. * @param x Any object */ static isConstruct(x3) { return x3 && typeof x3 === "object" && x3[CONSTRUCT_SYM]; } /** * Creates a new construct node. * * @param scope The scope in which to define this construct * @param id The scoped construct ID. Must be unique amongst siblings. If * the ID includes a path separator (`/`), then it will be replaced by double * dash `--`. */ constructor(scope, id) { this.node = new Node(this, scope, id); dependency_1.Dependable.implement(this, { dependencyRoots: [this] }); } /** * Returns a string representation of this construct. */ toString() { return this.node.path || "<root>"; } }; exports2.Construct = Construct; _b = JSII_RTTI_SYMBOL_1; Construct[_b] = { fqn: "constructs.Construct", version: "10.4.2" }; var ConstructOrder; (function(ConstructOrder2) { ConstructOrder2[ConstructOrder2["PREORDER"] = 0] = "PREORDER"; ConstructOrder2[ConstructOrder2["POSTORDER"] = 1] = "POSTORDER"; })(ConstructOrder || (exports2.ConstructOrder = ConstructOrder = {})); var PATH_SEP_REGEX = new RegExp(`${Node.PATH_SEP}`, "g"); function sanitizeId(id) { return id.replace(PATH_SEP_REGEX, "--"); } Object.defineProperty(Construct.prototype, CONSTRUCT_SYM, { value: true, enumerable: false, writable: false }); var RootConstruct = class extends Construct { /** * Creates a new root construct node. * * @param id The scoped construct ID. Must be unique amongst siblings. If * the ID includes a path separator (`/`), then it will be replaced by double * dash `--`. */ constructor(id) { super(void 0, id ?? ""); } }; exports2.RootConstruct = RootConstruct; _c = JSII_RTTI_SYMBOL_1; RootConstruct[_c] = { fqn: "constructs.RootConstruct", version: "10.4.2" }; } }); // node_modules/constructs/lib/metadata.js var require_metadata = __commonJS({ "node_modules/constructs/lib/metadata.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); } }); // node_modules/constructs/lib/index.js var require_lib = __commonJS({ "node_modules/constructs/lib/index.js"(exports2) { "use strict"; var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o3, m3, k3, k22) { if (k22 === void 0) k22 = k3; var desc = Object.getOwnPropertyDescriptor(m3, k3); if (!desc || ("get" in desc ? !m3.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m3[k3]; } }; } Object.defineProperty(o3, k22, desc); } : function(o3, m3, k3, k22) { if (k22 === void 0) k22 = k3; o3[k22] = m3[k3]; }); var __exportStar2 = exports2 && exports2.__exportStar || function(m3, exports3) { for (var p3 in m3) if (p3 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p3)) __createBinding2(exports3, m3, p3); }; Object.defineProperty(exports2, "__esModule", { value: true }); __exportStar2(require_construct(), exports2); __exportStar2(require_metadata(), exports2); __exportStar2(require_dependency(), exports2); } }); // node_modules/aws-cdk-lib/core/lib/aspect.js var require_aspect = __commonJS({ "node_modules/aws-cdk-lib/core/lib/aspect.js"(exports2) { "use strict"; var _a2; var _b; var _c; Object.defineProperty(exports2, "__esModule", { value: true }), exports2.AspectApplication = exports2.Aspects = exports2.AspectPriority = void 0, exports2._aspectTreeRevisionReader = _aspectTreeRevisionReader; var jsiiDeprecationWarnings = () => { var tmp = require_warnings_jsii(); return jsiiDeprecationWarnings = () => tmp, tmp; }; var JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti"); var ASPECTS_SYMBOL = Symbol.for("cdk-aspects"); var AspectPriority = class { }; exports2.AspectPriority = AspectPriority, _a2 = JSII_RTTI_SYMBOL_1, AspectPriority[_a2] = { fqn: "aws-cdk-lib.AspectPriority", version: "2.196.0" }, AspectPriority.MUTATING = 200, AspectPriority.READONLY = 1e3, AspectPriority.DEFAULT = 500; var Aspects = class _Aspects { static of(scope) { let aspects = scope[ASPECTS_SYMBOL]; return aspects || (aspects = new _Aspects(scope), Object.defineProperty(scope, ASPECTS_SYMBOL, { value: aspects, configurable: false, enumerable: false })), aspects; } constructor(scope) { this._appliedAspects = [], this._scope = scope; } add(aspect, options) { try { jsiiDeprecationWarnings().aws_cdk_lib_IAspect(aspect), jsiiDeprecationWarnings().aws_cdk_lib_AspectOptions(options); } catch (error) { throw process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError" && Error.captureStackTrace(error, this.add), error; } const newApplication = new AspectApplication(this._scope, aspect, options?.priority ?? AspectPriority.DEFAULT); this._appliedAspects.some((a3) => a3.aspect === newApplication.aspect && a3.priority === newApplication.priority) || (this._appliedAspects.push(newApplication), bumpAspectTreeRevision(this._scope)); } get all() { return this._appliedAspects.map((application) => application.aspect); } get applied() { return [...this._appliedAspects]; } }; exports2.Aspects = Aspects, _b = JSII_RTTI_SYMBOL_1, Aspects[_b] = { fqn: "aws-cdk-lib.Aspects", version: "2.196.0" }; function bumpAspectTreeRevision(construct) { const root = construct.node.root, rev = root[TREE_REVISION_SYM] ?? 0; root[TREE_REVISION_SYM] = rev + 1; } function _aspectTreeRevisionReader(construct) { const root = construct.node.root; return () => root[TREE_REVISION_SYM] ?? 0; } var AspectApplication = class _AspectApplication { constructor(construct, aspect, priority) { try { jsiiDeprecationWarnings().aws_cdk_lib_IAspect(aspect); } catch (error) { throw process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError" && Error.captureStackTrace(error, _AspectApplication), error; } this.construct = construct, this.aspect = aspect, this._priority = priority; } get priority() { return this._priority; } set priority(priority) { if (priority < 0) throw new Error("Priority must be a non-negative number"); this._priority = priority, bumpAspectTreeRevision(this.construct); } }; exports2.AspectApplication = AspectApplication, _c = JSII_RTTI_SYMBOL_1, AspectApplication[_c] = { fqn: "aws-cdk-lib.AspectApplication", version: "2.196.0" }; var TREE_REVISION_SYM = Symbol.for("@aws-cdk/core.Aspects.treeRevision"); } }); // node_modules/aws-cdk-lib/node_modules/universalify/index.js var require_universalify = __commonJS({ "node_modules/aws-cdk-lib/node_modules/universalify/index.js"(exports2) { "use strict"; exports2.fromCallback = function(fn) { return Object.defineProperty(function(...args) { if (typeof args[args.length - 1] === "function") fn.apply(this, args); else { return new Promise((resolve, reject) => { args.push((err, res) => err != null ? reject(err) : resolve(res)); fn.apply(this, args); }); } }, "name", { value: fn.name }); }; exports2.fromPromise = function(fn) { return Object.defineProperty(function(...args) { const cb = args[args.length - 1]; if (typeof cb !== "function") return fn.apply(this, args); else { args.pop(); fn.apply(this, args).then((r3) => cb(null, r3), cb); } }, "name", { value: fn.name }); }; } }); // node_modules/aws-cdk-lib/node_modules/graceful-fs/polyfills.js var require_polyfills = __commonJS({ "node_modules/aws-cdk-lib/node_modules/graceful-fs/polyfills.js"(exports2, module2) { var constants = require("constants"); var origCwd = process.cwd; var cwd = null; var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform; process.cwd = function() { if (!cwd) cwd = origCwd.call(process); return cwd; }; try { process.cwd(); } catch (er) { } if (typeof process.chdir === "function") { chdir = process.chdir; process.chdir = function(d3) { cwd = null; chdir.call(process, d3); }; if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir); } var chdir; module2.exports = patch; function patch(fs) { if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { patchLchmod(fs); } if (!fs.lutimes) { patchLutimes(fs); } fs.chown = chownFix(fs.chown); fs.fchown = chownFix(fs.fchown); fs.lchown = chownFix(fs.lchown); fs.chmod = chmodFix(fs.chmod); fs.fchmod = chmodFix(fs.fchmod); fs.lchmod = chmodFix(fs.lchmod); fs.chownSync = chownFixSync(fs.chownSync); fs.fchownSync = chownFixSync(fs.fchownSync); fs.lchownSync = chownFixSync(fs.lchownSync); fs.chmodSync = chmodFixSync(fs.chmodSync); fs.fchmodSync = chmodFixSync(fs.fchmodSync); fs.lchmodSync = chmodFixSync(fs.lchmodSync); fs.stat = statFix(fs.stat); fs.fstat = statFix(fs.fstat); fs.lstat = statFix(fs.lstat); fs.statSync = statFixSync(fs.statSync); fs.fstatSync = statFixSync(fs.fstatSync); fs.lstatSync = statFixSync(fs.lstatSync); if (fs.chmod && !fs.lchmod) { fs.lchmod = function(path, mode, cb) { if (cb) process.nextTick(cb); }; fs.lchmodSync = function() { }; } if (fs.chown && !fs.lchown) { fs.lchown = function(path, uid, gid, cb) { if (cb) process.nextTick(cb); }; fs.lchownSync = function() { }; } if (platform === "win32") { fs.rename = typeof fs.rename !== "function" ? fs.rename : function(fs$rename) { function rename(from, to, cb) { var start = Date.now(); var backoff = 0; fs$rename(from, to, function CB(er) { if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) { setTimeout(function() { fs.stat(to, function(stater, st) { if (stater && stater.code === "ENOENT") fs$rename(from, to, CB); else cb(er); }); }, backoff); if (backoff < 100) backoff += 10; return; } if (cb) cb(er); }); } if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename); return rename; }(fs.rename); } fs.read = typeof fs.read !== "function" ? fs.read : function(fs$read) { function read(fd, buffer, offset, length, position, callback_) { var callback; if (callback_ && typeof callback_ === "function") { var eagCounter = 0; callback = function(er, _2, __) { if (er && er.code === "EAGAIN" && eagCounter < 10) { eagCounter++; return fs$read.call(fs, fd, buffer, offset, length, position, callback); } callback_.apply(this, arguments); }; } return fs$read.call(fs, fd, buffer, offset, length, position, callback); } if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read); return read; }(fs.read); fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ function(fs$readSync) { return function(fd, buffer, offset, length, position) { var eagCounter = 0; while (true) { try { return fs$readSync.call(fs, fd, buffer, offset, length, position); } catch (er) { if (er.code === "EAGAIN" && eagCounter < 10) { eagCounter++; continue; } throw er; } } }; }(fs.readSync); function patchLchmod(fs2) { fs2.lchmod = function(path, mode, callback) { fs2.open( path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) { if (err) { if (callback) callback(err); return; } fs2.fchmod(fd, mode, function(err2) { fs2.close(fd, function(err22) { if (callback) callback(err2 || err22); }); }); } ); }; fs2.lchmodSync = function(path, mode) { var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode); var threw = true; var ret; try { ret = fs2.fchmodSync(fd, mode); threw = false; } finally { if (threw) { try { fs2.closeSync(fd); } catch (er) { } } else { fs2.closeSync(fd); } } return ret; }; } function patchLutimes(fs2) { if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) { fs2.lutimes = function(path, at, mt, cb) { fs2.open(path, constants.O_SYMLINK, function(er, fd) { if (er) { if (cb) cb(er); return; } fs2.futimes(fd, at, mt, function(er2) { fs2.close(fd, function(er22) { if (cb) cb(er2 || er22); }); }); }); }; fs2.lutimesSync = function(path, at, mt) { var fd = fs2.openSync(path, constants.O_SYMLINK); var ret; var threw = true; try { ret = fs2.futimesSync(fd, at, mt); threw = false; } finally { if (threw) { try { fs2.closeSync(fd); } catch (er) { } } else { fs2.closeSync(fd); } } return ret; }; } else if (fs2.futimes) { fs2.lutimes = function(_a2, _b, _c, cb) { if (cb) process.nextTick(cb); }; fs2.lutimesSync = function() { }; } } function chmodFix(orig) { if (!orig) return orig; return function(target, mode, cb) { return orig.call(fs, target, mode, function(er) { if (chownErOk(er)) er = null; if (cb) cb.apply(this, arguments); }); }; } function chmodFixSync(orig) { if (!orig) return orig; return function(target, mode) { try { return orig.call(fs, target, mode); } catch (er) { if (!chownErOk(er)) throw er; } }; } function chownFix(orig) { if (!orig) return orig; return function(target, uid, gid, cb) { return orig.call(fs, target, uid, gid, function(er) { if (chownErOk(er)) er = null; if (cb) cb.apply(this, arguments); }); }; } function chownFixSync(orig) { if (!orig) return orig; return function(target, uid, gid) { try { return orig.call(fs, target, uid, gid); } catch (er) { if (!chownErOk(er)) throw er; } }; } function statFix(orig) { if (!orig) return orig; return function(target, options, cb) { if (typeof options === "function") { cb = options; options = null; } function callback(er, stats) { if (stats) { if (stats.uid < 0) stats.uid += 4294967296; if (stats.gid < 0) stats.gid += 4294967296; } if (cb) cb.apply(this, arguments); } return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback); }; } function statFixSync(orig) { if (!orig) return orig; return function(target, options) { var stats = options ? orig.call(fs, target, options) : orig.call(fs, target); if (stats) { if (stats.uid < 0) stats.uid += 4294967296; if (stats.gid < 0) stats.gid += 4294967296; } return stats; }; } function chownErOk(er) { if (!er) return true; if (er.code === "ENOSYS") return true; var nonroot = !process.getuid || process.getuid() !== 0; if (nonroot) { if (er.code === "EINVAL" || er.code === "EPERM") return true; } return false; } } } }); // node_modules/aws-cdk-lib/node_modules/graceful-fs/legacy-streams.js var require_legacy_streams = __commonJS({ "node_modules/aws-cdk-lib/node_modules/graceful-fs/legacy-streams.js"(exports2, module2) { var Stream = require("stream").Stream; module2.exports = legacy; function legacy(fs) { return { ReadStream, WriteStream }; function ReadStream(path, options) { if (!(this instanceof ReadStream)) return new ReadStream(path, options); Stream.call(this); var self2 = this; this.path = path; this.fd = null; this.readable = true; this.paused = false; this.flags = "r"; this.mode = 438; this.bufferSize = 64 * 1024; options = options || {}; var keys = Object.keys(options); for (var index = 0, length = keys.length; index < length; index++) { var key = keys[index]; this[key] = options[key]; } if (this.encoding) this.setEncoding(this.encoding); if (this.start !== void 0) { if ("number" !== typeof this.start) { throw TypeError("start must be a Number"); } if (this.end === void 0) { this.end = Infinity; } else if ("number" !== typeof this.end) { throw TypeError("end must be a Number"); } if (this.start > this.end) { throw new Error("start must be <= end"); } this.pos = this.start; } if (this.fd !== null) { process.nextTick(function() { self2._read(); }); return; } fs.open(this.path, this.flags, this.mode, function(err, fd) { if (err) { self2.emit("error", err); self2.readable = false; return; } self2.fd = fd; self2.emit("open", fd); self2._read(); }); } function WriteStream(path, options) { if (!(this instanceof WriteStream)) return new WriteStream(path, options); Stream.call(this); this.path = path; this.fd = null; this.writable = true; this.flags = "w"; this.encoding = "binary"; this.mode = 438; this.bytesWritten = 0; options = options || {}; var keys = Object.keys(options); for (var index = 0, length = keys.length; index < length; index++) { var key = keys[index]; this[key] = options[key]; } if (this.start !== void 0) { if ("number" !== typeof this.start) { throw TypeError("start must be a Number"); } if (this.start < 0) { throw new Error("start must be >= zero"); } this.pos = this.start; } this.busy = false; this._queue = []; if (this.fd === null) { this._open = fs.open; this._queue.push([this._open, this.path, this.flags, this.mode, void 0]); this.flush(); } } } } }); // node_modules/aws-cdk-lib/node_modules/graceful-fs/clone.js var require_clone = __commonJS({ "node_modules/aws-cdk-lib/node_modules/graceful-fs/clone.js"(exports2, module2) { "use strict"; module2.exports = clone; var getPrototypeOf = Object.getPrototypeOf || function(obj) { return obj.__proto__; }; function clone(obj) { if (obj === null || typeof obj !== "object") return obj; if (obj instanceof Object) var copy = { __proto__: getPrototypeOf(obj) }; else var copy = /* @__PURE__ */ Object.create(null); Object.getOwnPropertyNames(obj).forEach(function(key) { Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key)); }); return copy; } } }); // node_modules/aws-cdk-lib/node_modules/graceful-fs/graceful-fs.js var require_graceful_fs = __commonJS({ "node_modules/aws-cdk-lib/node_modules/graceful-fs/graceful-fs.js"(exports2, module2) { var fs = require("fs"); var polyfills = require_polyfills(); var legacy = require_legacy_streams(); var clone = require_clone(); var util = require("util"); var gracefulQueue; var previousSymbol; if (typeof Symbol === "function" && typeof Symbol.for === "function") { gracefulQueue = Symbol.for("graceful-fs.queue"); previousSymbol = Symbol.for("graceful-fs.previous"); } else { gracefulQueue = "___graceful-fs.queue"; previousSymbol = "___graceful-fs.previous"; } function noop() { } function publishQueue(context, queue2) { Object.defineProperty(context, gracefulQueue, { get: function() { return queue2; } }); } var debug = noop; if (util.debuglog) debug = util.debuglog("gfs4"); else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() { var m3 = util.format.apply(util, arguments); m3 = "GFS4: " + m3.split(/\n/).join("\nGFS4: "); console.error(m3); }; if (!fs[gracefulQueue]) { queue = global[gracefulQueue] || []; publishQueue(fs, queue); fs.close = function(fs$close) { function close(fd, cb) { return fs$close.call(fs, fd, function(err) { if (!err) { resetQueue(); } if (typeof cb === "function") cb.apply(this, arguments); }); } Object.defineProperty(close, previousSymbol, { value: fs$close }); return close; }(fs.close); fs.closeSync = function(fs$closeSync) { function closeSync(fd) { fs$closeSync.apply(fs, arguments); resetQueue(); } Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync }); return closeSync; }(fs.closeSync); if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) { process.on("exit", function() { debug(fs[gracefulQueue]); require("assert").equal(fs[gracefulQueue].length, 0); }); } } var queue; if (!global[gracefulQueue]) { publishQueue(global, fs[gracefulQueue]); } module2.exports = patch(clone(fs)); if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) { module2.exports = patch(fs); fs.__patched = true; } function patch(fs2) { polyfills(fs2); fs2.gracefulify = patch; fs2.createReadStream = createReadStream; fs2.createWriteStream = createWriteStream; var fs$readFile = fs2.readFile; fs2.readFile = readFile; function readFile(path, options, cb) { if (typeof options === "function") cb = options, options = null; return go$readFile(path, options, cb); function go$readFile(path2, options2, cb2, startTime) { return fs$readFile(path2, options2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$writeFile = fs2.writeFile; fs2.writeFile = writeFile; function writeFile(path, data, options, cb) { if (typeof options === "function") cb = options, options = null; return go$writeFile(path, data, options, cb); function go$writeFile(path2, data2, options2, cb2, startTime) { return fs$writeFile(path2, data2, options2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$appendFile = fs2.appendFile; if (fs$appendFile) fs2.appendFile = appendFile; function appendFile(path, data, options, cb) { if (typeof options === "function") cb = options, options = null; return go$appendFile(path, data, options, cb); function go$appendFile(path2, data2, options2, cb2, startTime) { return fs$appendFile(path2, data2, options2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$copyFile = fs2.copyFile; if (fs$copyFile) fs2.copyFile = copyFile; function copyFile(src, dest, flags, cb) { if (typeof flags === "function") { cb = flags; flags = 0; } return go$copyFile(src, dest, flags, cb); function go$copyFile(src2, dest2, flags2, cb2, startTime) { return fs$copyFile(src2, dest2, flags2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$readdir = fs2.readdir; fs2.readdir = readdir; var noReaddirOptionVersions = /^v[0-5]\./; function readdir(path, options, cb) { if (typeof options === "function") cb = options, options = null; var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) { return fs$readdir(path2, fs$readdirCallback( path2, options2, cb2, startTime )); } : function go$readdir2(path2, options2, cb2, startTime) { return fs$readdir(path2, options2, fs$readdirCallback( path2, options2, cb2, startTime )); }; return go$readdir(path, options, cb); function fs$readdirCallback(path2, options2, cb2, startTime) { return function(err, files) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([ go$readdir, [path2, options2, cb2], err, startTime || Date.now(), Date.now() ]); else { if (files && files.sort) files.sort(); if (typeof cb2 === "function") cb2.call(this, err, files); } }; } } if (process.version.substr(0, 4) === "v0.8") { var legStreams = legacy(fs2); ReadStream = legStreams.ReadStream; WriteStream = legStreams.WriteStream; } var fs$ReadStream = fs2.ReadStream; if (fs$ReadStream) { ReadStream.prototype = Object.create(fs$ReadStream.prototype); ReadStream.prototype.open = ReadStream$open; } var fs$WriteStream = fs2.WriteStream; if (fs$WriteStream) { WriteStream.prototype = Object.create(fs$WriteStream.prototype); WriteStream.prototype.open = WriteStream$open; } Object.defineProperty(fs2, "ReadStream", { get: function() { return ReadStream; }, set: function(val2) { ReadStream = val2; }, enumerable: true, configurable: true }); Object.defineProperty(fs2, "WriteStream", { get: function() { return WriteStream; }, set: function(val2) { WriteStream = val2; }, enumerable: true, configurable: true }); var FileReadStream = ReadStream; Object.defineProperty(fs2, "FileReadStream", { get: function() { return FileReadStream; }, set: function(val2) { FileReadStream = val2; }, enumerable: true, configurable: true }); var FileWriteStream = WriteStream; Object.defineProperty(fs2, "FileWriteStream", { get: function() { return FileWriteStream; }, set: function(val2) { FileWriteStream = val2; }, enumerable: true, configurable: true }); function ReadStream(path, options) { if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this; else return ReadStream.apply(Object.create(ReadStream.prototype), arguments); } function ReadStream$open() { var that = this; open(that.path, that.flags, that.mode, function(err, fd) { if (err) { if