-
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): Add 3 EC2 checks (#317)
closes #189 closes #191 closes #239 ---- *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
355 additions
and
17 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
27 changes: 27 additions & 0 deletions
27
src/HIPAA-Security/rules/ec2/hipaaSecurityEC2InstanceDetailedMonitoringEnabled.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,27 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CfnLaunchConfiguration } from '@aws-cdk/aws-autoscaling'; | ||
import { CfnInstance } from '@aws-cdk/aws-ec2'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* EC2 instances have detailed monitoring enabled - (Control IDs: 164.312(b)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnInstance) { | ||
const monitoring = Stack.of(node).resolve(node.monitoring); | ||
if (monitoring == undefined || monitoring == false) { | ||
return false; | ||
} | ||
} else if (node instanceof CfnLaunchConfiguration) { | ||
const monitoring = Stack.of(node).resolve(node.instanceMonitoring); | ||
if (monitoring != undefined && monitoring == false) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/HIPAA-Security/rules/ec2/hipaaSecurityEC2InstanceNoPublicIp.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,31 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CfnInstance } from '@aws-cdk/aws-ec2'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* EC2 instances do not have public IPs - (Control IDs: 164.308(a)(3)(i), 164.308(a)(4)(ii)(A), 164.308(a)(4)(ii)(C), 164.312(a)(1), 164.312(e)(1)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnInstance) { | ||
const networkInterfaces = Stack.of(node).resolve(node.networkInterfaces); | ||
if (networkInterfaces != undefined) { | ||
//Iterate through network interfaces, checking if public IPs are enabled | ||
for (const networkInterface of networkInterfaces) { | ||
const resolvedInterface = Stack.of(node).resolve(networkInterface); | ||
if (resolvedInterface.associatePublicIpAddress != undefined) { | ||
if (resolvedInterface.associatePublicIpAddress == true) { | ||
return false; | ||
} | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/HIPAA-Security/rules/ec2/hipaaSecurityEC2InstancesInVPC.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,22 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CfnInstance } from '@aws-cdk/aws-ec2'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* EC2 instances are created within VPCs - (Control IDs: 164.308(a)(3)(i), 164.308(a)(4)(ii)(A), 164.308(a)(4)(ii)(C), 164.312(a)(1), 164.312(e)(1)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnInstance) { | ||
//If we are in a VPC, then we'll have a subnet | ||
const subnetId = Stack.of(node).resolve(node.subnetId); | ||
if (subnetId == 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
Oops, something went wrong.