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

Update_151124_4 #8687

Merged
merged 1 commit into from
Nov 15, 2024
Merged

Update_151124_4 #8687

merged 1 commit into from
Nov 15, 2024

Conversation

nbuckingham72
Copy link
Collaborator

Update to SNS topic IAM policy and amendments to SNS topic subscription resource names

@nbuckingham72 nbuckingham72 requested review from a team as code owners November 15, 2024 14:41
@github-actions github-actions bot added the environments-repository Used to exclude PRs from this repo in our Slack PR update label Nov 15, 2024
Copy link
Contributor

Trivy Scan Success

Show Output ```hcl

Trivy will check the following folders:
terraform/environments/ppud


Running Trivy in terraform/environments/ppud
2024-11-15T14:44:01Z INFO [vulndb] Need to update DB
2024-11-15T14:44:01Z INFO [vulndb] Downloading vulnerability DB...
2024-11-15T14:44:01Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-15T14:44:03Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-15T14:44:03Z INFO [vuln] Vulnerability scanning is enabled
2024-11-15T14:44:03Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-15T14:44:03Z INFO [misconfig] Need to update the built-in checks
2024-11-15T14:44:03Z INFO [misconfig] Downloading the built-in checks...
2024-11-15T14:44:03Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 19.967µs, allowed: 44000/minute\n\n"
2024-11-15T14:44:03Z INFO [secret] Secret scanning is enabled
2024-11-15T14:44:03Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-15T14:44:03Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-15T14:44:04Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-15T14:44:05Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.Memory_percentage_Committed_Bytes_In_Use" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.Windows_IIS_check" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.cpu" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.cpu_usage_iowait" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.instance_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.linux_cpu" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.linux_cpu_usage_iowait" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.linux_ec2_high_memory_usage" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.linux_instance_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.linux_system_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.low_disk_space_C_volume" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.low_disk_space_D_volume" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.low_disk_space_root_volume" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.malware_event_behavior_detected" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.malware_event_engine_out_of_date" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.malware_event_engine_update_failed" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.malware_event_scan_failed" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.malware_event_signature_update_failed" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.malware_event_state_detected" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="aws_cloudwatch_metric_alarm.system_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="data.aws_instance.linux_instance_details" value="cty.NilVal"
2024-11-15T14:44:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="data.aws_instance.windows_instance_details" value="cty.NilVal"
2024-11-15T14:44:06Z INFO [terraform executor] Ignore finding rule="aws-s3-enable-bucket-encryption" range="s3.tf:119-132"
2024-11-15T14:44:06Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="s3.tf:119-132"
2024-11-15T14:44:06Z INFO [terraform executor] Ignore finding rule="aws-iam-no-user-attached-policies" range="iam.tf:924-931"
2024-11-15T14:44:06Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="alb_external.tf:88-108"
2024-11-15T14:44:06Z INFO Number of language-specific files num=0
2024-11-15T14:44:06Z INFO Detected config files num=6
trivy_exitcode=0

</details> #### `Checkov Scan` Failed
<details><summary>Show Output</summary>

```hcl

*****************************

Checkov will check the following folders:
terraform/environments/ppud

*****************************

Running Checkov in terraform/environments/ppud
Excluding the following checks: CKV_GIT_1,CKV_AWS_126,CKV2_AWS_38,CKV2_AWS_39
2024-11-15 14:44:08,627 [MainThread  ] [WARNI]  [ArmLocalGraph] created 0 vertices
2024-11-15 14:44:08,627 [MainThread  ] [WARNI]  [ArmLocalGraph] created 0 edges
terraform scan results:

Passed checks: 1027, Failed checks: 4, Skipped checks: 155

Check: CKV_AWS_91: "Ensure the ELBv2 (Application/Network) has access logging enabled"
	FAILED for resource: aws_lb.WAM-ALB
	File: /alb_external.tf:88-108
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-logging-22

		88  | resource "aws_lb" "WAM-ALB" {
		89  |   # checkov:skip=CKV2_AWS_28: "ALB is already protected by WAF"
		90  |   # checkov:skip=CKV_AWS_152: "ALB target groups only have 2 targets so cross zone load balancing is not required"
		91  |   name               = local.application_data.accounts[local.environment].WAM_ALB
		92  |   internal           = false
		93  |   load_balancer_type = "application"
		94  |   security_groups    = [aws_security_group.WAM-ALB.id]
		95  |   subnets            = [data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id]
		96  |   #  access_logs {
		97  |   #    bucket  = aws_s3_bucket.moj-log-files-dev[0].id
		98  |   #    prefix  = "alb-logs"
		99  |   #    enabled = true
		100 |   #  }
		101 | 
		102 |   enable_deletion_protection = true
		103 |   drop_invalid_header_fields = true
		104 | 
		105 |   tags = {
		106 |     Name = "${var.networking[0].business-unit}-${local.environment}"
		107 |   }
		108 | }

Check: CKV_AWS_378: "Ensure AWS Load Balancer doesn't use HTTP protocol"
	FAILED for resource: aws_lb_target_group.WAM-Target-Group
	File: /alb_external.tf:152-172

		152 | resource "aws_lb_target_group" "WAM-Target-Group" {
		153 |   name     = "WAM"
		154 |   port     = 80
		155 |   protocol = "HTTP"
		156 |   vpc_id   = data.aws_vpc.shared.id
		157 | 
		158 |   health_check {
		159 |     enabled             = true
		160 |     path                = "/"
		161 |     interval            = 30
		162 |     protocol            = "HTTP"
		163 |     port                = 80
		164 |     timeout             = 5
		165 |     healthy_threshold   = 5
		166 |     unhealthy_threshold = 2
		167 |     matcher             = "302"
		168 |   }
		169 |   tags = {
		170 |     Name = "${var.networking[0].business-unit}-${local.environment}"
		171 |   }
		172 | }

Check: CKV_AWS_91: "Ensure the ELBv2 (Application/Network) has access logging enabled"
	FAILED for resource: aws_lb.PPUD-internal-ALB
	File: /alb_internal.tf:5-26
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-logging-22

		5  | resource "aws_lb" "PPUD-internal-ALB" {
		6  |   # checkov:skip=CKV_AWS_152: "ALB target groups only have 2 targets so cross zone load balancing is not required"
		7  |   count              = local.is-development == false ? 1 : 0
		8  |   name               = local.application_data.accounts[local.environment].PPUD_Internal_ALB
		9  |   internal           = true
		10 |   idle_timeout       = 240
		11 |   load_balancer_type = "application"
		12 |   security_groups    = [aws_security_group.PPUD-ALB.id]
		13 |   subnets            = [data.aws_subnet.private_subnets_b.id, data.aws_subnet.private_subnets_c.id]
		14 |   #  access_logs {
		15 |   #    bucket  = aws_s3_bucket.moj-log-files-uat[0].id
		16 |   #    prefix  = "alb-logs"
		17 |   #    enabled = true
		18 |   #  }
		19 | 
		20 |   enable_deletion_protection = true
		21 |   drop_invalid_header_fields = true
		22 | 
		23 |   tags = {
		24 |     Name = "${var.networking[0].business-unit}-${local.environment}"
		25 |   }
		26 | }

Check: CKV_AWS_91: "Ensure the ELBv2 (Application/Network) has access logging enabled"
	FAILED for resource: aws_lb.ppud_internal_nlb
	File: /endpointservice.tf:17-36
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-logging-policies/bc-aws-logging-22

		17 | resource "aws_lb" "ppud_internal_nlb" {
		18 |   # checkov:skip=CKV2_AWS_28: "ALB is already protected by WAF"
		19 |   # checkov:skip=CKV_AWS_152: "ALB target groups only have 2 targets so cross zone load balancing is not required"
		20 |   count                      = local.is-production == true ? 1 : 0
		21 |   name                       = "ppud-internal-nlb"
		22 |   internal                   = true
		23 |   load_balancer_type         = "network"
		24 |   subnets                    = [data.aws_subnet.private_subnets_b.id, data.aws_subnet.private_subnets_c.id]
		25 |   security_groups            = [aws_security_group.PPUD-ALB.id]
		26 |   enable_deletion_protection = true
		27 |   #access_logs {
		28 |   # bucket  = aws_s3_bucket.moj-log-files-prod[0].id
		29 |   # prefix  = "alb-logs"
		30 |   # enabled = true
		31 |   #}
		32 | 
		33 |   tags = {
		34 |     Name = "${var.networking[0].business-unit}-${local.environment}"
		35 |   }
		36 | }


checkov_exitcode=1

CTFLint Scan Failed

Show Output
*****************************

Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version: 0.9.1)
tflint will check the following folders:
terraform/environments/ppud

*****************************

Running tflint in terraform/environments/ppud
Excluding the following checks: terraform_unused_declarations
2 issue(s) found:

Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)

  on terraform/environments/ppud/certificate_mgmt.tf line 201:
 201: data "archive_file" "zip_the_certificate_expiry_prod" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md

Warning: Missing version constraint for provider "random" in `required_providers` (terraform_required_providers)

  on terraform/environments/ppud/secrets.tf line 7:
   7: resource "random_password" "password" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md

tflint_exitcode=2

Trivy Scan Success

Show Output
*****************************

Trivy will check the following folders:
terraform/environments/ppud

*****************************

Running Trivy in terraform/environments/ppud
2024-11-15T14:44:01Z	INFO	[vulndb] Need to update DB
2024-11-15T14:44:01Z	INFO	[vulndb] Downloading vulnerability DB...
2024-11-15T14:44:01Z	INFO	[vulndb] Downloading artifact...	repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-15T14:44:03Z	INFO	[vulndb] Artifact successfully downloaded	repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-15T14:44:03Z	INFO	[vuln] Vulnerability scanning is enabled
2024-11-15T14:44:03Z	INFO	[misconfig] Misconfiguration scanning is enabled
2024-11-15T14:44:03Z	INFO	[misconfig] Need to update the built-in checks
2024-11-15T14:44:03Z	INFO	[misconfig] Downloading the built-in checks...
2024-11-15T14:44:03Z	ERROR	[misconfig] Falling back to embedded checks	err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 19.967µs, allowed: 44000/minute\n\n"
2024-11-15T14:44:03Z	INFO	[secret] Secret scanning is enabled
2024-11-15T14:44:03Z	INFO	[secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-15T14:44:03Z	INFO	[secret] Please see also https://aquasecurity.github.io/trivy/v0.57/docs/scanner/secret#recommendation for faster secret detection
2024-11-15T14:44:04Z	INFO	[terraform scanner] Scanning root module	file_path="."
2024-11-15T14:44:05Z	WARN	[terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.	module="root" variables="networking"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.Memory_percentage_Committed_Bytes_In_Use" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.Windows_IIS_check" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.cpu" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.cpu_usage_iowait" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.instance_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.linux_cpu" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.linux_cpu_usage_iowait" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.linux_ec2_high_memory_usage" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.linux_instance_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.linux_system_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.low_disk_space_C_volume" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.low_disk_space_D_volume" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.low_disk_space_root_volume" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.malware_event_behavior_detected" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.malware_event_engine_out_of_date" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.malware_event_engine_update_failed" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.malware_event_scan_failed" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.malware_event_signature_update_failed" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.malware_event_state_detected" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="aws_cloudwatch_metric_alarm.system_health_check" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="data.aws_instance.linux_instance_details" value="cty.NilVal"
2024-11-15T14:44:05Z	ERROR	[terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.	block="data.aws_instance.windows_instance_details" value="cty.NilVal"
2024-11-15T14:44:06Z	INFO	[terraform executor] Ignore finding	rule="aws-s3-enable-bucket-encryption" range="s3.tf:119-132"
2024-11-15T14:44:06Z	INFO	[terraform executor] Ignore finding	rule="aws-s3-encryption-customer-key" range="s3.tf:119-132"
2024-11-15T14:44:06Z	INFO	[terraform executor] Ignore finding	rule="aws-iam-no-user-attached-policies" range="iam.tf:924-931"
2024-11-15T14:44:06Z	INFO	[terraform executor] Ignore finding	rule="aws-elb-alb-not-public" range="alb_external.tf:88-108"
2024-11-15T14:44:06Z	INFO	Number of language-specific files	num=0
2024-11-15T14:44:06Z	INFO	Detected config files	num=6
trivy_exitcode=0

@nbuckingham72 nbuckingham72 merged commit 5e272a4 into main Nov 15, 2024
11 of 14 checks passed
@nbuckingham72 nbuckingham72 deleted the Update_151124_4 branch November 15, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
environments-repository Used to exclude PRs from this repo in our Slack PR update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants