Skip to content
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

feat(terraform): Add a terraform block check #6904

Merged
merged 8 commits into from
Dec 18, 2024
Merged

Conversation

tsmithv11
Copy link
Collaborator

@tsmithv11 tsmithv11 commented Dec 13, 2024

User description

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

Flag the use of S3 as a backend without a lock file, potentially leading to a Supply Chain attack where state files can be modified by a bad actor

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes

Generated description

Below is a concise technical summary of the changes proposed in this PR:

This pull request introduces new checks and infrastructure for Terraform block checks, ensuring state files are locked when using S3 as a backend and enhancing the base classes and runners for Terraform checks.

TopicDetails
Terraform State Lock Implements a new check to ensure Terraform state files are locked when using S3 as a backend
Modified files (6)
  • tests/terraform/checks/terraform/terraform/resources/lock/pass_dynamodb_table.tf
  • tests/terraform/checks/terraform/terraform/resources/lock/unknown.tf
  • checkov/terraform/checks/terraform/terraform/StateLock.py
  • tests/terraform/checks/terraform/terraform/test_StateLock.py
  • tests/terraform/checks/terraform/terraform/resources/lock/pass.tf
  • tests/terraform/checks/terraform/terraform/resources/lock/fail1.tf
Latest Contributors(0)
UserCommitDate
Terraform Check Infra Adds infrastructure to support Terraform block checks, including new base classes and modifications to existing runners
Modified files (9)
  • checkov/terraform/checks/terraform/__init__.py
  • checkov/terraform/checks/terraform/terraform/__init__.py
  • checkov/terraform/context_parsers/parsers/terraform_context_parser.py
  • checkov/terraform/checks/terraform/registry.py
  • tests/terraform/checks/terraform/terraform/__init__.py
  • checkov/terraform/checks/terraform/base_registry.py
  • checkov/terraform/checks/terraform/base_check.py
  • checkov/terraform/runner.py
  • checkov/terraform/base_runner.py
Latest Contributors(2)
UserCommitDate
SteveVakninfix-terraform-fix-fail...July 17, 2024
lirshindalmanplatform-general-remov...January 28, 2024
This pull request is reviewed by Baz. Join @tsmithv11 and the rest of your team on (Baz).

Copy link
Contributor

@talazuri talazuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tsmithv11 tsmithv11 merged commit 0440c5a into main Dec 18, 2024
34 of 35 checks passed
@tsmithv11 tsmithv11 deleted the new-checks-dec24 branch December 18, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants