Skip to content

Commit

Permalink
chore: self mutation
Browse files Browse the repository at this point in the history
Signed-off-by: github-actions <[email protected]>
  • Loading branch information
github-actions committed Oct 9, 2024
1 parent b3692bf commit 24c3d55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/private/handlers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ export class FileAssetHandler implements IAssetHandler {
throw new Error(
`Bucket named '${destination.bucketName}' exists, but we dont have access to it.`
);
case BucketOwnership.SOMEONE_ELSES_AND_HAVE_ACCESS:
if (!allowCrossAccount) {
throw new Error(
`❗❗ UNEXPECTED BUCKET OWNER DETECTED ❗❗
case BucketOwnership.SOMEONE_ELSES_AND_HAVE_ACCESS:
if (!allowCrossAccount) {
throw new Error(
`❗❗ UNEXPECTED BUCKET OWNER DETECTED ❗❗
We've detected that the S3 bucket cdk-hnb659fds-assets-${await account()}-${destination.region} was
originally created in account ${await account()} as part of the CloudFormation stack CDKToolkit,
Expand All @@ -104,9 +104,9 @@ export class FileAssetHandler implements IAssetHandler {
[1] https://repost.aws/knowledge-center/potential-account-compromise
[2] https://aws.amazon.com/support`
);
}
break;
);
}
break;
}

if (await objectExists(s3, destination.bucketName, destination.objectKey)) {
Expand Down
4 changes: 3 additions & 1 deletion test/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ test('fails when cross account is required but not allowed', async () => {
return { promise: () => Promise.resolve() };
});

await expect(pub.publish({ allowCrossAccount: false })).rejects.toThrow('❗❗ UNEXPECTED BUCKET OWNER DETECTED ❗❗');
await expect(pub.publish({ allowCrossAccount: false })).rejects.toThrow(
'❗❗ UNEXPECTED BUCKET OWNER DETECTED ❗❗'
);
});

test('succeeds when bucket doesnt belong to us but doesnt contain account id - cross account', async () => {
Expand Down

0 comments on commit 24c3d55

Please sign in to comment.