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: Support null terraform values for misconf scanning #4780

Closed
2 tasks done
simar7 opened this issue Jul 5, 2023 Discussed in #4736 · 2 comments
Closed
2 tasks done

feat: Support null terraform values for misconf scanning #4780

simar7 opened this issue Jul 5, 2023 Discussed in #4736 · 2 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. scan/misconfiguration Issues relating to misconfiguration scanning
Milestone

Comments

@simar7
Copy link
Member

simar7 commented Jul 5, 2023

Discussed in #4736

Originally posted by gberenice June 29, 2023

Description

Hey!
We use terraform module cloudposseterraform-aws-s3-bucket v3.1.2 in our configuration, but Trivy scan (that is run as a Trunk check) fails with the error we don't expect to see:

 0:0  high  S3 Buckets should be encrypted to protect the data that is stored within them if access   trivy/AVD-AWS-0088
            is compromised.                                                                                             
...                                                                                      
 0:0  high   ↵ Versioning in Amazon S3 is a means of keeping multiple variants of an object in the    trivy/AVD-AWS-0090
            same bucket.  ↵ You can use the S3 Versioning feature to preserve, retrieve, an...                          
            .trunk/out/erP.txt   

Both encryption and versioning are enabled and configured.

S3 bucket encryption is managed via the resource aws_s3_bucket_server_side_encryption_configuration.
This is our state:

resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
    bucket = "test-logs"
    id     = "test-logs"

    rule {
        bucket_key_enabled = false

        apply_server_side_encryption_by_default {
            kms_master_key_id = "arn:aws:kms:us-east-1:111111111111:key/11111111-1111-1111-1111-111111111111"
            sse_algorithm     = "aws:kms"
        }
    }
}

Similar for versioning, in the state our resource aws_s3_bucket_versioning looks like:

resource "aws_s3_bucket_versioning" "default" {
    bucket = "test-logs"
    id     = "test-logs"

    versioning_configuration {
        status = "Enabled"
    }
}

Desired Behavior

Scan trivy config main.tf is successfully passed.

Actual Behavior

Scan fails.

Reproduction Steps

1. Add a child module with the following arguments:

module "logs_bucket" {
  source  = "cloudposse/s3-bucket/aws"
  version = "3.1.2"

  acl                = "private"
  sse_algorithm      = "aws:kms"
  kms_master_key_arn = module.kms_key.key_arn

  # Feature enablement
  user_enabled       = false
  versioning_enabled = true

2. Enable Trivy via Trunk in `trunk.yaml`:
```yaml
version: 0.1
cli:
  version: 1.11.1
plugins:
  sources:
    - id: trunk
      ref: v0.0.19
      uri: https://github.com/trunk-io/plugins
lint:
  enabled:
    - [email protected]
  1. Run the check.


### Target

None

### Scanner

None

### Output Format

JSON


### Operating System

macOS Ventura

### Version

```bash
Version: 0.42.1

Checklist

@simar7 simar7 added kind/feature Categorizes issue or PR as related to a new feature. scan/misconfiguration Issues relating to misconfiguration scanning labels Jul 5, 2023
@simar7
Copy link
Member Author

simar7 commented Jul 5, 2023

PR here aquasecurity/defsec#1370

@simar7 simar7 self-assigned this Jul 5, 2023
@simar7
Copy link
Member Author

simar7 commented Jul 6, 2023

Fixed via aquasecurity/defsec#1370

@simar7 simar7 closed this as completed Jul 6, 2023
@simar7 simar7 added this to the v0.44.0 milestone Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. scan/misconfiguration Issues relating to misconfiguration scanning
Projects
None yet
Development

No branches or pull requests

1 participant