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(misconf): show the resource name in the report #4806

Merged
merged 5 commits into from
Aug 23, 2023

Conversation

nikpivkin
Copy link
Contributor

@nikpivkin nikpivkin commented Jul 11, 2023

Description

Before

2023-06-06T16:24:07.908-0400    INFO    Misconfiguration scanning is enabled
2023-06-06T16:24:08.307-0400    INFO    Detected config files: 1

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

Tests: 4 (SUCCESSES: 3, 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-11T14:31:05.741+0600    INFO    Misconfiguration scanning is enabled
2023-07-11T14:31:06.123+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
   via terraform-aws-modules/security-group/aws/main.tf:191-227 (aws_security_group_rule.ingress_with_cidr_blocks[0])
    via sg.tf:1-13 (module.aws-security-groups["db1"])
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 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 └     ),
 ...   
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

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).

@simar7
Copy link
Member

simar7 commented Jul 25, 2023

any update on this @nikpivkin?

@nikpivkin
Copy link
Contributor Author

@simar7 The changes made to defsec have not yet been merged into trivy

@nikpivkin nikpivkin marked this pull request as ready for review August 1, 2023 13:40
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.

We can add a small test for this change as described. In addition lets also document this behavior as it a user facing change.

Comment on lines +166 to +180
for i, occ := range misconf.CauseMetadata.Occurrences {
lineInfo := fmt.Sprintf("%d-%d", occ.Location.StartLine, occ.Location.EndLine)
if occ.Location.StartLine >= occ.Location.EndLine {
lineInfo = fmt.Sprintf("%d", occ.Location.StartLine)
}

r.printf(
" %s<dim>via </dim><italic>%s<dim>:%s (%s)\n",
strings.Repeat(" ", i+2),
occ.Filename,
lineInfo,
occ.Resource,
)
}

Copy link
Member

Choose a reason for hiding this comment

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

@simar7
Copy link
Member

simar7 commented Aug 4, 2023

hi @knqyf263 this is a new feature and should go into v0.45.0, is there way to have a merge queue by milestone? Otherwise we will have to wait to merge until the end of the month is here.

@knqyf263
Copy link
Collaborator

knqyf263 commented Aug 4, 2023

hi @knqyf263 this is a new feature and should go into v0.45.0, is there way to have a merge queue by milestone?

As far as I know, there is no way to do that.

Otherwise we will have to wait to merge until the end of the month is here.

But v0.44.1 will be out next week, and we can merge this PR just after that.

@nikpivkin nikpivkin requested a review from simar7 August 10, 2023 08:02
@knqyf263
Copy link
Collaborator

v0.44.1 is out. I'll see if everything is fine in v0.44.1 (if there is a problem, we need to cut v0.44.2) and merge this PR.

@knqyf263 knqyf263 added this pull request to the merge queue Aug 23, 2023
Merged via the queue into aquasecurity:main with commit 07ddf47 Aug 23, 2023
11 checks passed
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 config terraform should show the resource name
3 participants