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(cli): add --tf-exclude-downloaded-modules flag #4810

Merged
merged 4 commits into from
Jul 16, 2023

Conversation

nikpivkin
Copy link
Contributor

@nikpivkin nikpivkin commented Jul 12, 2023

Description

Added the --exclude-downloaded-modules flag, which removes the results for downloaded terraform modules.

Before

2023-07-12T11:17:09.040+0600    INFO    Misconfiguration scanning is enabled
2023-07-12T11:17:09.400+0600    INFO    Detected config files: 2

terraform-aws-modules/security-group/aws/main.tf (terraform)

Tests: 6 (SUCCESSES: 5, FAILURES: 1, EXCEPTIONS: 0)
Failures: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 1)

CRITICAL: Security group rule allows ingress from public internet.
═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.

See https://avd.aquasec.com/misconfig/avd-aws-0107
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 terraform-aws-modules/security-group/aws/main.tf:197-204
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 191   resource "aws_security_group_rule" "ingress_with_cidr_blocks" {
 ...   
 197 ┌   cidr_blocks = split(
 198 │     ",",
 199 │     lookup(
 200 │       var.ingress_with_cidr_blocks[count.index],
 201 │       "cidr_blocks",
 202 │       join(",", var.ingress_cidr_blocks),
 203 └     ),
 ...   
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

After

2023-07-12T11:16:11.484+0600    INFO    Misconfiguration scanning is enabled
2023-07-12T11:16:11.862+0600    INFO    Detected config files: 2

Related issues

Related PRs

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@nikpivkin nikpivkin marked this pull request as ready for review July 12, 2023 06:31
@nikpivkin nikpivkin requested a review from simar7 July 12, 2023 06:31
Copy link
Member

@simar7 simar7 left a comment

Choose a reason for hiding this comment

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

it lgtm, but we should test this option in defsec. It should be added as a test here alongside the other options we have: https://github.com/aquasecurity/defsec/blob/master/pkg/scanners/terraform/scanner_test.go

@nikpivkin
Copy link
Contributor Author

@simar7 I added a test.

@nikpivkin nikpivkin requested a review from simar7 July 13, 2023 04:57
Copy link
Member

@simar7 simar7 left a comment

Choose a reason for hiding this comment

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

Nice lgtm!

@knqyf263 knqyf263 added this pull request to the merge queue Jul 16, 2023
Merged via the queue into aquasecurity:main with commit 3c7d988 Jul 16, 2023
17 checks passed
@nikpivkin nikpivkin deleted the nik-excl-sources branch July 20, 2023 16:06
AnaisUrlichs pushed a commit to AnaisUrlichs/trivy that referenced this pull request Aug 10, 2023
* feat(cli): add --tf-exclude-downloaded-modules flag

* fix typo

* generate docs
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.

feat: Trivy lacks tfsec option --exclude-downloaded-modules
3 participants