-
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): API Gateway Rules (#323)
Closes #160 Closes #161 Closes #162 Closes #163 ---- *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
13 changed files
with
387 additions
and
21 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
36 changes: 36 additions & 0 deletions
36
src/HIPAA-Security/rules/apigw/hipaaSecurityAPIGWCacheEnabledAndEncrypted.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,36 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { CfnStage } from '@aws-cdk/aws-apigateway'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* All methods in API Gateway stages have caching enabled and encrypted - (Control IDs: 164.312(a)(2)(iv), 164.312(e)(2)(ii)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnStage) { | ||
if (node.methodSettings == undefined) { | ||
return false; | ||
} | ||
const methodSettings = Stack.of(node).resolve(node.methodSettings); | ||
let found = false; | ||
for (const setting of methodSettings) { | ||
const resolvedSetting = Stack.of(node).resolve(setting); | ||
if ( | ||
resolvedSetting?.httpMethod == '*' && | ||
resolvedSetting?.resourcePath == '/*' && | ||
resolvedSetting?.cacheDataEncrypted && | ||
resolvedSetting?.cachingEnabled | ||
) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/HIPAA-Security/rules/apigw/hipaaSecurityAPIGWExecutionLoggingEnabled.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,36 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { CfnStage, MethodLoggingLevel } from '@aws-cdk/aws-apigateway'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* API Gateway stages have logging enabled - (Control ID: 164.312(b)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnStage) { | ||
if (node.methodSettings == undefined) { | ||
return false; | ||
} | ||
const methodSettings = Stack.of(node).resolve(node.methodSettings); | ||
let found = false; | ||
for (const setting of methodSettings) { | ||
const resolvedSetting = Stack.of(node).resolve(setting); | ||
if ( | ||
resolvedSetting?.httpMethod == '*' && | ||
resolvedSetting?.resourcePath == '/*' && | ||
(resolvedSetting?.loggingLevel == MethodLoggingLevel.ERROR || | ||
resolvedSetting?.loggingLevel == MethodLoggingLevel.INFO) | ||
) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/HIPAA-Security/rules/apigw/hipaaSecurityAPIGWSSLEnabled.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,19 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { CfnStage } from '@aws-cdk/aws-apigateway'; | ||
import { IConstruct } from '@aws-cdk/core'; | ||
|
||
/** | ||
* API Gateway REST API stages are configured with SSL certificates - (Control IDs: 164.312(a)(2)(iv), 164.312(e)(1), 164.312(e)(2)(i), 164.312(e)(2)(ii)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnStage) { | ||
if (node.clientCertificateId == undefined) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/HIPAA-Security/rules/apigw/hipaaSecurityAPIGWXrayEnabled.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 { CfnStage } from '@aws-cdk/aws-apigateway'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* API Gateway REST API stages have X-Ray tracing enabled - (Control IDs: 164.312(b)) | ||
* @param node the CfnResource to check | ||
*/ | ||
export default function (node: IConstruct): boolean { | ||
if (node instanceof CfnStage) { | ||
const tracingEnabled = Stack.of(node).resolve(node.tracingEnabled); | ||
if (tracingEnabled !== true) { | ||
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
Oops, something went wrong.