cdk-insights 1.37.2 → 1.37.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ ${JSON.stringify(Q)}`}).join(`
77
77
  `)!=-1,n=this._styles,r=n.length;r--;){var i=Cn[n[r]];t=i.open+t.replace(i.closeRe,i.open)+i.close,s&&(t=t.replace(TL,function(o){return i.close+o+i.open}))}return t}ve.setTheme=function(e){if(typeof e=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var t in e)(function(s){ve[s]=function(n){if(typeof e[s]=="object"){var r=n;for(var i in e[s])r=ve[e[s][i]](r);return r}return ve[e[s]](n)}})(t)};function BL(){var e={};return Object.keys(Av).forEach(function(t){e[t]={get:function(){return Cv([t])}}}),e}var ML=function(t,s){var n=s.split("");return n=n.map(t),n.join("")};ve.trap=uv();ve.zalgo=pv();ve.maps={};ve.maps.america=mv()(ve);ve.maps.zebra=gv()(ve);ve.maps.rainbow=yv()(ve);ve.maps.random=bv()(ve);for(Dv in ve.maps)(function(e){ve[e]=function(t){return ML(ve.maps[e],t)}})(Dv);var Dv;vv(ve,BL())});var Fv=T((CV,Ev)=>{var NL=wv();Ev.exports=NL});var Tv=T((AV,ra)=>{var{info:WL,debug:kv}=sa(),Ft=xl(),Fl=class e{constructor(t){this.setOptions(t),this.x=null,this.y=null}setOptions(t){["boolean","number","bigint","string"].indexOf(typeof t)!==-1&&(t={content:""+t}),t=t||{},this.options=t;let s=t.content;if(["boolean","number","bigint","string"].indexOf(typeof s)!==-1)this.content=String(s);else if(!s)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof s);this.colSpan=t.colSpan||1,this.rowSpan=t.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(t,s){this.cells=s;let n=this.options.chars||{},r=t.chars,i=this.chars={};jL.forEach(function(u){El(n,r,u,i)}),this.truncate=this.options.truncate||t.truncate;let o=this.options.style=this.options.style||{},a=t.style;El(o,a,"padding-left",this),El(o,a,"padding-right",this),this.head=o.head||a.head,this.border=o.border||a.border,this.fixedWidth=t.colWidths[this.x],this.lines=this.computeLines(t),this.desiredWidth=Ft.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(t){let s=t.wordWrap||t.textWrap,{wordWrap:n=s}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let o=1;for(;o<this.colSpan;)this.fixedWidth+=t.colWidths[this.x+o],o++}let{wrapOnWordBoundary:r=!0}=t,{wrapOnWordBoundary:i=r}=this.options;return this.wrapLines(Ft.wordWrap(this.fixedWidth,this.content,i))}return this.wrapLines(this.content.split(`
78
78
  `))}wrapLines(t){let s=Ft.colorizeLines(t);return this.href?s.map(n=>Ft.hyperlink(this.href,n)):s}init(t){let s=this.x,n=this.y;this.widths=t.colWidths.slice(s,s+this.colSpan),this.heights=t.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(Iv,-1),this.height=this.heights.reduce(Iv,-1),this.hAlign=this.options.hAlign||t.colAligns[s],this.vAlign=this.options.vAlign||t.rowAligns[n],this.drawRight=s+this.colSpan==t.colWidths.length}draw(t,s){if(t=="top")return this.drawTop(this.drawRight);if(t=="bottom")return this.drawBottom(this.drawRight);let n=Ft.truncate(this.content,10,this.truncate);t||WL(`${this.y}-${this.x}: ${this.rowSpan-t}x${this.colSpan} Cell ${n}`);let r=Math.max(this.height-this.lines.length,0),i;switch(this.vAlign){case"center":i=Math.ceil(r/2);break;case"bottom":i=r;break;default:i=0}if(t<i||t>=i+this.lines.length)return this.drawEmpty(this.drawRight,s);let o=this.lines.length>this.height&&t+1>=this.height;return this.drawLine(t-i,this.drawRight,o,s)}drawTop(t){let s=[];return this.cells?this.widths.forEach(function(n,r){s.push(this._topLeftChar(r)),s.push(Ft.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(s.push(this._topLeftChar(0)),s.push(Ft.repeat(this.chars[this.y==0?"top":"mid"],this.width))),t&&s.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",s.join(""))}_topLeftChar(t){let s=this.x+t,n;if(this.y==0)n=s==0?"topLeft":t==0?"topMid":"top";else if(s==0)n="leftMid";else if(n=t==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][s]instanceof e.ColSpanCell&&(n=t==0?"topMid":"mid"),t==0)){let i=1;for(;this.cells[this.y][s-i]instanceof e.ColSpanCell;)i++;this.cells[this.y][s-i]instanceof e.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(t,s){if(this[t]&&this[t].length)try{let n=Fv();for(let r=this[t].length-1;r>=0;r--)n=n[this[t][r]];return n(s)}catch{return s}else return s}drawLine(t,s,n,r){let i=this.chars[this.x==0?"left":"middle"];if(this.x&&r&&this.cells){let d=this.cells[this.y+r][this.x-1];for(;d instanceof di;)d=this.cells[d.y][d.x-1];d instanceof mi||(i=this.chars.rightMid)}let o=Ft.repeat(" ",this.paddingLeft),a=s?this.chars.right:"",u=Ft.repeat(" ",this.paddingRight),c=this.lines[t],l=this.width-(this.paddingLeft+this.paddingRight);n&&(c+=this.truncate||"\u2026");let p=Ft.truncate(c,l,this.truncate);return p=Ft.pad(p,l," ",this.hAlign),p=o+p+u,this.stylizeLine(i,p,a)}stylizeLine(t,s,n){return t=this.wrapWithStyleColors("border",t),n=this.wrapWithStyleColors("border",n),this.y===0&&(s=this.wrapWithStyleColors("head",s)),t+s+n}drawBottom(t){let s=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=Ft.repeat(this.chars.bottom,this.width),r=t?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",s+n+r)}drawEmpty(t,s){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&s&&this.cells){let o=this.cells[this.y+s][this.x-1];for(;o instanceof di;)o=this.cells[o.y][o.x-1];o instanceof mi||(n=this.chars.rightMid)}let r=t?this.chars.right:"",i=Ft.repeat(" ",this.width);return this.stylizeLine(n,i,r)}},di=class{constructor(){}draw(t){return typeof t=="number"&&kv(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},mi=class{constructor(t){this.originalCell=t}init(t){let s=this.y,n=this.originalCell.y;this.cellOffset=s-n,this.offset=UL(t.rowHeights,n,this.cellOffset)}draw(t){return t=="top"?this.originalCell.draw(this.offset,this.cellOffset):t=="bottom"?this.originalCell.draw("bottom"):(kv(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+t))}mergeTableOptions(){}};function Rv(...e){return e.filter(t=>t!=null).shift()}function El(e,t,s,n){let r=s.split("-");r.length>1?(r[1]=r[1].charAt(0).toUpperCase()+r[1].substr(1),r=r.join(""),n[r]=Rv(e[r],e[s],t[r],t[s])):n[s]=Rv(e[s],t[s])}function UL(e,t,s){let n=e[t];for(let r=1;r<s;r++)n+=1+e[t+r];return n}function Iv(e,t){return e+t+1}var jL=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];ra.exports=Fl;ra.exports.ColSpanCell=di;ra.exports.RowSpanCell=mi});var _v=T((xV,Lv)=>{var{warn:$L,debug:GL}=sa(),Rl=Tv(),{ColSpanCell:HL,RowSpanCell:zL}=Rl;(function(){function e(m,f){return m[f]>0?e(m,f+1):f}function t(m){let f={};m.forEach(function(g,h){let y=0;g.forEach(function(b){b.y=h,b.x=h?e(f,y):y;let C=b.rowSpan||1,v=b.colSpan||1;if(C>1)for(let I=0;I<v;I++)f[b.x+I]=C;y=b.x+v}),Object.keys(f).forEach(b=>{f[b]--,f[b]<1&&delete f[b]})})}function s(m){let f=0;return m.forEach(function(g){g.forEach(function(h){f=Math.max(f,h.x+(h.colSpan||1))})}),f}function n(m){return m.length}function r(m,f){let g=m.y,h=m.y-1+(m.rowSpan||1),y=f.y,b=f.y-1+(f.rowSpan||1),C=!(g>b||y>h),v=m.x,I=m.x-1+(m.colSpan||1),N=f.x,B=f.x-1+(f.colSpan||1),F=!(v>B||N>I);return C&&F}function i(m,f,g){let h=Math.min(m.length-1,g),y={x:f,y:g};for(let b=0;b<=h;b++){let C=m[b];for(let v=0;v<C.length;v++)if(r(y,C[v]))return!0}return!1}function o(m,f,g,h){for(let y=g;y<h;y++)if(i(m,y,f))return!1;return!0}function a(m){m.forEach(function(f,g){f.forEach(function(h){for(let y=1;y<h.rowSpan;y++){let b=new zL(h);b.x=h.x,b.y=h.y+y,b.colSpan=h.colSpan,c(b,m[g+y])}})})}function u(m){for(let f=m.length-1;f>=0;f--){let g=m[f];for(let h=0;h<g.length;h++){let y=g[h];for(let b=1;b<y.colSpan;b++){let C=new HL;C.x=y.x+b,C.y=y.y,g.splice(h+1,0,C)}}}}function c(m,f){let g=0;for(;g<f.length&&f[g].x<m.x;)g++;f.splice(g,0,m)}function l(m){let f=n(m),g=s(m);GL(`Max rows: ${f}; Max cols: ${g}`);for(let h=0;h<f;h++)for(let y=0;y<g;y++)if(!i(m,y,h)){let b={x:y,y:h,colSpan:1,rowSpan:1};for(y++;y<g&&!i(m,y,h);)b.colSpan++,y++;let C=h+1;for(;C<f&&o(m,C,b.x,b.x+b.colSpan);)b.rowSpan++,C++;let v=new Rl(b);v.x=b.x,v.y=b.y,$L(`Missing cell at ${v.y}-${v.x}.`),c(v,m[h])}}function p(m){return m.map(function(f){if(!Array.isArray(f)){let g=Object.keys(f)[0];f=f[g],Array.isArray(f)?(f=f.slice(),f.unshift(g)):f=[g,f]}return f.map(function(g){return new Rl(g)})})}function d(m){let f=p(m);return t(f),l(f),a(f),u(f),f}Lv.exports={makeTableLayout:d,layoutTable:t,addRowSpanCells:a,maxWidth:s,fillInTable:l,computeWidths:Pv("colSpan","desiredWidth","x",1),computeHeights:Pv("rowSpan","desiredHeight","y",1)}})();function Pv(e,t,s,n){return function(r,i){let o=[],a=[],u={};i.forEach(function(c){c.forEach(function(l){(l[e]||1)>1?a.push(l):o[l[s]]=Math.max(o[l[s]]||0,l[t]||0,n)})}),r.forEach(function(c,l){typeof c=="number"&&(o[l]=c)});for(let c=a.length-1;c>=0;c--){let l=a[c],p=l[e],d=l[s],m=o[d],f=typeof r[d]=="number"?0:1;if(typeof m=="number")for(let g=1;g<p;g++)m+=1+o[d+g],typeof r[d+g]!="number"&&f++;else m=t==="desiredWidth"?l.desiredWidth-1:1,(!u[d]||u[d]<m)&&(u[d]=m);if(l[t]>m){let g=0;for(;f>0&&l[t]>m;){if(typeof r[d+g]!="number"){let h=Math.round((l[t]-m)/f);m+=h,o[d+g]+=h,f--}g++}}}Object.assign(r,o,u);for(let c=0;c<r.length;c++)r[c]=Math.max(n,r[c]||0)}}});var Bv=T((wV,Ov)=>{var Ss=sa(),qL=xl(),Il=_v(),ia=class extends Array{constructor(t){super();let s=qL.mergeOptions(t);if(Object.defineProperty(this,"options",{value:s,enumerable:s.debug}),s.debug){switch(typeof s.debug){case"boolean":Ss.setDebugLevel(Ss.WARN);break;case"number":Ss.setDebugLevel(s.debug);break;case"string":Ss.setDebugLevel(parseInt(s.debug,10));break;default:Ss.setDebugLevel(Ss.WARN),Ss.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof s.debug}`)}Object.defineProperty(this,"messages",{get(){return Ss.debugMessages()}})}}toString(){let t=this,s=this.options.head&&this.options.head.length;s?(t=[this.options.head],this.length&&t.push.apply(t,this)):this.options.style.head=[];let n=Il.makeTableLayout(t);n.forEach(function(i){i.forEach(function(o){o.mergeTableOptions(this.options,n)},this)},this),Il.computeWidths(this.options.colWidths,n),Il.computeHeights(this.options.rowHeights,n),n.forEach(function(i){i.forEach(function(o){o.init(this.options)},this)},this);let r=[];for(let i=0;i<n.length;i++){let o=n[i],a=this.options.rowHeights[i];(i===0||!this.options.style.compact||i==1&&s)&&kl(o,"top",r);for(let u=0;u<a;u++)kl(o,u,r);i+1==n.length&&kl(o,"bottom",r)}return r.join(`
79
79
  `)}get width(){return this.toString().split(`
80
- `)[0].length}};ia.reset=()=>Ss.reset();function kl(e,t,s){let n=[];e.forEach(function(i){n.push(i.draw(t))});let r=n.join("");r.length&&s.push(r)}Ov.exports=ia});var Nv=T((EV,Mv)=>{Mv.exports=Bv()});var Tl=T((RV,YL)=>{YL.exports={name:"cdk-insights",version:"1.37.2",description:"AWS CDK security and cost analysis CLI. Free static scans via npm \u2014 no account needed. Sign up free to add AI-powered insights.",main:"dist/index.js",types:"dist/index.d.ts",bin:{"cdk-insights":"dist/entry.js"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.js"}},files:["dist/**/*","README.md","LICENSE"],scripts:{test:"vitest --run",lint:"biome lint src/",typecheck:"tsc --noEmit",format:"biome format --write src/",check:"biome check src/","check:schema-sync":"ts-node scripts/check-schema-sync.ts",build:"ts-node scripts/build.ts","build:dev":"CDK_INSIGHTS_ENVIRONMENT=dev CDK_INSIGHTS_API_URL=https://s2zhmjbwlj.execute-api.eu-west-2.amazonaws.com/v1 ts-node scripts/build.ts",start:"node dist/index.js",dev:"ts-node src/index.ts",prepare:"husky install && npm run build","start:dev":"CDK_ENV=local ts-node src/index.ts","ai-run":"ts-node src/index.ts",unlink:"npm unlink -g cdk-insights",link:"npm link","prepare:test":"npm run unlink && npm run build && npm run link","prepare:dev":"npm run unlink && npm run build:dev && npm run link","deploy:dev":"STAGE=dev cdk deploy","destroy:dev":"STAGE=dev cdk destroy","release:patch":"bumper release patch","release:minor":"bumper release minor","release:major":"bumper release major","release:dry-run":"bumper release patch --dry-run","changelog:preview":"bumper preview","changelog:generate":"bumper generate","validate:commits":"bumper validate","release:check":"npm run validate:commits && npm run test && npm run build","release:full":"npm run release:check && npm run changelog:generate","setup:bumper":"bumper setup","publish:beta":"npm run build && npm publish --tag beta && npm dist-tag add cdk-insights@$npm_package_version latest","publish:alpha":"npm run build && npm publish --tag alpha","publish:canary":"npm run build && npm publish --tag canary","publish:latest":"npm run build && npm publish --tag latest","version:beta":"npm version prerelease --preid=beta","version:alpha":"npm version prerelease --preid=alpha","version:rc":"npm version prerelease --preid=rc","cdk-insights":"node scripts/cdk-insights-wrapper.js",scan:"node scripts/cdk-insights-wrapper.js scan","scan:all":"node scripts/cdk-insights-wrapper.js scan --all","scan:json":"node scripts/cdk-insights-wrapper.js scan --format json","scan:markdown":"node scripts/cdk-insights-wrapper.js scan --format markdown","scan:summary":"node scripts/cdk-insights-wrapper.js scan --format summary","scan:with-issues":"node scripts/cdk-insights-wrapper.js scan --withIssue","cache:clear":"node scripts/cdk-insights-wrapper.js cache clear","cache:status":"node scripts/cdk-insights-wrapper.js cache status","demo:progress":"ts-node src/examples/progress-demo.ts","demo:single-line":"ts-node src/examples/single-line-progress-demo.ts","test:line-clearing":"ts-node src/examples/line-clearing-test.ts"},publishConfig:{access:"public"},keywords:["aws","cdk","cloudformation","analysis","security","cost-optimization","static-analysis","devops","infrastructure","aws-cdk","cloud-security","compliance"],author:"Lee Priest <lee@cdkinsights.dev>",license:"BUSL-1.1",homepage:"https://github.com/instancelabs/cdk-insights",bugs:"https://github.com/instancelabs/cdk-insights/issues",repository:{type:"git",url:"git+https://github.com/instancelabs/cdk-insights.git"},dependencies:{"@inquirer/prompts":"^7.4.1","@middy/core":"^6.1.6","@types/glob":"^8.1.0",axios:"^1.8.4",chalk:"^5.4.1",chokidar:"^3.6.0","cli-progress":"^3.12.0","cli-table3":"^0.6.5",dotenv:"^16.5.0",envolution:"^1.4.1",glob:"^11.0.3",ora:"^8.2.0",strogger:"^2.0.3",yargs:"^17.7.2",zod:"^3.23.8"},devDependencies:{"@aws-sdk/client-dynamodb":"^3.788.0","@biomejs/biome":"^2.0.6","@commitlint/cli":"^19.8.1","@commitlint/config-conventional":"^19.8.1","@types/cli-progress":"^3.11.6","@types/jsonwebtoken":"^9.0.9","@types/node":"^22.14.1","@types/yargs":"^17.0.33","aws-cdk":"^2.1010.0","bumper-cli":"^1.6.0",esbuild:"^0.25.2",husky:"^8.0.3","ts-node":"^10.9.2",typescript:"^5.8.3",vitest:"^3.1.1"},peerDependencies:{"aws-cdk-lib":"^2.190.0","cdk-nag":"^2.35.73",constructs:"^10.4.2"},optionalDependencies:{"@aws-solutions-constructs/aws-apigateway-lambda":"^2.0.0","@aws-solutions-constructs/aws-lambda-stepfunctions":"^2.0.0","@aws-solutions-constructs/aws-s3-lambda":"^2.0.0"}}});var cC={};Ci(cC,{STACK_TRACE_CONTEXT_KEY:()=>ga,ensureStackTraceInCdkJson:()=>I_,isStackTraceContextEnabledInCdkJson:()=>k_,patchCdkJsonForStackTrace:()=>aC});var Os,zl,ga,aC,I_,k_,uC=Xl(()=>{"use strict";Os=K(require("node:fs")),zl=K(require("node:path")),ga="@aws-cdk/core:stackTrace",aC=e=>{let t;try{t=JSON.parse(e)}catch{return{status:"invalid-json"}}if(t===null||typeof t!="object"||Array.isArray(t))return{status:"invalid-json"};let s=t,n=s.context,r=n&&typeof n=="object"&&!Array.isArray(n)?{...n}:{};if(r[ga]===!0)return{status:"already-set",updated:e};r[ga]=!0;let i={...s,context:r},o=e.endsWith(`
80
+ `)[0].length}};ia.reset=()=>Ss.reset();function kl(e,t,s){let n=[];e.forEach(function(i){n.push(i.draw(t))});let r=n.join("");r.length&&s.push(r)}Ov.exports=ia});var Nv=T((EV,Mv)=>{Mv.exports=Bv()});var Tl=T((RV,YL)=>{YL.exports={name:"cdk-insights",version:"1.37.4",description:"AWS CDK security and cost analysis CLI. Free static scans via npm \u2014 no account needed. Sign up free to add AI-powered insights.",main:"dist/index.js",types:"dist/index.d.ts",bin:{"cdk-insights":"dist/entry.js"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.js"}},files:["dist/**/*","README.md","LICENSE"],scripts:{test:"vitest --run",lint:"biome lint src/",typecheck:"tsc --noEmit",format:"biome format --write src/",check:"biome check src/","check:schema-sync":"ts-node scripts/check-schema-sync.ts",build:"ts-node scripts/build.ts","build:dev":"CDK_INSIGHTS_ENVIRONMENT=dev CDK_INSIGHTS_API_URL=https://s2zhmjbwlj.execute-api.eu-west-2.amazonaws.com/v1 ts-node scripts/build.ts",start:"node dist/index.js",dev:"ts-node src/index.ts",prepare:"husky install && npm run build","start:dev":"CDK_ENV=local ts-node src/index.ts","ai-run":"ts-node src/index.ts",unlink:"npm unlink -g cdk-insights",link:"npm link","prepare:test":"npm run unlink && npm run build && npm run link","prepare:dev":"npm run unlink && npm run build:dev && npm run link","deploy:dev":"STAGE=dev cdk deploy","destroy:dev":"STAGE=dev cdk destroy","release:patch":"bumper release patch","release:minor":"bumper release minor","release:major":"bumper release major","release:dry-run":"bumper release patch --dry-run","changelog:preview":"bumper preview","changelog:generate":"bumper generate","validate:commits":"bumper validate","release:check":"npm run validate:commits && npm run test && npm run build","release:full":"npm run release:check && npm run changelog:generate","setup:bumper":"bumper setup","publish:beta":"npm run build && npm publish --tag beta && npm dist-tag add cdk-insights@$npm_package_version latest","publish:alpha":"npm run build && npm publish --tag alpha","publish:canary":"npm run build && npm publish --tag canary","publish:latest":"npm run build && npm publish --tag latest","version:beta":"npm version prerelease --preid=beta","version:alpha":"npm version prerelease --preid=alpha","version:rc":"npm version prerelease --preid=rc","cdk-insights":"node scripts/cdk-insights-wrapper.js",scan:"node scripts/cdk-insights-wrapper.js scan","scan:all":"node scripts/cdk-insights-wrapper.js scan --all","scan:json":"node scripts/cdk-insights-wrapper.js scan --format json","scan:markdown":"node scripts/cdk-insights-wrapper.js scan --format markdown","scan:summary":"node scripts/cdk-insights-wrapper.js scan --format summary","scan:with-issues":"node scripts/cdk-insights-wrapper.js scan --withIssue","cache:clear":"node scripts/cdk-insights-wrapper.js cache clear","cache:status":"node scripts/cdk-insights-wrapper.js cache status","demo:progress":"ts-node src/examples/progress-demo.ts","demo:single-line":"ts-node src/examples/single-line-progress-demo.ts","test:line-clearing":"ts-node src/examples/line-clearing-test.ts"},publishConfig:{access:"public"},keywords:["aws","cdk","cloudformation","analysis","security","cost-optimization","static-analysis","devops","infrastructure","aws-cdk","cloud-security","compliance"],author:"Lee Priest <lee@cdkinsights.dev>",license:"BUSL-1.1",homepage:"https://github.com/instancelabs/cdk-insights",bugs:"https://github.com/instancelabs/cdk-insights/issues",repository:{type:"git",url:"git+https://github.com/instancelabs/cdk-insights.git"},dependencies:{"@inquirer/prompts":"^7.4.1","@middy/core":"^6.1.6","@types/glob":"^8.1.0",axios:"^1.8.4",chalk:"^5.4.1",chokidar:"^3.6.0","cli-progress":"^3.12.0","cli-table3":"^0.6.5",dotenv:"^16.5.0",envolution:"^1.4.1",glob:"^11.0.3",ora:"^8.2.0",strogger:"^2.0.3",yargs:"^17.7.2",zod:"^3.23.8"},devDependencies:{"@aws-sdk/client-dynamodb":"^3.788.0","@biomejs/biome":"^2.0.6","@commitlint/cli":"^19.8.1","@commitlint/config-conventional":"^19.8.1","@types/cli-progress":"^3.11.6","@types/jsonwebtoken":"^9.0.9","@types/node":"^22.14.1","@types/yargs":"^17.0.33","aws-cdk":"^2.1010.0","bumper-cli":"^1.6.0",esbuild:"^0.25.2",husky:"^8.0.3","ts-node":"^10.9.2",typescript:"^5.8.3",vitest:"^3.1.1"},peerDependencies:{"aws-cdk-lib":"^2.190.0","cdk-nag":"^2.35.73",constructs:"^10.4.2"},optionalDependencies:{"@aws-solutions-constructs/aws-apigateway-lambda":"^2.0.0","@aws-solutions-constructs/aws-lambda-stepfunctions":"^2.0.0","@aws-solutions-constructs/aws-s3-lambda":"^2.0.0"}}});var cC={};Ci(cC,{STACK_TRACE_CONTEXT_KEY:()=>ga,ensureStackTraceInCdkJson:()=>I_,isStackTraceContextEnabledInCdkJson:()=>k_,patchCdkJsonForStackTrace:()=>aC});var Os,zl,ga,aC,I_,k_,uC=Xl(()=>{"use strict";Os=K(require("node:fs")),zl=K(require("node:path")),ga="@aws-cdk/core:stackTrace",aC=e=>{let t;try{t=JSON.parse(e)}catch{return{status:"invalid-json"}}if(t===null||typeof t!="object"||Array.isArray(t))return{status:"invalid-json"};let s=t,n=s.context,r=n&&typeof n=="object"&&!Array.isArray(n)?{...n}:{};if(r[ga]===!0)return{status:"already-set",updated:e};r[ga]=!0;let i={...s,context:r},o=e.endsWith(`
81
81
  `)?`
82
82
  `:"";return{status:"added",updated:`${JSON.stringify(i,null,2)}${o}`}},I_=e=>{let t=zl.join(e,"cdk.json");if(!Os.existsSync(t))return{status:"missing",cdkJsonPath:t};let s=Os.readFileSync(t,"utf-8"),n=aC(s);return n.status==="invalid-json"?{status:"invalid-json",cdkJsonPath:t}:n.status==="already-set"?{status:"already-set",cdkJsonPath:t}:(Os.writeFileSync(t,n.updated,"utf-8"),{status:"added",cdkJsonPath:t})},k_=e=>{try{let t=zl.join(e,"cdk.json");if(!Os.existsSync(t))return!1;let s=JSON.parse(Os.readFileSync(t,"utf-8"));if(!s||typeof s!="object"||Array.isArray(s))return!1;let n=s.context;return!n||typeof n!="object"||Array.isArray(n)?!1:n[ga]===!0}catch{return!1}}});var DO={};Ci(DO,{CDK_INSIGHTS_ANNOTATION_PREFIX:()=>va,CDK_INSIGHTS_METADATA_VERSION:()=>Zl,CDK_INSIGHTS_NAG_FINDING_PREFIX:()=>ya,CdkInsightsAspect:()=>Da,CdkInsightsPolicyValidationPlugin:()=>bi,ExtremelyHelpfulConsoleLogger:()=>Si,SCAN_REPORT_SCHEMA_VERSION:()=>DC,clearCaches:()=>SC,createCdkInsightsAspect:()=>yC,createCdkInsightsLogger:()=>gC,createCdkInsightsPolicyValidationPlugin:()=>TC,createExtremelyHelpfulConsoleLogger:()=>hC,getCacheStats:()=>bC,isCdkDebugEnabled:()=>Yl,runAnalysis:()=>bO});module.exports=Ra(DO);var OC=K(require("node:fs"));function Sr(e,t){return function(){return e.apply(t,arguments)}}var{toString:$C}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:wi,toStringTag:sp}=Symbol,Ei=(e=>t=>{let s=$C.call(t);return e[s]||(e[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),$t=e=>(e=e.toLowerCase(),t=>Ei(t)===e),Fi=e=>t=>typeof t===e,{isArray:wn}=Array,xn=Fi("undefined");function br(e){return e!==null&&!xn(e)&&e.constructor!==null&&!xn(e.constructor)&&dt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var np=$t("ArrayBuffer");function GC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&np(e.buffer),t}var HC=Fi("string"),dt=Fi("function"),rp=Fi("number"),Dr=e=>e!==null&&typeof e=="object",zC=e=>e===!0||e===!1,Ai=e=>{if(Ei(e)!=="object")return!1;let t=xi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(sp in e)&&!(wi in e)},qC=e=>{if(!Dr(e)||br(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},VC=$t("Date"),KC=$t("File"),ZC=e=>!!(e&&typeof e.uri<"u"),YC=e=>e&&typeof e.getParts<"u",JC=$t("Blob"),XC=$t("FileList"),QC=e=>Dr(e)&&dt(e.pipe);function eA(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}var ep=eA(),tp=typeof ep.FormData<"u"?ep.FormData:void 0,tA=e=>{if(!e)return!1;if(tp&&e instanceof tp)return!0;let t=xi(e);if(!t||t===Object.prototype||!dt(e.append))return!1;let s=Ei(e);return s==="formdata"||s==="object"&&dt(e.toString)&&e.toString()==="[object FormData]"},sA=$t("URLSearchParams"),[nA,rA,iA,oA]=["ReadableStream","Request","Response","Headers"].map($t),aA=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function vr(e,t,{allOwnKeys:s=!1}={}){if(e===null||typeof e>"u")return;let n,r;if(typeof e!="object"&&(e=[e]),wn(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{if(br(e))return;let i=s?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length,a;for(n=0;n<o;n++)a=i[n],t.call(null,e[a],a,e)}}function ip(e,t){if(br(e))return null;t=t.toLowerCase();let s=Object.keys(e),n=s.length,r;for(;n-- >0;)if(r=s[n],t===r.toLowerCase())return r;return null}var Ws=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,op=e=>!xn(e)&&e!==Ws;function Ia(...e){let{caseless:t,skipUndefined:s}=op(this)&&this||{},n={},r=(i,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;let a=t&&ip(n,o)||o,u=ka(n,a)?n[a]:void 0;Ai(u)&&Ai(i)?n[a]=Ia(u,i):Ai(i)?n[a]=Ia({},i):wn(i)?n[a]=i.slice():(!s||!xn(i))&&(n[a]=i)};for(let i=0,o=e.length;i<o;i++)e[i]&&vr(e[i],r);return n}var cA=(e,t,s,{allOwnKeys:n}={})=>(vr(t,(r,i)=>{s&&dt(r)?Object.defineProperty(e,i,{__proto__:null,value:Sr(r,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),uA=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),lA=(e,t,s,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),s&&Object.assign(e.prototype,s)},pA=(e,t,s,n)=>{let r,i,o,a={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),i=r.length;i-- >0;)o=r[i],(!n||n(o,e,t))&&!a[o]&&(t[o]=e[o],a[o]=!0);e=s!==!1&&xi(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},dA=(e,t,s)=>{e=String(e),(s===void 0||s>e.length)&&(s=e.length),s-=t.length;let n=e.indexOf(t,s);return n!==-1&&n===s},mA=e=>{if(!e)return null;if(wn(e))return e;let t=e.length;if(!rp(t))return null;let s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},fA=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),gA=(e,t)=>{let n=(e&&e[wi]).call(e),r;for(;(r=n.next())&&!r.done;){let i=r.value;t.call(e,i[0],i[1])}},hA=(e,t)=>{let s,n=[];for(;(s=e.exec(t))!==null;)n.push(s);return n},yA=$t("HTMLFormElement"),SA=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,n,r){return n.toUpperCase()+r}),ka=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),bA=$t("RegExp"),ap=(e,t)=>{let s=Object.getOwnPropertyDescriptors(e),n={};vr(s,(r,i)=>{let o;(o=t(r,i,e))!==!1&&(n[i]=o||r)}),Object.defineProperties(e,n)},DA=e=>{ap(e,(t,s)=>{if(dt(e)&&["arguments","caller","callee"].includes(s))return!1;let n=e[s];if(dt(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},vA=(e,t)=>{let s={},n=r=>{r.forEach(i=>{s[i]=!0})};return wn(e)?n(e):n(String(e).split(t)),s},CA=()=>{},AA=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function xA(e){return!!(e&&dt(e.append)&&e[sp]==="FormData"&&e[wi])}var wA=e=>{let t=new Array(10),s=(n,r)=>{if(Dr(n)){if(t.indexOf(n)>=0)return;if(br(n))return n;if(!("toJSON"in n)){t[r]=n;let i=wn(n)?[]:{};return vr(n,(o,a)=>{let u=s(o,r+1);!xn(u)&&(i[a]=u)}),t[r]=void 0,i}}return n};return s(e,0)},EA=$t("AsyncFunction"),FA=e=>e&&(Dr(e)||dt(e))&&dt(e.then)&&dt(e.catch),cp=((e,t)=>e?setImmediate:t?((s,n)=>(Ws.addEventListener("message",({source:r,data:i})=>{r===Ws&&i===s&&n.length&&n.shift()()},!1),r=>{n.push(r),Ws.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",dt(Ws.postMessage)),RA=typeof queueMicrotask<"u"?queueMicrotask.bind(Ws):typeof process<"u"&&process.nextTick||cp,IA=e=>e!=null&&dt(e[wi]),D={isArray:wn,isArrayBuffer:np,isBuffer:br,isFormData:tA,isArrayBufferView:GC,isString:HC,isNumber:rp,isBoolean:zC,isObject:Dr,isPlainObject:Ai,isEmptyObject:qC,isReadableStream:nA,isRequest:rA,isResponse:iA,isHeaders:oA,isUndefined:xn,isDate:VC,isFile:KC,isReactNativeBlob:ZC,isReactNative:YC,isBlob:JC,isRegExp:bA,isFunction:dt,isStream:QC,isURLSearchParams:sA,isTypedArray:fA,isFileList:XC,forEach:vr,merge:Ia,extend:cA,trim:aA,stripBOM:uA,inherits:lA,toFlatObject:pA,kindOf:Ei,kindOfTest:$t,endsWith:dA,toArray:mA,forEachEntry:gA,matchAll:hA,isHTMLForm:yA,hasOwnProperty:ka,hasOwnProp:ka,reduceDescriptors:ap,freezeMethods:DA,toObjectSet:vA,toCamelCase:SA,noop:CA,toFiniteNumber:AA,findKey:ip,global:Ws,isContextDefined:op,isSpecCompliantForm:xA,toJSONObject:wA,isAsyncFn:EA,isThenable:FA,setImmediate:cp,asap:RA,isIterable:IA};var kA=D.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),up=e=>{let t={},s,n,r;return e&&e.split(`
83
83
  `).forEach(function(o){r=o.indexOf(":"),s=o.substring(0,r).trim().toLowerCase(),n=o.substring(r+1).trim(),!(!s||t[s]&&kA[s])&&(s==="set-cookie"?t[s]?t[s].push(n):t[s]=[n]:t[s]=t[s]?t[s]+", "+n:n)}),t};var lp=Symbol("internals"),TA=/[^\x09\x20-\x7E\x80-\xFF]/g;function PA(e){let t=0,s=e.length;for(;t<s;){let n=e.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;s>t;){let n=e.charCodeAt(s-1);if(n!==9&&n!==32)break;s-=1}return t===0&&s===e.length?e:e.slice(t,s)}function Cr(e){return e&&String(e).trim().toLowerCase()}function LA(e){return PA(e.replace(TA,""))}function Ri(e){return e===!1||e==null?e:D.isArray(e)?e.map(Ri):LA(String(e))}function _A(e){let t=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=s.exec(e);)t[n[1]]=n[2];return t}var OA=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ta(e,t,s,n,r){if(D.isFunction(n))return n.call(this,t,s);if(r&&(t=s),!!D.isString(t)){if(D.isString(n))return t.indexOf(n)!==-1;if(D.isRegExp(n))return n.test(t)}}function BA(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,s,n)=>s.toUpperCase()+n)}function MA(e,t){let s=D.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+s,{__proto__:null,value:function(r,i,o){return this[n].call(this,t,r,i,o)},configurable:!0})})}var En=class{constructor(t){t&&this.set(t)}set(t,s,n){let r=this;function i(a,u,c){let l=Cr(u);if(!l)throw new Error("header name must be a non-empty string");let p=D.findKey(r,l);(!p||r[p]===void 0||c===!0||c===void 0&&r[p]!==!1)&&(r[p||u]=Ri(a))}let o=(a,u)=>D.forEach(a,(c,l)=>i(c,l,u));if(D.isPlainObject(t)||t instanceof this.constructor)o(t,s);else if(D.isString(t)&&(t=t.trim())&&!OA(t))o(up(t),s);else if(D.isObject(t)&&D.isIterable(t)){let a={},u,c;for(let l of t){if(!D.isArray(l))throw TypeError("Object iterator must return a key-value pair");a[c=l[0]]=(u=a[c])?D.isArray(u)?[...u,l[1]]:[u,l[1]]:l[1]}o(a,s)}else t!=null&&i(s,t,n);return this}get(t,s){if(t=Cr(t),t){let n=D.findKey(this,t);if(n){let r=this[n];if(!s)return r;if(s===!0)return _A(r);if(D.isFunction(s))return s.call(this,r,n);if(D.isRegExp(s))return s.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,s){if(t=Cr(t),t){let n=D.findKey(this,t);return!!(n&&this[n]!==void 0&&(!s||Ta(this,this[n],n,s)))}return!1}delete(t,s){let n=this,r=!1;function i(o){if(o=Cr(o),o){let a=D.findKey(n,o);a&&(!s||Ta(n,n[a],a,s))&&(delete n[a],r=!0)}}return D.isArray(t)?t.forEach(i):i(t),r}clear(t){let s=Object.keys(this),n=s.length,r=!1;for(;n--;){let i=s[n];(!t||Ta(this,this[i],i,t,!0))&&(delete this[i],r=!0)}return r}normalize(t){let s=this,n={};return D.forEach(this,(r,i)=>{let o=D.findKey(n,i);if(o){s[o]=Ri(r),delete s[i];return}let a=t?BA(i):String(i).trim();a!==i&&delete s[i],s[a]=Ri(r),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let s=Object.create(null);return D.forEach(this,(n,r)=>{n!=null&&n!==!1&&(s[r]=t&&D.isArray(n)?n.join(", "):n)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,s])=>t+": "+s).join(`
@@ -124,7 +124,7 @@ ${q.comment("\u{1F4A1} Next Steps:")}`),U?(e.log(q.error(" \u274C Trial expire
124
124
  `)},displayQuotaWarning:_=>{let{currentResourcesAnalyzed:W,maxResources:ee,requestedResources:X,isTrial:U}=_;if(!U)return;W+X>ee&&(e.log(`
125
125
  ${q.warning.bold("\u26A0\uFE0F AI credit allowance exceeded")}`),e.log(q.comment("\u2500".repeat(40))),e.log(q.warning(` You've used ${W}/${ee} AI credits`)),e.log(q.warning(` This analysis would add ${X} more`)),e.log(q.warning(` Total would be ${W+X}/${ee}`)),e.log(`
126
126
  ${q.info("\u{1F4CB} Falling back to static analysis only")}`),e.log(q.comment("\u{1F4A1} Upgrade to Pro for unlimited AI analysis: https://cdkinsights.dev/pricing")),e.log(`${q.comment("\u2500".repeat(40))}
127
- `))}}},V=BP();var hD=e=>e&&(e.Name||e.ResourceName||e.FunctionName)||"Unnamed";var pl=null,yD=e=>{pl=e};var dl=()=>{if(pl&&!process.env.CI)try{pl.saveToDisk(),st.info("\u{1F4BE} Cache saved to disk on exit")}catch(e){st.warn("\u26A0\uFE0F Could not save cache on exit",{error:e instanceof Error?e.message:String(e)})}};process.on("exit",dl);process.on("SIGINT",()=>{dl(),process.exit(0)});process.on("SIGTERM",()=>{dl(),process.exit(0)});var MP={maxConcurrent:Xr.DEFAULT_MAX_CONCURRENT,retryAttempts:Xr.DEFAULT_RETRY_ATTEMPTS,retryDelay:Xr.DEFAULT_RETRY_DELAY_MS,timeoutMs:Xr.DEFAULT_TIMEOUT_MS},NP=e=>{if(!(e instanceof Error))return!1;let t=e.message??"";return t.startsWith("Polling timed out")||t==="Analysis timeout"||t.toLowerCase().includes("timeout")},Yo=(e,t)=>{let s=e.match(/^(.+?)(\s\([^)]+\))?$/);if(!s)return e;let[,n,r=""]=s;return`${ur(t,n)}${r}`},WP=e=>{let t=Ur({ttl:6e4,maxSize:1e3});return({analysisError:s,redactedId:n})=>{let r=s instanceof Error?s.message:"unknown",i=`${n}:${r}`,o=t.get(i)||0;return NP(s)?{status:"timeout",redactedId:n}:(t.set(i,o+1),o>e.retryAttempts?{status:"skipped",redactedId:n}:{status:"fail",redactedId:n,error:s})}},UP=({analyzeResource:e,redactionMapping:t,aggregatedResult:s,errorHandler:n,config:r,authToken:i,fingerprint:o,stackName:a,analysisCache:u,originalResources:c,relationships:l,aiModelId:p})=>async({redactedId:d,redactedResources:m,findingsByResource:f,progressTracker:g})=>{let h=f.get(d)||[],y=m[d];if(!y)return{status:"skipped",redactedId:d};let C=wu(d,y,i,o,[]),v=Eu(C),I=t[d];if(!I)return{status:"skipped",redactedId:d};let N=I,B=()=>(s[N]||(s[N]={issues:[]}),s[N]),F=u.get(v);if(F){let ye=(F.issues||[]).map(_=>({..._,resource:N,resourceId:N})),oe=B();return oe.issues.push(...bn({existing:oe.issues,incoming:ye})),oe.resourceName=F.resourceName,{status:"success",redactedId:d,resourceKey:N,remappedIssues:ye,resourceName:F.resourceName}}let z=ur(a,I),H=ur("cdk-insights-stack",a),Q=Xi(I,l,c),re={dependencies:Q.dependencies.map(ye=>Yo(ye,a)),dependents:Q.dependents.map(ye=>Yo(ye,a)),usageDescription:Q.usageDescription};for(let ye=1;ye<=r.retryAttempts;ye++)try{let oe=await Promise.race([e(H,z,y,y.Type,i,o,h,g,re,p),new Promise((ee,X)=>setTimeout(()=>X(new Error("Analysis timeout")),r.timeoutMs))]);oe.resourceId=N;let _=(oe.issues||[]).map(ee=>({...ee,resource:N,resourceId:N})),W=B();return W.issues.push(...bn({existing:W.issues,incoming:_})),W.resourceName=oe.resourceName,u.set(v,oe,C),{status:"success",redactedId:d,resourceKey:N,remappedIssues:_,resourceName:oe.resourceName}}catch(oe){if(ye===r.retryAttempts)return n({analysisError:oe,redactedId:d});await new Promise(_=>setTimeout(_,r.retryDelay*2**(ye-1)))}return{status:"fail",redactedId:d,error:new Error("Max retries exceeded")}},jP=async(e,t,s)=>{let n=Math.max(1,Math.floor(t)),r=0,i=Array.from({length:Math.min(n,e.length)}).map(async()=>{for(;r<e.length;){let o=r;r+=1;let a=e[o];await s(a)}});await Promise.allSettled(i)},$P=10,SD=({analyzeResource:e,analyzeResourcesBatch:t,redactResources:s,config:n=MP})=>async({stackName:r,resources:i,authToken:o,existingFindingsMap:a,pathToLogicalId:u,fingerprint:c,noCache:l=!1,cacheConfig:p,aiModelId:d,aiBatchSize:m})=>{let f={},g=[],h={startTime:Date.now(),processedCount:0,successCount:0,failureCount:0,timeoutCount:0},{redactedResources:y,mapping:b}=s(i),C=ib(a,b,u),v=new Map;for(let U of C){let Y=v.get(U.resourceId);Y?Y.push(U):v.set(U.resourceId,[U])}let I=Object.keys(y),N=I.length,B=Vs(i),F=new Bo({ttl:p?.ttl||6*60*60*1e3,maxSize:p?.maxSize||5e3,disabled:l||!p?.enabled});yD(F);let z=WP(n),H=UP({analyzeResource:e,redactionMapping:b,aggregatedResult:f,errorHandler:z,config:n,authToken:o,fingerprint:c,stackName:r,analysisCache:F,originalResources:i,relationships:B,aiModelId:d}),Q=Ko.createSingleLineProgressTracker(N,"Analyzing resources with AI"),re=Math.min(Math.max(1,Math.floor(m??1)),$P);if(re>1&&!!t&&t){st.debug("Batched analysis enabled",{batchSize:re,totalResources:N});let U=ur("cdk-insights-stack",r),Y=te=>{let de=Xi(te,B,i);return{dependencies:de.dependencies.map(ce=>Yo(ce,r)),dependents:de.dependents.map(ce=>Yo(ce,r)),usageDescription:de.usageDescription}};for(let te=0;te<I.length;te+=re){let de=I.slice(te,te+re),ce=async()=>{for(let xe of de){let O=await H({redactedId:xe,redactedResources:y,findingsByResource:v,progressTracker:Q});switch(h.processedCount++,O.status){case"success":h.successCount++;break;case"timeout":h.timeoutCount++,g.push({redactedId:xe,resourceData:y[xe],resourceType:y[xe].Type,existingFindings:v.get(xe)||[]});break;case"fail":case"skipped":h.failureCount++;break}}},Ae=new Map,le=[];for(let xe of de){let O=y[xe],P=b[xe];if(!O||!P){h.processedCount++,h.failureCount++;continue}let se=wu(xe,O,o,c,[]),ne=Eu(se),J=F.get(ne);if(J){let Ye=(J.issues||[]).map(ut=>({...ut,resource:P,resourceId:P}));f[P]||(f[P]={issues:[]});let Ce=f[P];Ce.issues.push(...bn({existing:Ce.issues,incoming:Ye})),Ce.resourceName=J.resourceName,h.processedCount++,h.successCount++;continue}let Pe=ur(r,P);Ae.set(Pe,{redactedId:xe,originalResourceId:P,cacheKey:ne,cacheComponents:se}),le.push({stableResourceId:Pe,resourceData:O,resourceType:O.Type,context:Y(P),existingFindings:v.get(xe)||[]})}if(le.length!==0)try{let xe=await Promise.race([t(U,le,o,c,d),new Promise((O,P)=>setTimeout(()=>P(new Error("Analysis timeout")),n.timeoutMs))]);for(let[O,P]of Ae){let se=xe.get(O);if(h.processedCount++,!se){st.warn(`Batched response missing entry for resource ${P.originalResourceId}`,{stableResourceId:O,redactedId:P.redactedId}),h.failureCount++;continue}let ne=(se.issues||[]).map(Pe=>({...Pe,resource:P.originalResourceId,resourceId:P.originalResourceId}));f[P.originalResourceId]||(f[P.originalResourceId]={issues:[]});let J=f[P.originalResourceId];J.issues.push(...bn({existing:J.issues,incoming:ne})),J.resourceName=se.resourceName,F.set(P.cacheKey,{resourceId:P.originalResourceId,issues:se.issues||[],resourceName:se.resourceName},P.cacheComponents),h.successCount++}}catch(xe){st.warn("Batched analysis call failed \u2014 falling back to per-resource for this chunk",{error:xe instanceof Error?xe.message:String(xe),chunkSize:de.length}),await ce()}}}else await jP(I,n.maxConcurrent,async U=>{st.debug(`Starting analysis for resource ${U}`,{redactedId:U,maxConcurrent:n.maxConcurrent});let Y=await H({redactedId:U,redactedResources:y,findingsByResource:v,progressTracker:Q});switch(h.processedCount++,st.debug(`Resource ${U} analysis result: ${Y.status}`,{redactedId:U,status:Y.status,hasProgressTracker:!!Q}),Y.status){case"success":h.successCount++,st.debug(`Resource ${U} completed successfully`,{redactedId:U,resourceKey:Y.resourceKey});break;case"timeout":h.timeoutCount++,st.warn(`Resource ${U} timed out`,{redactedId:U}),g.push({redactedId:U,resourceData:y[U],resourceType:y[U].Type,existingFindings:v.get(U)||[]});break;case"fail":case"skipped":h.failureCount++,st.warn(`Resource ${U} failed or was skipped`,{redactedId:U,status:Y.status});break}});let oe=Date.now()-h.startTime,_=Q.getStats();if(st.debug("Analysis completed with progress tracker stats",{progressTrackerStats:_,performanceMetrics:h,totalTime:oe,totalResources:N,maxConcurrent:n.maxConcurrent}),V.analysisComplete(oe,h.successCount,h.failureCount,h.timeoutCount),h.failureCount>0||h.timeoutCount>0){V.newline(),V.info("\u{1F4CA} Performance Analysis:");let U=h.successCount>0?Math.round(oe/1e3/h.successCount):0;V.comment(` \u23F1\uFE0F Average completion time: ${U}s`),V.comment(` \u{1F4CA} Success rate: ${(h.successCount/N*100).toFixed(1)}%`)}if(g.length>0){V.newline(),V.warning("\u23F0 Timed Out Resources:"),V.comment(` \u{1F4CB} Total timed out: ${g.length}`);for(let U of g){if(V.comment(` \u274C ${U.resourceType}: ${U.redactedId}`),U.resourceData?.Properties){let te=U.resourceData.Properties,de=hD(te);V.comment(` \u{1F4DD} Name: ${de}`)}U.existingFindings.length>0&&V.comment(` \u{1F50D} Existing findings: ${U.existingFindings.length}`),U.resourceData?.Metadata&&V.comment(" \u{1F4CD} Has metadata: Yes"),["AWS::CloudFormation::Stack","AWS::Serverless::Application","AWS::ECS::Service"].includes(U.resourceType)&&V.comment(" \u26A0\uFE0F Complex resource type - may require extended analysis time")}V.newline(),V.info("\u{1F4A1} Tip: Some resources are taking longer to analyze than expected."),V.comment(" This is normal for complex resources. The analysis will continue with the remaining resources."),V.warning(`Retrying ${g.length} resource${g.length===1?"":"s"} that need a little more time...`)}let W=new Set(Object.keys(f)),ee=new Set(Object.values(b)),X=Array.from(ee).filter(U=>!W.has(U)||!f[U]?.issues?.length);if(X.length>0){let U=F.getCachedResultsForResources(X),Y=0;for(let[te,de]of Array.from(U.entries())){if(f[te]?.issues?.length>0)continue;let ce=(de.issues||[]).map(Ae=>({...Ae,resource:te,resourceId:te}));ce.length>0&&(f[te]||(f[te]={issues:[]}),f[te].issues.push(...ce),f[te].resourceName=de.resourceName,Y+=ce.length)}Y>0}return f};var ml=require("node:child_process"),nt=K(require("node:fs")),fl=K(require("node:os")),ci=K(require("node:path"));var vD="1.37.2",GP={Security:"https://docs.aws.amazon.com/wellarchitected/latest/security-pillar/",Reliability:"https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/","Performance Efficiency":"https://docs.aws.amazon.com/wellarchitected/latest/performance-efficiency-pillar/","Cost Optimization":"https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/","Operational Excellence":"https://docs.aws.amazon.com/wellarchitected/latest/operational-excellence-pillar/",Sustainability:"https://docs.aws.amazon.com/wellarchitected/latest/sustainability-pillar/"},bD=e=>e.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),HP=(e,t)=>{let s=0;if(s+=2e3,t){let n=Object.values(e).filter(r=>{let i=r.sources.cdkInsights?.issues??[],o=r.sources.cdkNag?.issues??[];return i.length>0||o.length>0});s+=n.length*100}for(let[,n]of Object.entries(e)){let r=n.sources.cdkInsights?.issues??[],i=n.sources.cdkNag?.issues??[];for(let o of[...r,...i])s+=o.issue.length,s+=o.recommendation?.length||0,s+=o.codeSnippet?.length||0,s+=500}return s},zP=e=>e?e.split(`
127
+ `))}}},V=BP();var hD=e=>e&&(e.Name||e.ResourceName||e.FunctionName)||"Unnamed";var pl=null,yD=e=>{pl=e};var dl=()=>{if(pl&&!process.env.CI)try{pl.saveToDisk(),st.info("\u{1F4BE} Cache saved to disk on exit")}catch(e){st.warn("\u26A0\uFE0F Could not save cache on exit",{error:e instanceof Error?e.message:String(e)})}};process.on("exit",dl);process.on("SIGINT",()=>{dl(),process.exit(0)});process.on("SIGTERM",()=>{dl(),process.exit(0)});var MP={maxConcurrent:Xr.DEFAULT_MAX_CONCURRENT,retryAttempts:Xr.DEFAULT_RETRY_ATTEMPTS,retryDelay:Xr.DEFAULT_RETRY_DELAY_MS,timeoutMs:Xr.DEFAULT_TIMEOUT_MS},NP=e=>{if(!(e instanceof Error))return!1;let t=e.message??"";return t.startsWith("Polling timed out")||t==="Analysis timeout"||t.toLowerCase().includes("timeout")},Yo=(e,t)=>{let s=e.match(/^(.+?)(\s\([^)]+\))?$/);if(!s)return e;let[,n,r=""]=s;return`${ur(t,n)}${r}`},WP=e=>{let t=Ur({ttl:6e4,maxSize:1e3});return({analysisError:s,redactedId:n})=>{let r=s instanceof Error?s.message:"unknown",i=`${n}:${r}`,o=t.get(i)||0;return NP(s)?{status:"timeout",redactedId:n}:(t.set(i,o+1),o>e.retryAttempts?{status:"skipped",redactedId:n}:{status:"fail",redactedId:n,error:s})}},UP=({analyzeResource:e,redactionMapping:t,aggregatedResult:s,errorHandler:n,config:r,authToken:i,fingerprint:o,stackName:a,analysisCache:u,originalResources:c,relationships:l,aiModelId:p})=>async({redactedId:d,redactedResources:m,findingsByResource:f,progressTracker:g})=>{let h=f.get(d)||[],y=m[d];if(!y)return{status:"skipped",redactedId:d};let C=wu(d,y,i,o,[]),v=Eu(C),I=t[d];if(!I)return{status:"skipped",redactedId:d};let N=I,B=()=>(s[N]||(s[N]={issues:[]}),s[N]),F=u.get(v);if(F){let ye=(F.issues||[]).map(_=>({..._,resource:N,resourceId:N})),oe=B();return oe.issues.push(...bn({existing:oe.issues,incoming:ye})),oe.resourceName=F.resourceName,{status:"success",redactedId:d,resourceKey:N,remappedIssues:ye,resourceName:F.resourceName}}let z=ur(a,I),H=ur("cdk-insights-stack",a),Q=Xi(I,l,c),re={dependencies:Q.dependencies.map(ye=>Yo(ye,a)),dependents:Q.dependents.map(ye=>Yo(ye,a)),usageDescription:Q.usageDescription};for(let ye=1;ye<=r.retryAttempts;ye++)try{let oe=await Promise.race([e(H,z,y,y.Type,i,o,h,g,re,p),new Promise((ee,X)=>setTimeout(()=>X(new Error("Analysis timeout")),r.timeoutMs))]);oe.resourceId=N;let _=(oe.issues||[]).map(ee=>({...ee,resource:N,resourceId:N})),W=B();return W.issues.push(...bn({existing:W.issues,incoming:_})),W.resourceName=oe.resourceName,u.set(v,oe,C),{status:"success",redactedId:d,resourceKey:N,remappedIssues:_,resourceName:oe.resourceName}}catch(oe){if(ye===r.retryAttempts)return n({analysisError:oe,redactedId:d});await new Promise(_=>setTimeout(_,r.retryDelay*2**(ye-1)))}return{status:"fail",redactedId:d,error:new Error("Max retries exceeded")}},jP=async(e,t,s)=>{let n=Math.max(1,Math.floor(t)),r=0,i=Array.from({length:Math.min(n,e.length)}).map(async()=>{for(;r<e.length;){let o=r;r+=1;let a=e[o];await s(a)}});await Promise.allSettled(i)},$P=10,SD=({analyzeResource:e,analyzeResourcesBatch:t,redactResources:s,config:n=MP})=>async({stackName:r,resources:i,authToken:o,existingFindingsMap:a,pathToLogicalId:u,fingerprint:c,noCache:l=!1,cacheConfig:p,aiModelId:d,aiBatchSize:m})=>{let f={},g=[],h={startTime:Date.now(),processedCount:0,successCount:0,failureCount:0,timeoutCount:0},{redactedResources:y,mapping:b}=s(i),C=ib(a,b,u),v=new Map;for(let U of C){let Y=v.get(U.resourceId);Y?Y.push(U):v.set(U.resourceId,[U])}let I=Object.keys(y),N=I.length,B=Vs(i),F=new Bo({ttl:p?.ttl||6*60*60*1e3,maxSize:p?.maxSize||5e3,disabled:l||!p?.enabled});yD(F);let z=WP(n),H=UP({analyzeResource:e,redactionMapping:b,aggregatedResult:f,errorHandler:z,config:n,authToken:o,fingerprint:c,stackName:r,analysisCache:F,originalResources:i,relationships:B,aiModelId:d}),Q=Ko.createSingleLineProgressTracker(N,"Analyzing resources with AI"),re=Math.min(Math.max(1,Math.floor(m??1)),$P);if(re>1&&!!t&&t){st.debug("Batched analysis enabled",{batchSize:re,totalResources:N});let U=ur("cdk-insights-stack",r),Y=te=>{let de=Xi(te,B,i);return{dependencies:de.dependencies.map(ce=>Yo(ce,r)),dependents:de.dependents.map(ce=>Yo(ce,r)),usageDescription:de.usageDescription}};for(let te=0;te<I.length;te+=re){let de=I.slice(te,te+re),ce=async()=>{for(let xe of de){let O=await H({redactedId:xe,redactedResources:y,findingsByResource:v,progressTracker:Q});switch(h.processedCount++,O.status){case"success":h.successCount++;break;case"timeout":h.timeoutCount++,g.push({redactedId:xe,resourceData:y[xe],resourceType:y[xe].Type,existingFindings:v.get(xe)||[]});break;case"fail":case"skipped":h.failureCount++;break}}},Ae=new Map,le=[];for(let xe of de){let O=y[xe],P=b[xe];if(!O||!P){h.processedCount++,h.failureCount++;continue}let se=wu(xe,O,o,c,[]),ne=Eu(se),J=F.get(ne);if(J){let Ye=(J.issues||[]).map(ut=>({...ut,resource:P,resourceId:P}));f[P]||(f[P]={issues:[]});let Ce=f[P];Ce.issues.push(...bn({existing:Ce.issues,incoming:Ye})),Ce.resourceName=J.resourceName,h.processedCount++,h.successCount++;continue}let Pe=ur(r,P);Ae.set(Pe,{redactedId:xe,originalResourceId:P,cacheKey:ne,cacheComponents:se}),le.push({stableResourceId:Pe,resourceData:O,resourceType:O.Type,context:Y(P),existingFindings:v.get(xe)||[]})}if(le.length!==0)try{let xe=await Promise.race([t(U,le,o,c,d),new Promise((O,P)=>setTimeout(()=>P(new Error("Analysis timeout")),n.timeoutMs))]);for(let[O,P]of Ae){let se=xe.get(O);if(h.processedCount++,!se){st.warn(`Batched response missing entry for resource ${P.originalResourceId}`,{stableResourceId:O,redactedId:P.redactedId}),h.failureCount++;continue}let ne=(se.issues||[]).map(Pe=>({...Pe,resource:P.originalResourceId,resourceId:P.originalResourceId}));f[P.originalResourceId]||(f[P.originalResourceId]={issues:[]});let J=f[P.originalResourceId];J.issues.push(...bn({existing:J.issues,incoming:ne})),J.resourceName=se.resourceName,F.set(P.cacheKey,{resourceId:P.originalResourceId,issues:se.issues||[],resourceName:se.resourceName},P.cacheComponents),h.successCount++}}catch(xe){st.warn("Batched analysis call failed \u2014 falling back to per-resource for this chunk",{error:xe instanceof Error?xe.message:String(xe),chunkSize:de.length}),await ce()}}}else await jP(I,n.maxConcurrent,async U=>{st.debug(`Starting analysis for resource ${U}`,{redactedId:U,maxConcurrent:n.maxConcurrent});let Y=await H({redactedId:U,redactedResources:y,findingsByResource:v,progressTracker:Q});switch(h.processedCount++,st.debug(`Resource ${U} analysis result: ${Y.status}`,{redactedId:U,status:Y.status,hasProgressTracker:!!Q}),Y.status){case"success":h.successCount++,st.debug(`Resource ${U} completed successfully`,{redactedId:U,resourceKey:Y.resourceKey});break;case"timeout":h.timeoutCount++,st.warn(`Resource ${U} timed out`,{redactedId:U}),g.push({redactedId:U,resourceData:y[U],resourceType:y[U].Type,existingFindings:v.get(U)||[]});break;case"fail":case"skipped":h.failureCount++,st.warn(`Resource ${U} failed or was skipped`,{redactedId:U,status:Y.status});break}});let oe=Date.now()-h.startTime,_=Q.getStats();if(st.debug("Analysis completed with progress tracker stats",{progressTrackerStats:_,performanceMetrics:h,totalTime:oe,totalResources:N,maxConcurrent:n.maxConcurrent}),V.analysisComplete(oe,h.successCount,h.failureCount,h.timeoutCount),h.failureCount>0||h.timeoutCount>0){V.newline(),V.info("\u{1F4CA} Performance Analysis:");let U=h.successCount>0?Math.round(oe/1e3/h.successCount):0;V.comment(` \u23F1\uFE0F Average completion time: ${U}s`),V.comment(` \u{1F4CA} Success rate: ${(h.successCount/N*100).toFixed(1)}%`)}if(g.length>0){V.newline(),V.warning("\u23F0 Timed Out Resources:"),V.comment(` \u{1F4CB} Total timed out: ${g.length}`);for(let U of g){if(V.comment(` \u274C ${U.resourceType}: ${U.redactedId}`),U.resourceData?.Properties){let te=U.resourceData.Properties,de=hD(te);V.comment(` \u{1F4DD} Name: ${de}`)}U.existingFindings.length>0&&V.comment(` \u{1F50D} Existing findings: ${U.existingFindings.length}`),U.resourceData?.Metadata&&V.comment(" \u{1F4CD} Has metadata: Yes"),["AWS::CloudFormation::Stack","AWS::Serverless::Application","AWS::ECS::Service"].includes(U.resourceType)&&V.comment(" \u26A0\uFE0F Complex resource type - may require extended analysis time")}V.newline(),V.info("\u{1F4A1} Tip: Some resources are taking longer to analyze than expected."),V.comment(" This is normal for complex resources. The analysis will continue with the remaining resources."),V.warning(`Retrying ${g.length} resource${g.length===1?"":"s"} that need a little more time...`)}let W=new Set(Object.keys(f)),ee=new Set(Object.values(b)),X=Array.from(ee).filter(U=>!W.has(U)||!f[U]?.issues?.length);if(X.length>0){let U=F.getCachedResultsForResources(X),Y=0;for(let[te,de]of Array.from(U.entries())){if(f[te]?.issues?.length>0)continue;let ce=(de.issues||[]).map(Ae=>({...Ae,resource:te,resourceId:te}));ce.length>0&&(f[te]||(f[te]={issues:[]}),f[te].issues.push(...ce),f[te].resourceName=de.resourceName,Y+=ce.length)}Y>0}return f};var ml=require("node:child_process"),nt=K(require("node:fs")),fl=K(require("node:os")),ci=K(require("node:path"));var vD="1.37.4",GP={Security:"https://docs.aws.amazon.com/wellarchitected/latest/security-pillar/",Reliability:"https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/","Performance Efficiency":"https://docs.aws.amazon.com/wellarchitected/latest/performance-efficiency-pillar/","Cost Optimization":"https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/","Operational Excellence":"https://docs.aws.amazon.com/wellarchitected/latest/operational-excellence-pillar/",Sustainability:"https://docs.aws.amazon.com/wellarchitected/latest/sustainability-pillar/"},bD=e=>e.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),HP=(e,t)=>{let s=0;if(s+=2e3,t){let n=Object.values(e).filter(r=>{let i=r.sources.cdkInsights?.issues??[],o=r.sources.cdkNag?.issues??[];return i.length>0||o.length>0});s+=n.length*100}for(let[,n]of Object.entries(e)){let r=n.sources.cdkInsights?.issues??[],i=n.sources.cdkNag?.issues??[];for(let o of[...r,...i])s+=o.issue.length,s+=o.recommendation?.length||0,s+=o.codeSnippet?.length||0,s+=500}return s},zP=e=>e?e.split(`
128
128
  `).map(t=>t.trim()).filter(Boolean).join(`
129
129
  `):"",DD=e=>{let t=`- **Issue:** ${e.issue}`;return e.recommendation&&(t+=`
130
130
  - **Recommendation:** ${zP(e.recommendation)}`),e.context&&(e.context.property&&(t+=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdk-insights",
3
- "version": "1.37.2",
3
+ "version": "1.37.4",
4
4
  "description": "AWS CDK security and cost analysis CLI. Free static scans via npm — no account needed. Sign up free to add AI-powered insights.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",