-
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): EMR check (#358)
Closes #259 ---- *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
6 changed files
with
131 additions
and
44 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
20 changes: 20 additions & 0 deletions
20
src/HIPAA-Security/rules/emr/hipaaSecurityEMRKerberosEnabled.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,20 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { CfnCluster } from '@aws-cdk/aws-emr'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* EMR clusters have Kerberos enabled - (Control IDs: 164.308(a)(3)(i), 164.308(a)(3)(ii)(A), 164.308(a)(3)(ii)(B), 164.308(a)(4)(i), 164.308(a)(4)(ii)(A), 164.308(a)(4)(ii)(B), 164.308(a)(4)(ii)(C), 164.312(a)(1)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnCluster) { | ||
const kerberosAttributes = Stack.of(node).resolve(node.kerberosAttributes); | ||
if (kerberosAttributes == undefined) { | ||
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,50 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { SynthUtils } from '@aws-cdk/assert'; | ||
import { CfnCluster } from '@aws-cdk/aws-emr'; | ||
import { Aspects, Stack } from '@aws-cdk/core'; | ||
import { HIPAASecurityChecks } from '../../src'; | ||
|
||
describe('Amazon EMR', () => { | ||
test('HIPAA.Security-EMRKerberosEnabled: - EMR clusters have Kerberos enabled - (Control IDs: 164.308(a)(3)(i), 164.308(a)(3)(ii)(A), 164.308(a)(3)(ii)(B), 164.308(a)(4)(i), 164.308(a)(4)(ii)(A), 164.308(a)(4)(ii)(B), 164.308(a)(4)(ii)(C), 164.312(a)(1)', () => { | ||
const nonCompliant = new Stack(); | ||
Aspects.of(nonCompliant).add(new HIPAASecurityChecks()); | ||
new CfnCluster(nonCompliant, 'rEmrCluster', { | ||
instances: {}, | ||
jobFlowRole: ' EMR_EC2_DefaultRole', | ||
name: 'foo', | ||
serviceRole: 'bar', | ||
}); | ||
const messages = SynthUtils.synthesize(nonCompliant).messages; | ||
expect(messages).toContainEqual( | ||
expect.objectContaining({ | ||
entry: expect.objectContaining({ | ||
data: expect.stringContaining('HIPAA.Security-EMRKerberosEnabled:'), | ||
}), | ||
}) | ||
); | ||
|
||
const compliant = new Stack(); | ||
Aspects.of(compliant).add(new HIPAASecurityChecks()); | ||
new CfnCluster(compliant, 'rEmrCluster', { | ||
instances: {}, | ||
jobFlowRole: ' EMR_EC2_DefaultRole', | ||
name: 'foo', | ||
serviceRole: 'bar', | ||
kerberosAttributes: { | ||
kdcAdminPassword: 'baz', | ||
realm: 'qux', | ||
}, | ||
}); | ||
const messages2 = SynthUtils.synthesize(compliant).messages; | ||
expect(messages2).not.toContainEqual( | ||
expect.objectContaining({ | ||
entry: expect.objectContaining({ | ||
data: expect.stringContaining('HIPAA.Security-EMRKerberosEnabled:'), | ||
}), | ||
}) | ||
); | ||
}); | ||
}); |