-
Notifications
You must be signed in to change notification settings - Fork 348
fix(query): fn for EFS volume with disabled transit encryption--cloudformation/aws #7586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nsit_Encryption--cloudformation/aws
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
cx-artur-ribeiro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…on--cloudformation/aws' of https://github.com/cx-andre-pereira/kics into AST-40736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…on--cloudformation/aws' of https://github.com/cx-andre-pereira/kics into AST-40736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
…nsit_Encryption--cloudformation/aws
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 19562607 | Triggered | Generic Password | 74da8c2 | assets/queries/common/passwords_and_secrets/test/positive53.json | View secret |
| 4266022 | Triggered | Generic Password | 6e9f38e | assets/queries/cloudFormation/aws/amplify_branch_basic_auth_config_password_exposed/test/negative7.yaml | View secret |
| 9419039 | Triggered | Username Password | 6e9f38e | assets/queries/cloudFormation/aws/amplify_branch_basic_auth_config_password_exposed/test/positive6.json | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
cx-artur-ribeiro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I don't know why we had a sample.yaml as a test file but nice revert from your side.
Closes #7093
Reason for Proposed Changes
The purpose of this query is to check all
ECS:Task-Definitionresources and guarantee that, within theirVolumes.EFSVolumeConfigurationfield,TransitEncryptionis defined and set to "ENABLED". This will ensure Amazon EFS volume(s) have encryption for data at transit.The query and all its test, currently, have syntax errors for the
VolumesandEFSVolumeConfigurationfields; put simple the capitalization of character is inconsistent with official documentation which clearly declares the fields with this syntax. There are no analog naming schemes mentioned and these field´s naming is case sensitive.While investigation the reason for this seemingly dysfunctional since inception query, it was made clear that it is analog to a terraform query "ECS Task Definition Volume Not Encrypted". In terraform the fields are named in lowercase and the adjustment for CloudFormation was never properly done. There was an attempt but it only updated the
transitEncryptiontoTransitEncryption.Furtermore there is currently another CloudFormation query that is doing a very similar scan even though it is unrelated to its name/purpose. The "ECS Cluster Not Encrypted At Rest" query , which got updated recently as of writing (PR), is doing a near identical check except for the fact that it will only check the relevant
ECS:Task-Definitionresources, if they are referenced by anECS:Serviceresource in itsTaskDefinitionfield. The confusion might have sparked from the fact that both queries try to ensure encryption is enabled but the types of encryption are different and are not interchangeable. (At Rest Encryption / In Transit Encryption)Both CloudFormation queries are , currently, missing the case for the lack of the
EFSVolumeConfigurationfield; this case is not missing in the original terraform query.Given all this we have :
Proposed Changes
I started by simply adjusting all mentions of the 2 relevant fields (
VolumesandEFSVolumeConfiguration) to the correct nomenclature.Additionally i found the test folder to be lacking
yamltest files, currently it has exclusivelyJSONfiles. I created tests similar to the ones already incorporated written inyamlformat whilst also adjusting the field naming.Some E2E tests have been updated since the
AWS::ECS::TaskDefinitionresource from e2e/fixtures/samples/positive.yaml is now flagging as it always should have, due to lack of theEFSVolumeConfigurationfield.Finally i adjusted the "searchKey" values to pinpoint results more accurately in the same way the "searchLine" was already doing and i implemented the missing case found on the terraform original query. (case of missing "EFSVolumeConfiguration" field)
I adjusted the terraform's query original name "ECS Task Definition Volume Not Encrypted" to "EFS Volume With Disabled Transit Encryption". This way it will be easy to recognize the 2 queries from each platform as equivalent in the future.
For the metadata of the queries there were changes made to better adjust various details to current implementation/context (cwe/documentation/severity).
An initial implementation of the "ECS Cluster Not Encrypted At Rest" was commited , but it was decided the query required further research before moving on with the implementation(fallback commit). That said this initial implementation should be included in a "dangling" PR for future reference. (Draft PR)
Note: all test files from the "ECS Cluster Not Encrypted At Rest" query have been checked to be flagged identically by the adjusted EFS Volume query. The 2 instances that did not get flagged are the case of the
TaskDefinitionfield referencing a resource that does not exist; those , however, did get correctly flagged as "Empty Roles For ECS Cluster Task Definitions" , this seems like the correct flag for this scenario and since the query naming/description of "ECS Cluster Not Encrypted At Rest" was unrelated to the issue to begin with, it seems to be a True Negative for the EFS Volume query.I submit this contribution under the Apache-2.0 license.