From 248ad08de855201b41f8bfe64ddf1456346409e8 Mon Sep 17 00:00:00 2001 From: Dhyan Gandhi Date: Tue, 23 Sep 2025 17:24:18 -0400 Subject: [PATCH 1/6] feat(cli): add skip-unauthorized-stacks-when-noncdk option for garbage collection - Removed old functionality on ignore-stacks & skip-unauthorized-stacks - Add --skip-unauthorized-stacks-when-noncdk CLI option to handle AccessDenied errors for non-cdk stack names entered by user - Update interfaces and constructors with new parameter --- .../garbage-collection/garbage-collector.ts | 12 ++ .../api/garbage-collection/stack-refresh.ts | 76 ++++++++++-- .../garbage-collection.test.ts | 109 ++++++++++++++++++ packages/aws-cdk/lib/cli/cdk-toolkit.ts | 9 ++ packages/aws-cdk/lib/cli/cli.ts | 1 + .../lib/cli/parse-command-line-arguments.ts | 6 + 6 files changed, 203 insertions(+), 10 deletions(-) diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts index 84f13239e..667a910f7 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts @@ -178,6 +178,14 @@ interface GarbageCollectorProps { * @default true */ readonly confirm?: boolean; + + /** + * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. + * You must explicitly specify non-CDK stack names - CDK stacks will be rejected to prevent accidental asset deletion. + * + * @default undefined + */ + readonly skipUnauthorizedStacksWhenNonCdk?: string[]; } /** @@ -191,6 +199,7 @@ export class GarbageCollector { private bootstrapStackName: string; private confirm: boolean; private ioHelper: IoHelper; + private skipUnauthorizedStacksWhenNonCdk?: string[]; public constructor(readonly props: GarbageCollectorProps) { this.ioHelper = props.ioHelper; @@ -201,6 +210,7 @@ export class GarbageCollector { this.permissionToDelete = ['delete-tagged', 'full'].includes(props.action); this.permissionToTag = ['tag', 'full'].includes(props.action); this.confirm = props.confirm ?? true; + this.skipUnauthorizedStacksWhenNonCdk = props.skipUnauthorizedStacksWhenNonCdk; this.bootstrapStackName = props.bootstrapStackName ?? DEFAULT_TOOLKIT_STACK_NAME; } @@ -224,6 +234,7 @@ export class GarbageCollector { ioHelper: this.ioHelper, activeAssets, qualifier, + skipUnauthorizedStacksWhenNonCdk: this.skipUnauthorizedStacksWhenNonCdk, }); // Start the background refresh const backgroundStackRefresh = new BackgroundStackRefresh({ @@ -231,6 +242,7 @@ export class GarbageCollector { ioHelper: this.ioHelper, activeAssets, qualifier, + skipUnauthorizedStacksWhenNonCdk: this.skipUnauthorizedStacksWhenNonCdk, }); backgroundStackRefresh.start(); diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts index 83e13ba86..6e9684a5e 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts @@ -1,4 +1,5 @@ import type { ParameterDeclaration } from '@aws-sdk/client-cloudformation'; +import { minimatch } from 'minimatch'; import { ToolkitError } from '../../toolkit/toolkit-error'; import type { ICloudFormationClient } from '../aws-auth/private'; import type { IoHelper } from '../io/private'; @@ -20,6 +21,23 @@ export class ActiveAssetCache { } } +/** + * Check if a stack name matches any of the skip patterns using glob matching + */ +function shouldSkipStack(stackName: string, skipPatterns?: string[]): boolean { + if (!skipPatterns || skipPatterns.length === 0) { + return false; + } + + // Extract stack name from ARN if entire path is passed + // fetchAllStackTemplates can return either stack name or id so we handle both + const extractedStackName = stackName.includes(':cloudformation:') && stackName.includes(':stack/') + ? stackName.split('/')[1] || stackName + : stackName; + + return skipPatterns.some(pattern => minimatch(extractedStackName, pattern)); +} + async function paginateSdkCall(cb: (nextToken?: string) => Promise) { let finished = false; let nextToken: string | undefined; @@ -35,8 +53,14 @@ async function paginateSdkCall(cb: (nextToken?: string) => Promise { const stacks = await cfn.listStacks({ NextToken: nextToken }); @@ -56,20 +80,40 @@ async function fetchAllStackTemplates(cfn: ICloudFormationClient, ioHelper: IoHe const templates: string[] = []; for (const stack of stackNames) { - let summary; - summary = await cfn.getTemplateSummary({ - StackName: stack, - }); + try { + let summary; + summary = await cfn.getTemplateSummary({ + StackName: stack, + }); + + if (bootstrapFilter(summary.Parameters, qualifier)) { + // This stack is definitely bootstrapped to a different qualifier so we can safely ignore it + continue; + } - if (bootstrapFilter(summary.Parameters, qualifier)) { - // This stack is definitely bootstrapped to a different qualifier so we can safely ignore it - continue; - } else { const template = await cfn.getTemplate({ StackName: stack, }); templates.push((template.TemplateBody ?? '') + JSON.stringify(summary?.Parameters)); + } catch (error: any) { + // Check if this is a CloudFormation access denied error + if (error.name === 'AccessDenied') { + if (shouldSkipStack(stack, skipUnauthorizedStacksWhenNonCdk)) { + await ioHelper.defaults.warn( + `Skipping unauthorized stack '${stack}' as specified in --skip-unauthorized-stacks-when-noncdk`, + ); + continue; + } + + throw new ToolkitError( + `Access denied when trying to access stack '${stack}'. ` + + 'If this is a non-CDK stack that you want to skip, add it to --skip-unauthorized-stacks-when-noncdk.', + ); + } + + // Re-throw the error if it's not handled + throw error; } } @@ -102,11 +146,17 @@ export interface RefreshStacksProps { readonly ioHelper: IoHelper; readonly activeAssets: ActiveAssetCache; readonly qualifier?: string; + readonly skipUnauthorizedStacksWhenNonCdk?: string[]; } export async function refreshStacks(props: RefreshStacksProps) { try { - const stacks = await fetchAllStackTemplates(props.cfn, props.ioHelper, props.qualifier); + const stacks = await fetchAllStackTemplates( + props.cfn, + props.ioHelper, + props.qualifier, + props.skipUnauthorizedStacksWhenNonCdk, + ); for (const stack of stacks) { props.activeAssets.rememberStack(stack); } @@ -138,6 +188,11 @@ export interface BackgroundStackRefreshProps { * Stack bootstrap qualifier */ readonly qualifier?: string; + + /** + * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors + */ + readonly skipUnauthorizedStacksWhenNonCdk?: string[]; } /** @@ -166,6 +221,7 @@ export class BackgroundStackRefresh { ioHelper: this.props.ioHelper, activeAssets: this.props.activeAssets, qualifier: this.props.qualifier, + skipUnauthorizedStacksWhenNonCdk: this.props.skipUnauthorizedStacksWhenNonCdk, }); this.justRefreshedStacks(); diff --git a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts index 242d66571..df798c15e 100644 --- a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts +++ b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts @@ -735,6 +735,115 @@ describe('CloudFormation API calls', () => { }, }); }); + + test('skip stacks using glob patterns when unauthorized', async () => { + mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); + + cfnClient.on(ListStacksCommand).resolves({ + StackSummaries: [ + { StackName: 'CDKStack1', StackStatus: 'CREATE_COMPLETE', CreationTime: new Date() }, + { StackName: 'Legacy-App-Stack', StackStatus: 'CREATE_COMPLETE', CreationTime: new Date() }, + { StackName: 'Legacy-DB-Stack', StackStatus: 'CREATE_COMPLETE', CreationTime: new Date() }, + { StackName: 'ThirdParty-Service', StackStatus: 'CREATE_COMPLETE', CreationTime: new Date() }, + ], + }); + + cfnClient.on(GetTemplateSummaryCommand, { StackName: 'CDKStack1' }).resolves({ + Parameters: [{ ParameterKey: 'BootstrapVersion', DefaultValue: '/cdk-bootstrap/abcde/version' }], + }); + cfnClient.on(GetTemplateCommand, { StackName: 'CDKStack1' }).resolves({ TemplateBody: 'cdk-template' }); + + const accessDeniedError = new Error('Access Denied'); + accessDeniedError.name = 'AccessDenied'; + + ['Legacy-App-Stack', 'Legacy-DB-Stack', 'ThirdParty-Service'].forEach(stackName => { + cfnClient.on(GetTemplateSummaryCommand, { StackName: stackName }).resolves({ Parameters: [] }); + cfnClient.on(GetTemplateCommand, { StackName: stackName }).rejects(accessDeniedError); + }); + + garbageCollector = new GarbageCollector({ + sdkProvider: new MockSdkProvider(), + ioHelper: ioHost.asHelper('gc'), + action: 'full', + resolvedEnvironment: { account: '123456789012', region: 'us-east-1', name: 'mock' }, + bootstrapStackName: 'GarbageStack', + rollbackBufferDays: 0, + createdBufferDays: 0, + type: 's3', + confirm: false, + skipUnauthorizedStacksWhenNonCdk: ['Legacy-*', 'ThirdParty-*'], + }); + + await garbageCollector.garbageCollect(); + + expect(cfnClient).toHaveReceivedCommandWith(GetTemplateCommand, { StackName: 'CDKStack1' }); + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'warn', message: expect.stringContaining("Skipping unauthorized stack 'Legacy-App-Stack'") }), + ); + }); + + test('fail on unauthorized stack not matching skip patterns', async () => { + mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); + + cfnClient.on(ListStacksCommand).resolves({ + StackSummaries: [{ StackName: 'UnauthorizedStack', StackStatus: 'CREATE_COMPLETE', CreationTime: new Date() }], + }); + + const accessDeniedError = new Error('Access Denied'); + accessDeniedError.name = 'AccessDenied'; + cfnClient.on(GetTemplateSummaryCommand, { StackName: 'UnauthorizedStack' }).resolves({ Parameters: [] }); + cfnClient.on(GetTemplateCommand, { StackName: 'UnauthorizedStack' }).rejects(accessDeniedError); + + garbageCollector = new GarbageCollector({ + sdkProvider: new MockSdkProvider(), + ioHelper: ioHost.asHelper('gc'), + action: 'full', + resolvedEnvironment: { account: '123456789012', region: 'us-east-1', name: 'mock' }, + bootstrapStackName: 'GarbageStack', + rollbackBufferDays: 0, + createdBufferDays: 0, + type: 's3', + confirm: false, + skipUnauthorizedStacksWhenNonCdk: ['Legacy-*'], + }); + + await expect(garbageCollector.garbageCollect()).rejects.toThrow( + "Access denied when trying to access stack 'UnauthorizedStack'", + ); + }); + + test('extract stack name from ARN for pattern matching', async () => { + mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); + + const stackArn = 'arn:aws:cloudformation:us-east-1:123456789012:stack/Legacy-App-Stack/12345'; + cfnClient.on(ListStacksCommand).resolves({ + StackSummaries: [{ StackName: stackArn, StackStatus: 'CREATE_COMPLETE', CreationTime: new Date() }], + }); + + const accessDeniedError = new Error('Access Denied'); + accessDeniedError.name = 'AccessDenied'; + cfnClient.on(GetTemplateSummaryCommand, { StackName: stackArn }).resolves({ Parameters: [] }); + cfnClient.on(GetTemplateCommand, { StackName: stackArn }).rejects(accessDeniedError); + + garbageCollector = new GarbageCollector({ + sdkProvider: new MockSdkProvider(), + ioHelper: ioHost.asHelper('gc'), + action: 'full', + resolvedEnvironment: { account: '123456789012', region: 'us-east-1', name: 'mock' }, + bootstrapStackName: 'GarbageStack', + rollbackBufferDays: 0, + createdBufferDays: 0, + type: 's3', + confirm: false, + skipUnauthorizedStacksWhenNonCdk: ['Legacy-*'], + }); + + await garbageCollector.garbageCollect(); + + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'warn', message: expect.stringContaining('Skipping unauthorized stack') }), + ); + }); }); function prepareDefaultCfnMock() { diff --git a/packages/aws-cdk/lib/cli/cdk-toolkit.ts b/packages/aws-cdk/lib/cli/cdk-toolkit.ts index 7d8edc5c5..67464ddd1 100644 --- a/packages/aws-cdk/lib/cli/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cli/cdk-toolkit.ts @@ -1133,6 +1133,7 @@ export class CdkToolkit { action: options.action ?? 'full', type: options.type ?? 'all', confirm: options.confirm ?? true, + skipUnauthorizedStacksWhenNonCdk: options.skipUnauthorizedStacksWhenNonCdk, }); await gc.garbageCollect(); } @@ -1918,6 +1919,14 @@ export interface GarbageCollectionOptions { * @default false */ readonly confirm?: boolean; + + /** + * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. + * You must explicitly specify non-CDK stack names - CDK stacks will be rejected to prevent accidental asset deletion. + * + * @default undefined + */ + readonly skipUnauthorizedStacksWhenNonCdk?: string[]; } export interface MigrateOptions { /** diff --git a/packages/aws-cdk/lib/cli/cli.ts b/packages/aws-cdk/lib/cli/cli.ts index c3342e835..de726799c 100644 --- a/packages/aws-cdk/lib/cli/cli.ts +++ b/packages/aws-cdk/lib/cli/cli.ts @@ -487,6 +487,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise): any { deprecated: 'use --toolkit-stack-name', requiresArg: true, conflicts: 'toolkit-stack-name', + }) + .option('skip-unauthorized-stacks-when-noncdk', { + type: 'array', + desc: 'Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names - CDK stacks will be rejected.', + default: [], + requiresArg: true, }), ) .command('flags [FLAGNAME..]', 'View and toggle feature flags.', (yargs: Argv) => From 140fcd94bee12a79c98615298ac79d9eafddeaff Mon Sep 17 00:00:00 2001 From: dgandhi62 Date: Fri, 26 Sep 2025 11:56:14 -0400 Subject: [PATCH 2/6] feat(gc): improve unauthorized stack handling with batch prompts and CI support - Replace individual warnings with single batch prompt for unauthorized stacks - Add CDK_GC_AUTO_APPROVE_UNAUTHORIZED env var for CI/CD automation - Add CI detection to fail fast instead of hanging on user prompts - Add performance optimization with early return for empty assets --- .../garbage-collection/garbage-collector.ts | 2 +- .../api/garbage-collection/stack-refresh.ts | 71 ++++++++++++++++++- .../garbage-collection.test.ts | 10 ++- packages/aws-cdk/lib/cli/cdk-toolkit.ts | 2 +- .../lib/cli/parse-command-line-arguments.ts | 2 +- 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts index 667a910f7..13496ca0a 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts @@ -181,7 +181,7 @@ interface GarbageCollectorProps { /** * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. - * You must explicitly specify non-CDK stack names - CDK stacks will be rejected to prevent accidental asset deletion. + * You must explicitly specify non-CDK stack names * * @default undefined */ diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts index 6e9684a5e..67b79f52c 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts @@ -12,6 +12,9 @@ export class ActiveAssetCache { } public contains(asset: string): boolean { + // To reduce computation if asset is null or undefined + if (!asset) return false; + for (const stack of this.stacks) { if (stack.includes(asset)) { return true; @@ -49,6 +52,66 @@ async function paginateSdkCall(cb: (nextToken?: string) => Promise { + if (unauthorizedStacks.length === 0) { + return; + } + + // Auto-approve in CI environments + if (process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED === 'true') { + await ioHelper.defaults.info(`Auto-approving ${unauthorizedStacks.length} unauthorized stack(s) in CI mode`); + return; + } + + // Detect CI environment and fail fast to prevent hanging + const isCI = process.env.CI === 'true' || + process.env.GITHUB_ACTIONS === 'true' || + process.env.GITLAB_CI === 'true' || + process.env.JENKINS_URL !== undefined || + process.env.BUILDKITE === 'true'; + + if (isCI) { + throw new ToolkitError( + `Found ${unauthorizedStacks.length} unauthorized stack(s) in CI environment. ` + + 'Set CDK_GC_AUTO_APPROVE_UNAUTHORIZED=true to auto-approve or configure --skip-unauthorized-stacks-when-noncdk.', + ); + } + + try { + const stackList = unauthorizedStacks.join(', '); + const message = `Found ${unauthorizedStacks.length} unauthorized stack(s): ${stackList}\nDo you want to skip all these stacks?`; + + // Ask user if they want to proceed + const response = await ioHelper.requestResponse({ + time: new Date(), + level: 'info', + code: 'CDK_TOOLKIT_I9210', + message, + data: { + stacks: unauthorizedStacks, + count: unauthorizedStacks.length, + responseDescription: '[y]es/[n]o', + }, + defaultResponse: 'y', + }); + + // Throw error is user response is not yes or y + if (!response || !['y', 'yes'].includes(response.toLowerCase())) { + throw new ToolkitError('Operation cancelled by user due to unauthorized stacks'); + } + + await ioHelper.defaults.info(`Skipping ${unauthorizedStacks.length} unauthorized stack(s)`); + } catch (error) { + if (error instanceof ToolkitError) { + throw error; + } + throw new ToolkitError(`Failed to handle unauthorized stacks: ${error}`); + } +} + /** * Fetches all relevant stack templates from CloudFormation. It ignores the following stacks: * - stacks in DELETE_COMPLETE or DELETE_IN_PROGRESS stage @@ -79,6 +142,8 @@ async function fetchAllStackTemplates( await ioHelper.defaults.debug(`Parsing through ${stackNames.length} stacks`); const templates: string[] = []; + const unauthorizedStacks: string[] = []; + for (const stack of stackNames) { try { let summary; @@ -100,9 +165,7 @@ async function fetchAllStackTemplates( // Check if this is a CloudFormation access denied error if (error.name === 'AccessDenied') { if (shouldSkipStack(stack, skipUnauthorizedStacksWhenNonCdk)) { - await ioHelper.defaults.warn( - `Skipping unauthorized stack '${stack}' as specified in --skip-unauthorized-stacks-when-noncdk`, - ); + unauthorizedStacks.push(stack); continue; } @@ -117,6 +180,8 @@ async function fetchAllStackTemplates( } } + await handleUnauthorizedStacks(unauthorizedStacks, ioHelper); + await ioHelper.defaults.debug('Done parsing through stacks'); return templates; diff --git a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts index df798c15e..08c6aa1b4 100644 --- a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts +++ b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts @@ -761,6 +761,9 @@ describe('CloudFormation API calls', () => { cfnClient.on(GetTemplateCommand, { StackName: stackName }).rejects(accessDeniedError); }); + // Mock user response to confirm skipping unauthorized stacks + ioHost.requestSpy.mockResolvedValue('y'); + garbageCollector = new GarbageCollector({ sdkProvider: new MockSdkProvider(), ioHelper: ioHost.asHelper('gc'), @@ -778,7 +781,7 @@ describe('CloudFormation API calls', () => { expect(cfnClient).toHaveReceivedCommandWith(GetTemplateCommand, { StackName: 'CDKStack1' }); expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'warn', message: expect.stringContaining("Skipping unauthorized stack 'Legacy-App-Stack'") }), + expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 3 unauthorized stack(s)') }), ); }); @@ -825,6 +828,9 @@ describe('CloudFormation API calls', () => { cfnClient.on(GetTemplateSummaryCommand, { StackName: stackArn }).resolves({ Parameters: [] }); cfnClient.on(GetTemplateCommand, { StackName: stackArn }).rejects(accessDeniedError); + // Mock user response to confirm skipping unauthorized stacks + ioHost.requestSpy.mockResolvedValue('y'); + garbageCollector = new GarbageCollector({ sdkProvider: new MockSdkProvider(), ioHelper: ioHost.asHelper('gc'), @@ -841,7 +847,7 @@ describe('CloudFormation API calls', () => { await garbageCollector.garbageCollect(); expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'warn', message: expect.stringContaining('Skipping unauthorized stack') }), + expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 1 unauthorized stack(s)') }), ); }); }); diff --git a/packages/aws-cdk/lib/cli/cdk-toolkit.ts b/packages/aws-cdk/lib/cli/cdk-toolkit.ts index 67464ddd1..adae9b2a1 100644 --- a/packages/aws-cdk/lib/cli/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cli/cdk-toolkit.ts @@ -1922,7 +1922,7 @@ export interface GarbageCollectionOptions { /** * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. - * You must explicitly specify non-CDK stack names - CDK stacks will be rejected to prevent accidental asset deletion. + * You must explicitly specify non-CDK stack names. * * @default undefined */ diff --git a/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts b/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts index 0ecf1e4e0..002ad8084 100644 --- a/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts +++ b/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts @@ -367,7 +367,7 @@ export function parseCommandLineArguments(args: Array): any { }) .option('skip-unauthorized-stacks-when-noncdk', { type: 'array', - desc: 'Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names - CDK stacks will be rejected.', + desc: 'Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names.', default: [], requiresArg: true, }), From 7aed817a7ef5bc3e32901920cea9f2ca9f1b772b Mon Sep 17 00:00:00 2001 From: dgandhi62 Date: Fri, 26 Sep 2025 12:04:32 -0400 Subject: [PATCH 3/6] Add environment variable to test for ci environments --- .../test/api/garbage-collection/garbage-collection.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts index 08c6aa1b4..b8d795da9 100644 --- a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts +++ b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts @@ -44,6 +44,9 @@ beforeEach(() => { ioHost.notifySpy.mockClear(); ioHost.requestSpy.mockClear(); + // Set environment variable to prevent CI detection from failing tests + process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED = 'true'; + // By default, we'll return a non-found toolkit info jest.spyOn(ToolkitInfo, 'lookup').mockResolvedValue(ToolkitInfo.bootstrapStackNotFoundInfo('GarbageStack')); @@ -59,6 +62,8 @@ beforeEach(() => { afterEach(() => { stderrMock.mockReset(); + // Clean up environment variable + delete process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED; }); function mockTheToolkitInfo(stackProps: Partial) { From 698f26d776e6414e2f642401b68f1c0e31a29807 Mon Sep 17 00:00:00 2001 From: dgandhi62 Date: Fri, 26 Sep 2025 13:03:45 -0400 Subject: [PATCH 4/6] fix(test): add CI detection for garbage collection tests - Remove global environment variable from test setup and add it locally to test - Add CI detection in failing tests --- .../garbage-collection.test.ts | 66 +++++++++++++++---- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts index b8d795da9..55f873152 100644 --- a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts +++ b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts @@ -44,9 +44,6 @@ beforeEach(() => { ioHost.notifySpy.mockClear(); ioHost.requestSpy.mockClear(); - // Set environment variable to prevent CI detection from failing tests - process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED = 'true'; - // By default, we'll return a non-found toolkit info jest.spyOn(ToolkitInfo, 'lookup').mockResolvedValue(ToolkitInfo.bootstrapStackNotFoundInfo('GarbageStack')); @@ -742,6 +739,18 @@ describe('CloudFormation API calls', () => { }); test('skip stacks using glob patterns when unauthorized', async () => { + // Detect if we're in CI environment + const isCI = process.env.CI === 'true' || + process.env.GITHUB_ACTIONS === 'true' || + process.env.GITLAB_CI === 'true' || + process.env.JENKINS_URL !== undefined || + process.env.BUILDKITE === 'true'; + + // If in CI, set auto-approve env var to prevent hanging + if (isCI) { + process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED = 'true'; + } + mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); cfnClient.on(ListStacksCommand).resolves({ @@ -766,8 +775,10 @@ describe('CloudFormation API calls', () => { cfnClient.on(GetTemplateCommand, { StackName: stackName }).rejects(accessDeniedError); }); - // Mock user response to confirm skipping unauthorized stacks - ioHost.requestSpy.mockResolvedValue('y'); + // Mock user response for interactive mode + if (!isCI) { + ioHost.requestSpy.mockResolvedValue('y'); + } garbageCollector = new GarbageCollector({ sdkProvider: new MockSdkProvider(), @@ -785,9 +796,17 @@ describe('CloudFormation API calls', () => { await garbageCollector.garbageCollect(); expect(cfnClient).toHaveReceivedCommandWith(GetTemplateCommand, { StackName: 'CDKStack1' }); - expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 3 unauthorized stack(s)') }), - ); + + // Expect different messages based on environment + if (isCI) { + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'info', message: expect.stringContaining('Auto-approving 3 unauthorized stack(s) in CI mode') }), + ); + } else { + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 3 unauthorized stack(s)') }), + ); + } }); test('fail on unauthorized stack not matching skip patterns', async () => { @@ -821,6 +840,18 @@ describe('CloudFormation API calls', () => { }); test('extract stack name from ARN for pattern matching', async () => { + // Detect if we're in CI environment + const isCI = process.env.CI === 'true' || + process.env.GITHUB_ACTIONS === 'true' || + process.env.GITLAB_CI === 'true' || + process.env.JENKINS_URL !== undefined || + process.env.BUILDKITE === 'true'; + + // If in CI, set auto-approve env var to prevent hanging + if (isCI) { + process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED = 'true'; + } + mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); const stackArn = 'arn:aws:cloudformation:us-east-1:123456789012:stack/Legacy-App-Stack/12345'; @@ -833,8 +864,10 @@ describe('CloudFormation API calls', () => { cfnClient.on(GetTemplateSummaryCommand, { StackName: stackArn }).resolves({ Parameters: [] }); cfnClient.on(GetTemplateCommand, { StackName: stackArn }).rejects(accessDeniedError); - // Mock user response to confirm skipping unauthorized stacks - ioHost.requestSpy.mockResolvedValue('y'); + // Mock user response for interactive mode + if (!isCI) { + ioHost.requestSpy.mockResolvedValue('y'); + } garbageCollector = new GarbageCollector({ sdkProvider: new MockSdkProvider(), @@ -851,9 +884,16 @@ describe('CloudFormation API calls', () => { await garbageCollector.garbageCollect(); - expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 1 unauthorized stack(s)') }), - ); + // Expect different messages based on environment + if (isCI) { + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'info', message: expect.stringContaining('Auto-approving 1 unauthorized stack(s) in CI mode') }), + ); + } else { + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 1 unauthorized stack(s)') }), + ); + } }); }); From eb74966392e5b51acd2c8887c60401bb5d93cb55 Mon Sep 17 00:00:00 2001 From: dgandhi62 Date: Fri, 10 Oct 2025 17:20:25 -0400 Subject: [PATCH 5/6] feat(gc): change default to 'no' for unauthorized stacks and rename option to --unauth-native-cfn-stacks-to-skip - Change default response from 'yes' to 'no' when prompting to skip unauthorized stacks - Rename parameter from skipUnauthorizedStacksWhenNonCdk to unauthNativeCfnStacksToSkip - Remove wrong ci/cd detection logic --- .../toolkit-lib/docs/message-registry.md | 1 + .../lib/api/garbage-collection/README.md | 78 +++++ .../garbage-collection/garbage-collector.ts | 14 +- .../api/garbage-collection/stack-refresh.ts | 62 ++-- .../lib/api/io/private/messages.ts | 7 +- .../@aws-cdk/toolkit-lib/lib/payloads/gc.ts | 8 + .../__snapshots__/sdk-logger.test.ts.snap | 2 +- .../garbage-collection.test.ts | 106 +++---- packages/aws-cdk/lib/cli/cdk-toolkit.ts | 4 +- packages/aws-cdk/lib/cli/cli.ts | 2 +- .../lib/cli/parse-command-line-arguments.ts | 2 +- packages/cdk-assets/THIRD_PARTY_LICENSES | 286 ++++++++++++++---- 12 files changed, 404 insertions(+), 168 deletions(-) create mode 100644 packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/README.md diff --git a/packages/@aws-cdk/toolkit-lib/docs/message-registry.md b/packages/@aws-cdk/toolkit-lib/docs/message-registry.md index dbe43118c..d034ac9e8 100644 --- a/packages/@aws-cdk/toolkit-lib/docs/message-registry.md +++ b/packages/@aws-cdk/toolkit-lib/docs/message-registry.md @@ -132,6 +132,7 @@ Please let us know by [opening an issue](https://github.com/aws/aws-cdk-cli/issu | `CDK_TOOLKIT_I9000` | Provides bootstrap times | `info` | {@link Duration} | | `CDK_TOOLKIT_I9100` | Bootstrap progress | `info` | {@link BootstrapEnvironmentProgress} | | `CDK_TOOLKIT_I9210` | Confirm the deletion of a batch of assets | `info` | {@link AssetBatchDeletionRequest} | +| `CDK_TOOLKIT_I9211` | Confirm skipping unauthorized stacks during garbage collection | `info` | {@link UnauthorizedStacksRequest} | | `CDK_TOOLKIT_I9900` | Bootstrap results on success | `result` | [cxapi.Environment](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_cx-api.Environment.html) | | `CDK_TOOLKIT_E9900` | Bootstrap failed | `error` | {@link ErrorPayload} | | `CDK_TOOLKIT_I9300` | Confirm the feature flag configuration changes | `info` | {@link FeatureFlagChangeRequest} | diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/README.md b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/README.md new file mode 100644 index 000000000..239dfd351 --- /dev/null +++ b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/README.md @@ -0,0 +1,78 @@ +# CDK Garbage Collection - Skip Unauthorized Native CloudFormation Stacks + +This document describes the `--unauth-native-cfn-stacks-to-skip` option that allows users to provide patterns to automatically skip unauthorized native CloudFormation stacks. + +## Overview + +When CDK Garbage Collection scans CloudFormation stacks to determine which assets are still in use, it may encounter stacks that it cannot access due to insufficient permissions. + +**Without skip patterns configured:** +1. **Prompt the user** asking whether to skip the unauthorized stacks +2. **Default to 'no'** - the operation will be cancelled unless the user explicitly chooses to skip +3. **List the unauthorized stacks** that were found + +**With skip patterns configured:** +- Stacks matching the patterns are automatically skipped without prompting +- Only non-matching unauthorized stacks will prompt the user + +The user needs to ensure that the stacks they intend to skip are native CloudFormation stacks (not CDK-managed). The option does NOT check this. Attempting to skip CDK stacks during gc can be hazardous + +Example prompt: +``` +Found 3 unauthorized stack(s): Legacy-App-Stack, +Legacy-DB-Stack, +ThirdParty-Service +Do you want to skip all these stacks? Default is 'no' [y]es/[n]o +``` + +## Skip Patterns Configuration + +Users can provide glob patterns to automatically skip unauthorized stacks using the `--unauth-native-cfn-stacks-to-skip` option: + +```bash +cdk gc --unstable=gc --unauth-native-cfn-stacks-to-skip "Legacy-*" "ThirdParty-*" +``` + +**How it works:** +- Patterns are checked against unauthorized stack names +- Matching stacks are automatically skipped +- Non-matching unauthorized stacks still prompt the user with default 'no' + +### Pattern Matching + +- Supports glob patterns (`*`, `**`) +- Extracts stack names from ARNs automatically +- Case-sensitive matching + +Examples: +- `Legacy-*` matches `Legacy-App-Stack`, `Legacy-DB-Stack` +- `*-Prod` matches `MyApp-Prod`, `Database-Prod` +- `ThirdParty-*` matches `ThirdParty-Service`, `ThirdParty-API` + +## Security Considerations + +The default behavior of requiring explicit user confirmation to skip stacks helps prevent: + +- Accidentally skipping important stacks +- Missing assets that might be referenced by inaccessible stacks +- Unintended deletion of assets in shared environments + +## CI/CD Environments + +In CI/CD environments where user interaction is not possible: + +- The default 'no' response will cause the operation to fail +- Consider implementing proper IAM permissions instead of skipping stacks + + +## Implementation Details + +The skip patterns feature is implemented in `stack-refresh.ts`: + +1. Attempt to access each stack template +2. Catch `AccessDenied` errors +3. Check if stack name matches any user-provided skip patterns +4. **If pattern matches:** automatically skip without prompting +5. **If no pattern matches:** prompt user whether to skip (defaults to 'no') + +This ensures that only stacks matching user-specified patterns are skipped automatically, maintaining security by default. \ No newline at end of file diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts index 13496ca0a..c1859d350 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts @@ -180,12 +180,12 @@ interface GarbageCollectorProps { readonly confirm?: boolean; /** - * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. - * You must explicitly specify non-CDK stack names + * Native CloudFormation stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. + * You must explicitly specify native CloudFormation stack names * * @default undefined */ - readonly skipUnauthorizedStacksWhenNonCdk?: string[]; + readonly unauthNativeCfnStacksToSkip?: string[]; } /** @@ -199,7 +199,7 @@ export class GarbageCollector { private bootstrapStackName: string; private confirm: boolean; private ioHelper: IoHelper; - private skipUnauthorizedStacksWhenNonCdk?: string[]; + private unauthNativeCfnStacksToSkip?: string[]; public constructor(readonly props: GarbageCollectorProps) { this.ioHelper = props.ioHelper; @@ -210,7 +210,7 @@ export class GarbageCollector { this.permissionToDelete = ['delete-tagged', 'full'].includes(props.action); this.permissionToTag = ['tag', 'full'].includes(props.action); this.confirm = props.confirm ?? true; - this.skipUnauthorizedStacksWhenNonCdk = props.skipUnauthorizedStacksWhenNonCdk; + this.unauthNativeCfnStacksToSkip = props.unauthNativeCfnStacksToSkip; this.bootstrapStackName = props.bootstrapStackName ?? DEFAULT_TOOLKIT_STACK_NAME; } @@ -234,7 +234,7 @@ export class GarbageCollector { ioHelper: this.ioHelper, activeAssets, qualifier, - skipUnauthorizedStacksWhenNonCdk: this.skipUnauthorizedStacksWhenNonCdk, + unauthNativeCfnStacksToSkip: this.unauthNativeCfnStacksToSkip, }); // Start the background refresh const backgroundStackRefresh = new BackgroundStackRefresh({ @@ -242,7 +242,7 @@ export class GarbageCollector { ioHelper: this.ioHelper, activeAssets, qualifier, - skipUnauthorizedStacksWhenNonCdk: this.skipUnauthorizedStacksWhenNonCdk, + unauthNativeCfnStacksToSkip: this.unauthNativeCfnStacksToSkip, }); backgroundStackRefresh.start(); diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts index 67b79f52c..4dfa27dea 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts @@ -3,6 +3,7 @@ import { minimatch } from 'minimatch'; import { ToolkitError } from '../../toolkit/toolkit-error'; import type { ICloudFormationClient } from '../aws-auth/private'; import type { IoHelper } from '../io/private'; +import { IO } from '../io/private/messages'; export class ActiveAssetCache { private readonly stacks: Set = new Set(); @@ -12,8 +13,8 @@ export class ActiveAssetCache { } public contains(asset: string): boolean { - // To reduce computation if asset is null or undefined - if (!asset) return false; + // To reduce computation if asset is empty + if (asset=='') return false; for (const stack of this.stacks) { if (stack.includes(asset)) { @@ -60,45 +61,18 @@ async function handleUnauthorizedStacks(unauthorizedStacks: string[], ioHelper: return; } - // Auto-approve in CI environments - if (process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED === 'true') { - await ioHelper.defaults.info(`Auto-approving ${unauthorizedStacks.length} unauthorized stack(s) in CI mode`); - return; - } - - // Detect CI environment and fail fast to prevent hanging - const isCI = process.env.CI === 'true' || - process.env.GITHUB_ACTIONS === 'true' || - process.env.GITLAB_CI === 'true' || - process.env.JENKINS_URL !== undefined || - process.env.BUILDKITE === 'true'; - - if (isCI) { - throw new ToolkitError( - `Found ${unauthorizedStacks.length} unauthorized stack(s) in CI environment. ` + - 'Set CDK_GC_AUTO_APPROVE_UNAUTHORIZED=true to auto-approve or configure --skip-unauthorized-stacks-when-noncdk.', - ); - } - try { - const stackList = unauthorizedStacks.join(', '); - const message = `Found ${unauthorizedStacks.length} unauthorized stack(s): ${stackList}\nDo you want to skip all these stacks?`; - - // Ask user if they want to proceed - const response = await ioHelper.requestResponse({ - time: new Date(), - level: 'info', - code: 'CDK_TOOLKIT_I9210', - message, - data: { + // Ask user if they want to proceed. Default is no + // In CI environments, IoHelper automatically accepts the default response + const response = await ioHelper.requestResponse( + IO.CDK_TOOLKIT_I9211.req(`Found ${unauthorizedStacks.length} unauthorized stack(s): ${unauthorizedStacks.join(',\n')}\nDo you want to skip all these stacks? Default is 'no'`, { stacks: unauthorizedStacks, count: unauthorizedStacks.length, responseDescription: '[y]es/[n]o', - }, - defaultResponse: 'y', - }); + }, 'n'), // To account for ci/cd environments, default remains no until a --yes flag is implemented for cdk-cli + ); - // Throw error is user response is not yes or y + // Throw error if user response is not yes or y if (!response || !['y', 'yes'].includes(response.toLowerCase())) { throw new ToolkitError('Operation cancelled by user due to unauthorized stacks'); } @@ -122,7 +96,7 @@ async function fetchAllStackTemplates( cfn: ICloudFormationClient, ioHelper: IoHelper, qualifier?: string, - skipUnauthorizedStacksWhenNonCdk?: string[], + unauthNativeCfnStacksToSkip?: string[], ) { const stackNames: string[] = []; await paginateSdkCall(async (nextToken) => { @@ -164,14 +138,14 @@ async function fetchAllStackTemplates( } catch (error: any) { // Check if this is a CloudFormation access denied error if (error.name === 'AccessDenied') { - if (shouldSkipStack(stack, skipUnauthorizedStacksWhenNonCdk)) { + if (shouldSkipStack(stack, unauthNativeCfnStacksToSkip)) { unauthorizedStacks.push(stack); continue; } throw new ToolkitError( `Access denied when trying to access stack '${stack}'. ` + - 'If this is a non-CDK stack that you want to skip, add it to --skip-unauthorized-stacks-when-noncdk.', + 'If this is a native CloudFormation stack that you want to skip, add it to --unauth-native-cfn-stacks-to-skip.', ); } @@ -211,7 +185,7 @@ export interface RefreshStacksProps { readonly ioHelper: IoHelper; readonly activeAssets: ActiveAssetCache; readonly qualifier?: string; - readonly skipUnauthorizedStacksWhenNonCdk?: string[]; + readonly unauthNativeCfnStacksToSkip?: string[]; } export async function refreshStacks(props: RefreshStacksProps) { @@ -220,7 +194,7 @@ export async function refreshStacks(props: RefreshStacksProps) { props.cfn, props.ioHelper, props.qualifier, - props.skipUnauthorizedStacksWhenNonCdk, + props.unauthNativeCfnStacksToSkip, ); for (const stack of stacks) { props.activeAssets.rememberStack(stack); @@ -255,9 +229,9 @@ export interface BackgroundStackRefreshProps { readonly qualifier?: string; /** - * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors + * Native CloudFormation stack names or glob patterns to skip when encountering unauthorized access errors */ - readonly skipUnauthorizedStacksWhenNonCdk?: string[]; + readonly unauthNativeCfnStacksToSkip?: string[]; } /** @@ -286,7 +260,7 @@ export class BackgroundStackRefresh { ioHelper: this.props.ioHelper, activeAssets: this.props.activeAssets, qualifier: this.props.qualifier, - skipUnauthorizedStacksWhenNonCdk: this.props.skipUnauthorizedStacksWhenNonCdk, + unauthNativeCfnStacksToSkip: this.props.unauthNativeCfnStacksToSkip, }); this.justRefreshedStacks(); diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/messages.ts b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/messages.ts index 82435c09a..d22d4eae1 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/messages.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/messages.ts @@ -8,7 +8,7 @@ import type { BuildAsset, DeployConfirmationRequest, PublishAsset, StackDeployPr import type { StackDestroy, StackDestroyProgress } from '../../../payloads/destroy'; import type { DriftResultPayload } from '../../../payloads/drift'; import type { FeatureFlagChangeRequest } from '../../../payloads/flags'; -import type { AssetBatchDeletionRequest } from '../../../payloads/gc'; +import type { AssetBatchDeletionRequest, UnauthorizedStacksRequest } from '../../../payloads/gc'; import type { HotswapDeploymentDetails, HotswapDeploymentAttempt, HotswappableChange, HotswapResult } from '../../../payloads/hotswap'; import type { ResourceIdentificationRequest, ResourceImportRequest } from '../../../payloads/import'; import type { StackDetailsPayload } from '../../../payloads/list'; @@ -419,6 +419,11 @@ export const IO = { description: 'Confirm the deletion of a batch of assets', interface: 'AssetBatchDeletionRequest', }), + CDK_TOOLKIT_I9211: make.question({ + code: 'CDK_TOOLKIT_I9211', + description: 'Confirm skipping unauthorized stacks during garbage collection', + interface: 'UnauthorizedStacksRequest', + }), CDK_TOOLKIT_I9900: make.result<{ environment: cxapi.Environment }>({ code: 'CDK_TOOLKIT_I9900', diff --git a/packages/@aws-cdk/toolkit-lib/lib/payloads/gc.ts b/packages/@aws-cdk/toolkit-lib/lib/payloads/gc.ts index b807745ff..23f7af88c 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/payloads/gc.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/payloads/gc.ts @@ -11,3 +11,11 @@ export interface AssetBatchDeletionRequest extends DataRequest { readonly createdBufferDays: number; }; } + +/** + * Request to confirm skipping unauthorized stacks during garbage collection. + */ +export interface UnauthorizedStacksRequest extends DataRequest { + readonly stacks: string[]; + readonly count: number; +} diff --git a/packages/@aws-cdk/toolkit-lib/test/api/aws-auth/__snapshots__/sdk-logger.test.ts.snap b/packages/@aws-cdk/toolkit-lib/test/api/aws-auth/__snapshots__/sdk-logger.test.ts.snap index 8fb0d999e..467b9b46b 100644 --- a/packages/@aws-cdk/toolkit-lib/test/api/aws-auth/__snapshots__/sdk-logger.test.ts.snap +++ b/packages/@aws-cdk/toolkit-lib/test/api/aws-auth/__snapshots__/sdk-logger.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`formatting a failing SDK call looks broadly reasonable 1`] = `"[2 attempts, 30ms retry] S3.GetBucketLocation({"Bucket":"....."}) -> Error: it failed"`; diff --git a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts index 55f873152..baa890dbc 100644 --- a/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts +++ b/packages/@aws-cdk/toolkit-lib/test/api/garbage-collection/garbage-collection.test.ts @@ -59,8 +59,6 @@ beforeEach(() => { afterEach(() => { stderrMock.mockReset(); - // Clean up environment variable - delete process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED; }); function mockTheToolkitInfo(stackProps: Partial) { @@ -739,18 +737,6 @@ describe('CloudFormation API calls', () => { }); test('skip stacks using glob patterns when unauthorized', async () => { - // Detect if we're in CI environment - const isCI = process.env.CI === 'true' || - process.env.GITHUB_ACTIONS === 'true' || - process.env.GITLAB_CI === 'true' || - process.env.JENKINS_URL !== undefined || - process.env.BUILDKITE === 'true'; - - // If in CI, set auto-approve env var to prevent hanging - if (isCI) { - process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED = 'true'; - } - mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); cfnClient.on(ListStacksCommand).resolves({ @@ -775,10 +761,8 @@ describe('CloudFormation API calls', () => { cfnClient.on(GetTemplateCommand, { StackName: stackName }).rejects(accessDeniedError); }); - // Mock user response for interactive mode - if (!isCI) { - ioHost.requestSpy.mockResolvedValue('y'); - } + // Mock user response - IoHelper will use default 'n' in CI environments, so we need to explicitly say 'y' + ioHost.requestSpy.mockResolvedValue('y'); garbageCollector = new GarbageCollector({ sdkProvider: new MockSdkProvider(), @@ -790,23 +774,15 @@ describe('CloudFormation API calls', () => { createdBufferDays: 0, type: 's3', confirm: false, - skipUnauthorizedStacksWhenNonCdk: ['Legacy-*', 'ThirdParty-*'], + unauthNativeCfnStacksToSkip: ['Legacy-*', 'ThirdParty-*'], }); await garbageCollector.garbageCollect(); expect(cfnClient).toHaveReceivedCommandWith(GetTemplateCommand, { StackName: 'CDKStack1' }); - - // Expect different messages based on environment - if (isCI) { - expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'info', message: expect.stringContaining('Auto-approving 3 unauthorized stack(s) in CI mode') }), - ); - } else { - expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 3 unauthorized stack(s)') }), - ); - } + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 3 unauthorized stack(s)') }), + ); }); test('fail on unauthorized stack not matching skip patterns', async () => { @@ -831,7 +807,7 @@ describe('CloudFormation API calls', () => { createdBufferDays: 0, type: 's3', confirm: false, - skipUnauthorizedStacksWhenNonCdk: ['Legacy-*'], + unauthNativeCfnStacksToSkip: ['Legacy-*'], }); await expect(garbageCollector.garbageCollect()).rejects.toThrow( @@ -840,18 +816,6 @@ describe('CloudFormation API calls', () => { }); test('extract stack name from ARN for pattern matching', async () => { - // Detect if we're in CI environment - const isCI = process.env.CI === 'true' || - process.env.GITHUB_ACTIONS === 'true' || - process.env.GITLAB_CI === 'true' || - process.env.JENKINS_URL !== undefined || - process.env.BUILDKITE === 'true'; - - // If in CI, set auto-approve env var to prevent hanging - if (isCI) { - process.env.CDK_GC_AUTO_APPROVE_UNAUTHORIZED = 'true'; - } - mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); const stackArn = 'arn:aws:cloudformation:us-east-1:123456789012:stack/Legacy-App-Stack/12345'; @@ -864,10 +828,8 @@ describe('CloudFormation API calls', () => { cfnClient.on(GetTemplateSummaryCommand, { StackName: stackArn }).resolves({ Parameters: [] }); cfnClient.on(GetTemplateCommand, { StackName: stackArn }).rejects(accessDeniedError); - // Mock user response for interactive mode - if (!isCI) { - ioHost.requestSpy.mockResolvedValue('y'); - } + // Mock user response - IoHelper will use default 'n' in CI environments, so we need to explicitly say 'y' + ioHost.requestSpy.mockResolvedValue('y'); garbageCollector = new GarbageCollector({ sdkProvider: new MockSdkProvider(), @@ -879,21 +841,49 @@ describe('CloudFormation API calls', () => { createdBufferDays: 0, type: 's3', confirm: false, - skipUnauthorizedStacksWhenNonCdk: ['Legacy-*'], + unauthNativeCfnStacksToSkip: ['Legacy-*'], }); await garbageCollector.garbageCollect(); - // Expect different messages based on environment - if (isCI) { - expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'info', message: expect.stringContaining('Auto-approving 1 unauthorized stack(s) in CI mode') }), - ); - } else { - expect(ioHost.notifySpy).toHaveBeenCalledWith( - expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 1 unauthorized stack(s)') }), - ); - } + expect(ioHost.notifySpy).toHaveBeenCalledWith( + expect.objectContaining({ level: 'info', message: expect.stringContaining('Skipping 1 unauthorized stack(s)') }), + ); + }); + + test('user can decline to skip unauthorized stacks', async () => { + mockTheToolkitInfo({ Outputs: [{ OutputKey: 'BootstrapVersion', OutputValue: '999' }] }); + + cfnClient.on(ListStacksCommand).resolves({ + StackSummaries: [ + { StackName: 'Legacy-App-Stack', StackStatus: 'CREATE_COMPLETE', CreationTime: new Date() }, + ], + }); + + const accessDeniedError = new Error('Access Denied'); + accessDeniedError.name = 'AccessDenied'; + cfnClient.on(GetTemplateSummaryCommand, { StackName: 'Legacy-App-Stack' }).resolves({ Parameters: [] }); + cfnClient.on(GetTemplateCommand, { StackName: 'Legacy-App-Stack' }).rejects(accessDeniedError); + + // Mock user declining to skip + ioHost.requestSpy.mockResolvedValue('n'); + + garbageCollector = new GarbageCollector({ + sdkProvider: new MockSdkProvider(), + ioHelper: ioHost.asHelper('gc'), + action: 'full', + resolvedEnvironment: { account: '123456789012', region: 'us-east-1', name: 'mock' }, + bootstrapStackName: 'GarbageStack', + rollbackBufferDays: 0, + createdBufferDays: 0, + type: 's3', + confirm: false, + unauthNativeCfnStacksToSkip: ['Legacy-*'], + }); + + await expect(garbageCollector.garbageCollect()).rejects.toThrow( + 'Operation cancelled by user due to unauthorized stacks', + ); }); }); diff --git a/packages/aws-cdk/lib/cli/cdk-toolkit.ts b/packages/aws-cdk/lib/cli/cdk-toolkit.ts index e766f516f..08935d503 100644 --- a/packages/aws-cdk/lib/cli/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cli/cdk-toolkit.ts @@ -1136,7 +1136,7 @@ export class CdkToolkit { action: options.action ?? 'full', type: options.type ?? 'all', confirm: options.confirm ?? true, - skipUnauthorizedStacksWhenNonCdk: options.skipUnauthorizedStacksWhenNonCdk, + unauthNativeCfnStacksToSkip: options.unauthNativeCfnStacksToSkip, }); await gc.garbageCollect(); } @@ -1929,7 +1929,7 @@ export interface GarbageCollectionOptions { * * @default undefined */ - readonly skipUnauthorizedStacksWhenNonCdk?: string[]; + readonly unauthNativeCfnStacksToSkip?: string[]; } export interface MigrateOptions { /** diff --git a/packages/aws-cdk/lib/cli/cli.ts b/packages/aws-cdk/lib/cli/cli.ts index dd19beab0..f978e8c1e 100644 --- a/packages/aws-cdk/lib/cli/cli.ts +++ b/packages/aws-cdk/lib/cli/cli.ts @@ -482,7 +482,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise): any { requiresArg: true, conflicts: 'toolkit-stack-name', }) - .option('skip-unauthorized-stacks-when-noncdk', { + .option('unauth-native-cfn-stacks-to-skip', { type: 'array', desc: 'Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names.', default: [], diff --git a/packages/cdk-assets/THIRD_PARTY_LICENSES b/packages/cdk-assets/THIRD_PARTY_LICENSES index beeea79fa..dfb8e291e 100644 --- a/packages/cdk-assets/THIRD_PARTY_LICENSES +++ b/packages/cdk-assets/THIRD_PARTY_LICENSES @@ -618,7 +618,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-cognito-identity@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-cognito-identity/v/3.893.0 | Apache-2.0 +** @aws-sdk/client-cognito-identity@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-cognito-identity/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -824,7 +824,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-ecr@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-ecr/v/3.893.0 | Apache-2.0 +** @aws-sdk/client-ecr@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-ecr/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1030,7 +1030,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-s3@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-s3/v/3.893.0 | Apache-2.0 +** @aws-sdk/client-s3@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-s3/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1236,7 +1236,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-secrets-manager@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-secrets-manager/v/3.893.0 | Apache-2.0 +** @aws-sdk/client-secrets-manager@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-secrets-manager/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1442,7 +1442,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-sso@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-sso/v/3.893.0 | Apache-2.0 +** @aws-sdk/client-sso@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-sso/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1648,7 +1648,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-sts@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-sts/v/3.893.0 | Apache-2.0 +** @aws-sdk/client-sts@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-sts/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1854,11 +1854,11 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/core@3.893.0 - https://www.npmjs.com/package/@aws-sdk/core/v/3.893.0 | Apache-2.0 +** @aws-sdk/core@3.894.0 - https://www.npmjs.com/package/@aws-sdk/core/v/3.894.0 | Apache-2.0 ---------------- -** @aws-sdk/credential-provider-cognito-identity@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-cognito-identity/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-cognito-identity@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-cognito-identity/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2064,7 +2064,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/credential-provider-env@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-env/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-env@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-env/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2269,11 +2269,11 @@ Apache License ---------------- -** @aws-sdk/credential-provider-http@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-http/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-http@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-http/v/3.894.0 | Apache-2.0 ---------------- -** @aws-sdk/credential-provider-ini@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-ini/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-ini@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-ini/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2478,7 +2478,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-node@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-node/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-node@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-node/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2683,7 +2683,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-process@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-process/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-process@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-process/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2888,7 +2888,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-sso@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-sso/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-sso@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-sso/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -3093,7 +3093,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-web-identity@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-web-identity/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-provider-web-identity@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-web-identity/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -3298,7 +3298,7 @@ Apache License ---------------- -** @aws-sdk/credential-providers@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-providers/v/3.893.0 | Apache-2.0 +** @aws-sdk/credential-providers@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-providers/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -3503,7 +3503,7 @@ Apache License ---------------- -** @aws-sdk/lib-storage@3.893.0 - https://www.npmjs.com/package/@aws-sdk/lib-storage/v/3.893.0 | Apache-2.0 +** @aws-sdk/lib-storage@3.894.0 - https://www.npmjs.com/package/@aws-sdk/lib-storage/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -4120,7 +4120,7 @@ Apache License ---------------- -** @aws-sdk/middleware-flexible-checksums@3.893.0 - https://www.npmjs.com/package/@aws-sdk/middleware-flexible-checksums/v/3.893.0 | Apache-2.0 +** @aws-sdk/middleware-flexible-checksums@3.894.0 - https://www.npmjs.com/package/@aws-sdk/middleware-flexible-checksums/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -5149,7 +5149,7 @@ Apache License ---------------- -** @aws-sdk/middleware-sdk-s3@3.893.0 - https://www.npmjs.com/package/@aws-sdk/middleware-sdk-s3/v/3.893.0 | Apache-2.0 +** @aws-sdk/middleware-sdk-s3@3.894.0 - https://www.npmjs.com/package/@aws-sdk/middleware-sdk-s3/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -5561,7 +5561,7 @@ Apache License ---------------- -** @aws-sdk/middleware-user-agent@3.893.0 - https://www.npmjs.com/package/@aws-sdk/middleware-user-agent/v/3.893.0 | Apache-2.0 +** @aws-sdk/middleware-user-agent@3.894.0 - https://www.npmjs.com/package/@aws-sdk/middleware-user-agent/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -5767,7 +5767,7 @@ Apache License ---------------- -** @aws-sdk/nested-clients@3.893.0 - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.893.0 | Apache-2.0 +** @aws-sdk/nested-clients@3.894.0 - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.894.0 | Apache-2.0 ---------------- @@ -5976,7 +5976,7 @@ Apache License ---------------- -** @aws-sdk/signature-v4-multi-region@3.893.0 - https://www.npmjs.com/package/@aws-sdk/signature-v4-multi-region/v/3.893.0 | Apache-2.0 +** @aws-sdk/signature-v4-multi-region@3.894.0 - https://www.npmjs.com/package/@aws-sdk/signature-v4-multi-region/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -6182,7 +6182,7 @@ Apache License ---------------- -** @aws-sdk/token-providers@3.893.0 - https://www.npmjs.com/package/@aws-sdk/token-providers/v/3.893.0 | Apache-2.0 +** @aws-sdk/token-providers@3.894.0 - https://www.npmjs.com/package/@aws-sdk/token-providers/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -6797,7 +6797,7 @@ Apache License ---------------- -** @aws-sdk/util-user-agent-node@3.893.0 - https://www.npmjs.com/package/@aws-sdk/util-user-agent-node/v/3.893.0 | Apache-2.0 +** @aws-sdk/util-user-agent-node@3.894.0 - https://www.npmjs.com/package/@aws-sdk/util-user-agent-node/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -7003,7 +7003,7 @@ Apache License ---------------- -** @aws-sdk/xml-builder@3.893.0 - https://www.npmjs.com/package/@aws-sdk/xml-builder/v/3.893.0 | Apache-2.0 +** @aws-sdk/xml-builder@3.894.0 - https://www.npmjs.com/package/@aws-sdk/xml-builder/v/3.894.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -16963,7 +16963,7 @@ THE SOFTWARE. ---------------- -** b4a@1.7.1 - https://www.npmjs.com/package/b4a/v/1.7.1 | Apache-2.0 +** b4a@1.7.2 - https://www.npmjs.com/package/b4a/v/1.7.2 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -17626,6 +17626,212 @@ SOFTWARE. +---------------- + +** events-universal@1.0.1 - https://www.npmjs.com/package/events-universal/v/1.0.1 | Apache-2.0 + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ---------------- ** fast-fifo@1.3.2 - https://www.npmjs.com/package/fast-fifo/v/1.3.2 | MIT @@ -18374,7 +18580,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ---------------- -** streamx@2.22.1 - https://www.npmjs.com/package/streamx/v/2.22.1 | MIT +** streamx@2.23.0 - https://www.npmjs.com/package/streamx/v/2.23.0 | MIT The MIT License (MIT) Copyright (c) 2019 Mathias Buus @@ -18532,32 +18738,6 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------- - -** strnum@2.1.1 - https://www.npmjs.com/package/strnum/v/2.1.1 | MIT -MIT License - -Copyright (c) 2021 Natural Intelligence - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - ---------------- ** tar-stream@3.1.7 - https://www.npmjs.com/package/tar-stream/v/3.1.7 | MIT From 87054d990dcf65c08593922bf778045e31241edb Mon Sep 17 00:00:00 2001 From: dgandhi62 Date: Tue, 21 Oct 2025 01:19:41 -0400 Subject: [PATCH 6/6] fix: add option to cli-config and remove it from parse-command-line-arguments --- packages/aws-cdk/lib/cli/cli-config.ts | 1 + .../aws-cdk/lib/cli/cli-type-registry.json | 6 + .../aws-cdk/lib/cli/convert-to-user-input.ts | 2 + .../lib/cli/parse-command-line-arguments.ts | 1 + packages/aws-cdk/lib/cli/user-input.ts | 7 + packages/cdk-assets/THIRD_PARTY_LICENSES | 286 ++++-------------- 6 files changed, 70 insertions(+), 233 deletions(-) diff --git a/packages/aws-cdk/lib/cli/cli-config.ts b/packages/aws-cdk/lib/cli/cli-config.ts index fbe1aefcb..b46222cdc 100644 --- a/packages/aws-cdk/lib/cli/cli-config.ts +++ b/packages/aws-cdk/lib/cli/cli-config.ts @@ -114,6 +114,7 @@ export async function makeConfig(): Promise { 'confirm': { type: 'boolean', desc: 'Confirm via manual prompt before deletion', default: true }, 'toolkit-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit"', requiresArg: true, conflicts: 'bootstrap-stack-name' }, 'bootstrap-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit" (deprecated, use --toolkit-stack-name)', deprecated: 'use --toolkit-stack-name', requiresArg: true, conflicts: 'toolkit-stack-name' }, // TODO: remove when garbage collection is GA + 'unauth-native-cfn-stacks-to-skip': { type: 'array', desc: 'Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names.', default: [], requiresArg: true }, }, }, 'flags': { diff --git a/packages/aws-cdk/lib/cli/cli-type-registry.json b/packages/aws-cdk/lib/cli/cli-type-registry.json index 3d7cbb488..57335cbef 100644 --- a/packages/aws-cdk/lib/cli/cli-type-registry.json +++ b/packages/aws-cdk/lib/cli/cli-type-registry.json @@ -338,6 +338,12 @@ "deprecated": "use --toolkit-stack-name", "requiresArg": true, "conflicts": "toolkit-stack-name" + }, + "unauth-native-cfn-stacks-to-skip": { + "type": "array", + "desc": "Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names.", + "default": [], + "requiresArg": true } } }, diff --git a/packages/aws-cdk/lib/cli/convert-to-user-input.ts b/packages/aws-cdk/lib/cli/convert-to-user-input.ts index 26e5c18cf..8a5766bda 100644 --- a/packages/aws-cdk/lib/cli/convert-to-user-input.ts +++ b/packages/aws-cdk/lib/cli/convert-to-user-input.ts @@ -92,6 +92,7 @@ export function convertYargsToUserInput(args: any): UserInput { confirm: args.confirm, toolkitStackName: args.toolkitStackName, bootstrapStackName: args.bootstrapStackName, + unauthNativeCfnStacksToSkip: args.unauthNativeCfnStacksToSkip, ENVIRONMENTS: args.ENVIRONMENTS, }; break; @@ -384,6 +385,7 @@ export function convertConfigToUserInput(config: any): UserInput { confirm: config.gc?.confirm, toolkitStackName: config.gc?.toolkitStackName, bootstrapStackName: config.gc?.bootstrapStackName, + unauthNativeCfnStacksToSkip: config.gc?.unauthNativeCfnStacksToSkip, }; const flagsOptions = { value: config.flags?.value, diff --git a/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts b/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts index a4510eac2..0fa582620 100644 --- a/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts +++ b/packages/aws-cdk/lib/cli/parse-command-line-arguments.ts @@ -370,6 +370,7 @@ export function parseCommandLineArguments(args: Array): any { desc: 'Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names.', default: [], requiresArg: true, + nargs: 1, }), ) .command('flags [FLAGNAME..]', 'View and toggle feature flags.', (yargs: Argv) => diff --git a/packages/aws-cdk/lib/cli/user-input.ts b/packages/aws-cdk/lib/cli/user-input.ts index 6a18b5873..e9b57c93f 100644 --- a/packages/aws-cdk/lib/cli/user-input.ts +++ b/packages/aws-cdk/lib/cli/user-input.ts @@ -618,6 +618,13 @@ export interface GcOptions { */ readonly bootstrapStackName?: string; + /** + * Non-CDK stack names or glob patterns to skip when encountering unauthorized access errors during garbage collection. You must explicitly specify non-CDK stack names. + * + * @default - [] + */ + readonly unauthNativeCfnStacksToSkip?: Array; + /** * Positional argument for gc */ diff --git a/packages/cdk-assets/THIRD_PARTY_LICENSES b/packages/cdk-assets/THIRD_PARTY_LICENSES index dfb8e291e..beeea79fa 100644 --- a/packages/cdk-assets/THIRD_PARTY_LICENSES +++ b/packages/cdk-assets/THIRD_PARTY_LICENSES @@ -618,7 +618,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-cognito-identity@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-cognito-identity/v/3.894.0 | Apache-2.0 +** @aws-sdk/client-cognito-identity@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-cognito-identity/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -824,7 +824,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-ecr@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-ecr/v/3.894.0 | Apache-2.0 +** @aws-sdk/client-ecr@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-ecr/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1030,7 +1030,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-s3@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-s3/v/3.894.0 | Apache-2.0 +** @aws-sdk/client-s3@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-s3/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1236,7 +1236,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-secrets-manager@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-secrets-manager/v/3.894.0 | Apache-2.0 +** @aws-sdk/client-secrets-manager@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-secrets-manager/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1442,7 +1442,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-sso@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-sso/v/3.894.0 | Apache-2.0 +** @aws-sdk/client-sso@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-sso/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1648,7 +1648,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/client-sts@3.894.0 - https://www.npmjs.com/package/@aws-sdk/client-sts/v/3.894.0 | Apache-2.0 +** @aws-sdk/client-sts@3.893.0 - https://www.npmjs.com/package/@aws-sdk/client-sts/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -1854,11 +1854,11 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/core@3.894.0 - https://www.npmjs.com/package/@aws-sdk/core/v/3.894.0 | Apache-2.0 +** @aws-sdk/core@3.893.0 - https://www.npmjs.com/package/@aws-sdk/core/v/3.893.0 | Apache-2.0 ---------------- -** @aws-sdk/credential-provider-cognito-identity@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-cognito-identity/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-cognito-identity@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-cognito-identity/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2064,7 +2064,7 @@ The cdk-assets package includes the following third-party software/licensing: ---------------- -** @aws-sdk/credential-provider-env@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-env/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-env@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-env/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2269,11 +2269,11 @@ Apache License ---------------- -** @aws-sdk/credential-provider-http@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-http/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-http@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-http/v/3.893.0 | Apache-2.0 ---------------- -** @aws-sdk/credential-provider-ini@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-ini/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-ini@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-ini/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2478,7 +2478,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-node@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-node/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-node@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-node/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2683,7 +2683,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-process@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-process/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-process@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-process/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -2888,7 +2888,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-sso@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-sso/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-sso@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-sso/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -3093,7 +3093,7 @@ Apache License ---------------- -** @aws-sdk/credential-provider-web-identity@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-web-identity/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-provider-web-identity@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-provider-web-identity/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -3298,7 +3298,7 @@ Apache License ---------------- -** @aws-sdk/credential-providers@3.894.0 - https://www.npmjs.com/package/@aws-sdk/credential-providers/v/3.894.0 | Apache-2.0 +** @aws-sdk/credential-providers@3.893.0 - https://www.npmjs.com/package/@aws-sdk/credential-providers/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -3503,7 +3503,7 @@ Apache License ---------------- -** @aws-sdk/lib-storage@3.894.0 - https://www.npmjs.com/package/@aws-sdk/lib-storage/v/3.894.0 | Apache-2.0 +** @aws-sdk/lib-storage@3.893.0 - https://www.npmjs.com/package/@aws-sdk/lib-storage/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -4120,7 +4120,7 @@ Apache License ---------------- -** @aws-sdk/middleware-flexible-checksums@3.894.0 - https://www.npmjs.com/package/@aws-sdk/middleware-flexible-checksums/v/3.894.0 | Apache-2.0 +** @aws-sdk/middleware-flexible-checksums@3.893.0 - https://www.npmjs.com/package/@aws-sdk/middleware-flexible-checksums/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -5149,7 +5149,7 @@ Apache License ---------------- -** @aws-sdk/middleware-sdk-s3@3.894.0 - https://www.npmjs.com/package/@aws-sdk/middleware-sdk-s3/v/3.894.0 | Apache-2.0 +** @aws-sdk/middleware-sdk-s3@3.893.0 - https://www.npmjs.com/package/@aws-sdk/middleware-sdk-s3/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -5561,7 +5561,7 @@ Apache License ---------------- -** @aws-sdk/middleware-user-agent@3.894.0 - https://www.npmjs.com/package/@aws-sdk/middleware-user-agent/v/3.894.0 | Apache-2.0 +** @aws-sdk/middleware-user-agent@3.893.0 - https://www.npmjs.com/package/@aws-sdk/middleware-user-agent/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -5767,7 +5767,7 @@ Apache License ---------------- -** @aws-sdk/nested-clients@3.894.0 - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.894.0 | Apache-2.0 +** @aws-sdk/nested-clients@3.893.0 - https://www.npmjs.com/package/@aws-sdk/nested-clients/v/3.893.0 | Apache-2.0 ---------------- @@ -5976,7 +5976,7 @@ Apache License ---------------- -** @aws-sdk/signature-v4-multi-region@3.894.0 - https://www.npmjs.com/package/@aws-sdk/signature-v4-multi-region/v/3.894.0 | Apache-2.0 +** @aws-sdk/signature-v4-multi-region@3.893.0 - https://www.npmjs.com/package/@aws-sdk/signature-v4-multi-region/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -6182,7 +6182,7 @@ Apache License ---------------- -** @aws-sdk/token-providers@3.894.0 - https://www.npmjs.com/package/@aws-sdk/token-providers/v/3.894.0 | Apache-2.0 +** @aws-sdk/token-providers@3.893.0 - https://www.npmjs.com/package/@aws-sdk/token-providers/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -6797,7 +6797,7 @@ Apache License ---------------- -** @aws-sdk/util-user-agent-node@3.894.0 - https://www.npmjs.com/package/@aws-sdk/util-user-agent-node/v/3.894.0 | Apache-2.0 +** @aws-sdk/util-user-agent-node@3.893.0 - https://www.npmjs.com/package/@aws-sdk/util-user-agent-node/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -7003,7 +7003,7 @@ Apache License ---------------- -** @aws-sdk/xml-builder@3.894.0 - https://www.npmjs.com/package/@aws-sdk/xml-builder/v/3.894.0 | Apache-2.0 +** @aws-sdk/xml-builder@3.893.0 - https://www.npmjs.com/package/@aws-sdk/xml-builder/v/3.893.0 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -16963,7 +16963,7 @@ THE SOFTWARE. ---------------- -** b4a@1.7.2 - https://www.npmjs.com/package/b4a/v/1.7.2 | Apache-2.0 +** b4a@1.7.1 - https://www.npmjs.com/package/b4a/v/1.7.1 | Apache-2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -17626,212 +17626,6 @@ SOFTWARE. ----------------- - -** events-universal@1.0.1 - https://www.npmjs.com/package/events-universal/v/1.0.1 | Apache-2.0 - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ---------------- ** fast-fifo@1.3.2 - https://www.npmjs.com/package/fast-fifo/v/1.3.2 | MIT @@ -18580,7 +18374,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ---------------- -** streamx@2.23.0 - https://www.npmjs.com/package/streamx/v/2.23.0 | MIT +** streamx@2.22.1 - https://www.npmjs.com/package/streamx/v/2.22.1 | MIT The MIT License (MIT) Copyright (c) 2019 Mathias Buus @@ -18738,6 +18532,32 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +---------------- + +** strnum@2.1.1 - https://www.npmjs.com/package/strnum/v/2.1.1 | MIT +MIT License + +Copyright (c) 2021 Natural Intelligence + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + ---------------- ** tar-stream@3.1.7 - https://www.npmjs.com/package/tar-stream/v/3.1.7 | MIT