-
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): CodeBuild checks (#340)
Closes #174 Closes #175 ---- *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
8 changed files
with
397 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
40 changes: 40 additions & 0 deletions
40
src/HIPAA-Security/rules/codebuild/hipaaSecurityCodeBuildProjectEnvVarAwsCred.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,40 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CfnProject } from '@aws-cdk/aws-codebuild'; | ||
import { IConstruct, Stack } from '@aws-cdk/core'; | ||
|
||
/** | ||
* CodeBuild projects do not store AWS credentials as plaintext environment variables - (Control IDs: 164.308(a)(3)(i), 164.308(a)(4)(ii)(A), 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 CfnProject) { | ||
//Check for the presence of OAUTH | ||
const environment = Stack.of(node).resolve(node.environment); | ||
const environmentVars = Stack.of(node).resolve( | ||
environment.environmentVariables | ||
); | ||
if (environmentVars != undefined) { | ||
//For each envvar, check if its a sensitive credential being stored | ||
for (const envVar of environmentVars) { | ||
const resolvedEnvVar = Stack.of(node).resolve(envVar); | ||
if ( | ||
resolvedEnvVar.name == 'AWS_ACCESS_KEY_ID' || | ||
resolvedEnvVar.name == 'AWS_SECRET_ACCESS_KEY' | ||
) { | ||
//is this credential being stored as plaintext? | ||
if ( | ||
resolvedEnvVar.type == undefined || | ||
resolvedEnvVar.type == 'PLAINTEXT' | ||
) { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} |
Oops, something went wrong.