-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(HIPAA Security): ElastiCache check (#347)
Closes #246 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
7 changed files
with
131 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/HIPAA-Security/rules/elasticache/hipaaSecurityElastiCacheRedisClusterAutomaticBackup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { CfnCacheCluster, CfnReplicationGroup } from '@aws-cdk/aws-elasticache'; | ||
import { CfnResource } from '@aws-cdk/core'; | ||
|
||
/** | ||
* ElastiCache Redis clusters retain automatic backups for at least 15 days - (Control IDs: 164.308(a)(7)(i), 164.308(a)(7)(ii)(A), 164.308(a)(7)(ii)(B)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: CfnResource): boolean { | ||
if (node instanceof CfnCacheCluster) { | ||
const engine = node.engine.toLowerCase(); | ||
const retention = node.snapshotRetentionLimit; | ||
if (engine == 'redis' && (retention == undefined || retention < 15)) { | ||
return false; | ||
} | ||
} else if (node instanceof CfnReplicationGroup) { | ||
const retention = node.snapshotRetentionLimit; | ||
if (retention == undefined || retention < 15) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { SynthUtils } from '@aws-cdk/assert'; | ||
import { CfnCacheCluster, CfnReplicationGroup } from '@aws-cdk/aws-elasticache'; | ||
import { Aspects, Stack } from '@aws-cdk/core'; | ||
import { HIPAASecurityChecks } from '../../src'; | ||
|
||
describe('Amazon ElastiCache', () => { | ||
test('HIPAA.Security-ElasticacheRedisClusterAutomaticBackup: ElastiCache Redis clusters retain automatic backups for at least 15 days', () => { | ||
const nonCompliant = new Stack(); | ||
Aspects.of(nonCompliant).add(new HIPAASecurityChecks()); | ||
new CfnCacheCluster(nonCompliant, 'rAec', { | ||
cacheNodeType: 'cache.t3.micro', | ||
engine: 'redis', | ||
numCacheNodes: 42, | ||
snapshotRetentionLimit: 14, | ||
port: 11211, | ||
}); | ||
const messages = SynthUtils.synthesize(nonCompliant).messages; | ||
expect(messages).toContainEqual( | ||
expect.objectContaining({ | ||
entry: expect.objectContaining({ | ||
data: expect.stringContaining( | ||
'HIPAA.Security-ElasticacheRedisClusterAutomaticBackup:' | ||
), | ||
}), | ||
}) | ||
); | ||
|
||
const nonCompliant2 = new Stack(); | ||
Aspects.of(nonCompliant2).add(new HIPAASecurityChecks()); | ||
new CfnReplicationGroup(nonCompliant2, 'rAecGroup', { | ||
replicationGroupDescription: 'lorem ipsum dolor sit amet', | ||
cacheNodeType: 'cache.t3.micro', | ||
engine: 'redis', | ||
}); | ||
const messages2 = SynthUtils.synthesize(nonCompliant2).messages; | ||
expect(messages2).toContainEqual( | ||
expect.objectContaining({ | ||
entry: expect.objectContaining({ | ||
data: expect.stringContaining( | ||
'HIPAA.Security-ElasticacheRedisClusterAutomaticBackup:' | ||
), | ||
}), | ||
}) | ||
); | ||
|
||
const compliant = new Stack(); | ||
Aspects.of(compliant).add(new HIPAASecurityChecks()); | ||
new CfnCacheCluster(compliant, 'rAec', { | ||
cacheNodeType: 'cache.t3.micro', | ||
engine: 'redis', | ||
numCacheNodes: 42, | ||
snapshotRetentionLimit: 16, | ||
port: 42, | ||
}); | ||
new CfnReplicationGroup(compliant, 'rAecGroup', { | ||
replicationGroupDescription: 'lorem ipsum dolor sit amet', | ||
cacheNodeType: 'cache.t3.micro', | ||
engine: 'redis', | ||
snapshotRetentionLimit: 16, | ||
}); | ||
const messages3 = SynthUtils.synthesize(compliant).messages; | ||
expect(messages3).not.toContainEqual( | ||
expect.objectContaining({ | ||
entry: expect.objectContaining({ | ||
data: expect.stringContaining( | ||
'HIPAA.Security-ElasticacheRedisClusterAutomaticBackup:' | ||
), | ||
}), | ||
}) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters