Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const getPublicAccessBlock = block => block === true
? { BlockPublicAcls: true, BlockPublicPolicy: true, IgnorePublicAcls: true, RestrictPublicBuckets: true }
: { BlockPublicAcls: false, BlockPublicPolicy: false, IgnorePublicAcls: false, RestrictPublicBuckets: false }

const sortObject = obj => typeof obj === 'object'
? Object.fromEntries(Object.entries(obj).sort())
: obj

class DeploymentBucketPlugin {
constructor(serverless, options) {
this.serverless = serverless
Expand Down Expand Up @@ -242,7 +246,7 @@ class DeploymentBucketPlugin {
try {
const config = getPublicAccessBlock(blockPublicAccess)
const response = await this.provider.request('S3', 'getPublicAccessBlock', { Bucket: name })
return response && JSON.stringify(response.PublicAccessBlockConfiguration) !== JSON.stringify(config)
return response && JSON.stringify(sortObject(response.PublicAccessBlockConfiguration)) !== JSON.stringify(sortObject(config))
} catch (e) {
return blockPublicAccess
}
Expand Down
2 changes: 1 addition & 1 deletion lib/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ describe('DeploymentBucketPlugin', () => {
.mockResolvedValueOnce({}) // S3.getBucketAccelerateConfiguration()
.mockResolvedValueOnce({
PublicAccessBlockConfiguration: {
BlockPublicAcls: true, BlockPublicPolicy: true, IgnorePublicAcls: true, RestrictPublicBuckets: true
BlockPublicAcls: true, IgnorePublicAcls: true, BlockPublicPolicy: true, RestrictPublicBuckets: true
}
}) // S3.getPublicAccessBlock()

Expand Down