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

[BUG] FG_R00041 causing false positive #401

Open
dkoder20 opened this issue Feb 23, 2023 · 1 comment
Open

[BUG] FG_R00041 causing false positive #401

dkoder20 opened this issue Feb 23, 2023 · 1 comment

Comments

@dkoder20
Copy link
Contributor

Describe the bug
FG_R00041 is working is as expected if you are creating a new stack. But if you try updating an existing stack which has resource aws_security_group then it'll flag FG_R00041 as a false positive.

Some investigation on my end has revealed that for an existing stack where "address": "aws_security_group.alb", there are ingress definitions defined within the aws_security_group resource in the plan despite the definitions done by aws_security_group_rule resource.

  • This is not being handled well by regula and is generating a false positive

How you're running Regula
Please include versions of all relevant tools. Some examples:

  • Regula v3.1.0
  • TF v0.13.4
  • AWS v4.55.0

Operating System
Mac

Steps to reproduce
Copy the following terraform configuration to re-create the error:

main.tf

variable "ingress_cidrs" {
  type = list(string)
  default = ["0.0.0.0/0"]
}

variable "vpc_id" {
  type = string
  default = vpc-12345678abcdefgh
}

resource "aws_security_group" "alb" {
  vpc_id = var.vpc_id
}

resource "aws_security_group_rule" "http" {
  security_group_id = aws_security_group.alb.id
  type              = "ingress"
  from_port         = 80
  to_port           = 80
  protocol          = "tcp"
  cidr_blocks       = ["0.0.0.0/0"]
}

Then run:

terraform init
terraform plan -input=false -out=tfplan.txt
terraform show -json tfplan.txt > plan.json
regula run # you will notice there are no issues

# now apply these changes and create a stack
terraform apply -auto-approve

After the stack is created, again run

terraform plan -input=false -out=tfplan.txt
terraform show -json tfplan.txt > plan.json
regula run # you will notice FG_R00041 is raised against `plan.json`
@jbrule
Copy link

jbrule commented May 12, 2023

Is it a "known after apply" value? You should see an after unknown section in the plan file for values that cannot be determined until after apply.

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

No branches or pull requests

2 participants