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_041224_5 #8966

Merged
merged 1 commit into from
Dec 4, 2024
Merged

Update_041224_5 #8966

merged 1 commit into from
Dec 4, 2024

Conversation

nbuckingham72
Copy link
Collaborator

Creation of a new eventbridge rule and IAM permissions update

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

github-actions bot commented Dec 4, 2024

Trivy Scan Success

Show Output ```hcl

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


Running Trivy in terraform/environments/ppud
2024-12-04T15:07:56Z INFO [vulndb] Need to update DB
2024-12-04T15:07:56Z INFO [vulndb] Downloading vulnerability DB...
2024-12-04T15:07:56Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-04T15:07:59Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-04T15:07:59Z INFO [vuln] Vulnerability scanning is enabled
2024-12-04T15:07:59Z INFO [misconfig] Misconfiguration scanning is enabled
2024-12-04T15:07:59Z INFO [misconfig] Need to update the built-in checks
2024-12-04T15:07:59Z INFO [misconfig] Downloading the built-in checks...
160.80 KiB / 160.80 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-12-04T15:08:01Z INFO [secret] Secret scanning is enabled
2024-12-04T15:08:01Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-04T15:08:01Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.58/docs/scanner/secret#recommendation for faster secret detection
2024-12-04T15:08:02Z INFO [terraform scanner] Scanning root module file_path="."
2024-12-04T15:08:03Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-12-04T15:08:04Z INFO [terraform executor] Ignore finding rule="aws-iam-no-user-attached-policies" range="iam.tf:925-932"
2024-12-04T15:08:04Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="s3.tf:119-132"
2024-12-04T15:08:04Z INFO [terraform executor] Ignore finding rule="aws-s3-enable-bucket-encryption" range="s3.tf:119-132"
2024-12-04T15:08:04Z INFO [terraform executor] Ignore finding rule="aws-elb-alb-not-public" range="alb_external.tf:92"
2024-12-04T15:08:04Z INFO Number of language-specific files num=0
2024-12-04T15:08:04Z 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
terraform scan results:

Passed checks: 1218, Failed checks: 9, Skipped checks: 167

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_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 | }

Check: CKV_AWS_116: "Ensure that AWS Lambda function is configured for a Dead Letter Queue(DLQ)"
	FAILED for resource: aws_lambda_function.terraform_lambda_func_send_cpu_graph_dev
	File: /lambda.tf:498-521
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-that-aws-lambda-function-is-configured-for-a-dead-letter-queue-dlq

		498 | resource "aws_lambda_function" "terraform_lambda_func_send_cpu_graph_dev" {
		499 |   # checkov:skip=CKV_AWS_117: "PPUD Lambda functions do not require VPC access and can run in no-VPC mode"
		500 |   count                          = local.is-development == true ? 1 : 0
		501 |   filename                       = "${path.module}/lambda_scripts/send_cpu_graph_dev.zip"
		502 |   function_name                  = "send_cpu_graph"
		503 |   role                           = aws_iam_role.lambda_role_cloudwatch_get_metric_data_dev[0].arn
		504 |   handler                        = "send_cpu_graph_dev.lambda_handler"
		505 |   runtime                        = "python3.12"
		506 |   timeout                        = 300
		507 |   depends_on                     = [aws_iam_role_policy_attachment.attach_lambda_policy_cloudwatch_get_metric_data_to_lambda_role_cloudwatch_get_metric_data_dev]
		508 |   reserved_concurrent_executions = 5
		509 |   # code_signing_config_arn        = "arn:aws:lambda:eu-west-2:${local.environment_management.account_ids["ppud-development"]}:code-signing-config:csc-0c7136ccff2de748f"
		510 |   # dead_letter_config {
		511 |   #   target_arn = aws_sqs_queue.lambda_queue_dev[0].arn
		512 |   # }
		513 |   tracing_config {
		514 |     mode = "Active"
		515 |   }
		516 |   layers = [
		517 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_dev[0].value}:layer:Klayers-p312-numpy:8",
		518 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_dev[0].value}:layer:Klayers-p312-pillow:1",
		519 |     aws_lambda_layer_version.lambda_layer_matplotlib_dev[0].arn
		520 |   ]
		521 | }

Check: CKV_AWS_272: "Ensure AWS Lambda function is configured to validate code-signing"
	FAILED for resource: aws_lambda_function.terraform_lambda_func_send_cpu_graph_dev
	File: /lambda.tf:498-521
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-272

		498 | resource "aws_lambda_function" "terraform_lambda_func_send_cpu_graph_dev" {
		499 |   # checkov:skip=CKV_AWS_117: "PPUD Lambda functions do not require VPC access and can run in no-VPC mode"
		500 |   count                          = local.is-development == true ? 1 : 0
		501 |   filename                       = "${path.module}/lambda_scripts/send_cpu_graph_dev.zip"
		502 |   function_name                  = "send_cpu_graph"
		503 |   role                           = aws_iam_role.lambda_role_cloudwatch_get_metric_data_dev[0].arn
		504 |   handler                        = "send_cpu_graph_dev.lambda_handler"
		505 |   runtime                        = "python3.12"
		506 |   timeout                        = 300
		507 |   depends_on                     = [aws_iam_role_policy_attachment.attach_lambda_policy_cloudwatch_get_metric_data_to_lambda_role_cloudwatch_get_metric_data_dev]
		508 |   reserved_concurrent_executions = 5
		509 |   # code_signing_config_arn        = "arn:aws:lambda:eu-west-2:${local.environment_management.account_ids["ppud-development"]}:code-signing-config:csc-0c7136ccff2de748f"
		510 |   # dead_letter_config {
		511 |   #   target_arn = aws_sqs_queue.lambda_queue_dev[0].arn
		512 |   # }
		513 |   tracing_config {
		514 |     mode = "Active"
		515 |   }
		516 |   layers = [
		517 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_dev[0].value}:layer:Klayers-p312-numpy:8",
		518 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_dev[0].value}:layer:Klayers-p312-pillow:1",
		519 |     aws_lambda_layer_version.lambda_layer_matplotlib_dev[0].arn
		520 |   ]
		521 | }

Check: CKV_AWS_116: "Ensure that AWS Lambda function is configured for a Dead Letter Queue(DLQ)"
	FAILED for resource: aws_lambda_function.terraform_lambda_func_send_cpu_graph_prod
	File: /lambda.tf:556-584
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-that-aws-lambda-function-is-configured-for-a-dead-letter-queue-dlq

		556 | resource "aws_lambda_function" "terraform_lambda_func_send_cpu_graph_prod" {
		557 |   # checkov:skip=CKV_AWS_117: "PPUD Lambda functions do not require VPC access and can run in no-VPC mode"
		558 |   count                          = local.is-production == true ? 1 : 0
		559 |   filename                       = "${path.module}/lambda_scripts/send_cpu_graph_prod.zip"
		560 |   function_name                  = "send_cpu_graph"
		561 |   role                           = aws_iam_role.lambda_role_cloudwatch_get_metric_data_prod[0].arn
		562 |   handler                        = "send_cpu_graph_prod.lambda_handler"
		563 |   runtime                        = "python3.12"
		564 |   timeout                        = 300
		565 |   depends_on                     = [aws_iam_role_policy_attachment.attach_lambda_policy_cloudwatch_get_metric_data_to_lambda_role_cloudwatch_get_metric_data_prod]
		566 |   reserved_concurrent_executions = 5
		567 |   # code_signing_config_arn        = "arn:aws:lambda:eu-west-2:${local.environment_management.account_ids["ppud-production"]}:code-signing-config:csc-0bafee04a642a41c1"
		568 |   # dead_letter_config {
		569 |   #   target_arn = aws_sqs_queue.lambda_queue_prod[0].arn
		570 |   # }
		571 |   tracing_config {
		572 |     mode = "Active"
		573 |   }
		574 |   layers = [
		575 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_prod[0].value}:layer:Klayers-p312-numpy:8",
		576 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_prod[0].value}:layer:Klayers-p312-pillow:1",
		577 |     aws_lambda_layer_version.lambda_layer_matplotlib_prod[0].arn
		578 |   ]
		579 |   # VPC configuration
		580 |   vpc_config {
		581 |     subnet_ids         = [data.aws_subnet.private_subnets_b.id]
		582 |     security_group_ids = [aws_security_group.PPUD-Mail-Server[0].id]
		583 |   }
		584 | }

Check: CKV_AWS_272: "Ensure AWS Lambda function is configured to validate code-signing"
	FAILED for resource: aws_lambda_function.terraform_lambda_func_send_cpu_graph_prod
	File: /lambda.tf:556-584
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/bc-aws-272

		556 | resource "aws_lambda_function" "terraform_lambda_func_send_cpu_graph_prod" {
		557 |   # checkov:skip=CKV_AWS_117: "PPUD Lambda functions do not require VPC access and can run in no-VPC mode"
		558 |   count                          = local.is-production == true ? 1 : 0
		559 |   filename                       = "${path.module}/lambda_scripts/send_cpu_graph_prod.zip"
		560 |   function_name                  = "send_cpu_graph"
		561 |   role                           = aws_iam_role.lambda_role_cloudwatch_get_metric_data_prod[0].arn
		562 |   handler                        = "send_cpu_graph_prod.lambda_handler"
		563 |   runtime                        = "python3.12"
		564 |   timeout                        = 300
		565 |   depends_on                     = [aws_iam_role_policy_attachment.attach_lambda_policy_cloudwatch_get_metric_data_to_lambda_role_cloudwatch_get_metric_data_prod]
		566 |   reserved_concurrent_executions = 5
		567 |   # code_signing_config_arn        = "arn:aws:lambda:eu-west-2:${local.environment_management.account_ids["ppud-production"]}:code-signing-config:csc-0bafee04a642a41c1"
		568 |   # dead_letter_config {
		569 |   #   target_arn = aws_sqs_queue.lambda_queue_prod[0].arn
		570 |   # }
		571 |   tracing_config {
		572 |     mode = "Active"
		573 |   }
		574 |   layers = [
		575 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_prod[0].value}:layer:Klayers-p312-numpy:8",
		576 |     "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_prod[0].value}:layer:Klayers-p312-pillow:1",
		577 |     aws_lambda_layer_version.lambda_layer_matplotlib_prod[0].arn
		578 |   ]
		579 |   # VPC configuration
		580 |   vpc_config {
		581 |     subnet_ids         = [data.aws_subnet.private_subnets_b.id]
		582 |     security_group_ids = [aws_security_group.PPUD-Mail-Server[0].id]
		583 |   }
		584 | }

Check: CKV2_AWS_5: "Ensure that Security Groups are attached to another resource"
	FAILED for resource: aws_security_group.Live-DOC-Server
	File: /security_group.tf:419-428
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-that-security-groups-are-attached-to-ec2-instances-or-elastic-network-interfaces-enis

		419 | resource "aws_security_group" "Live-DOC-Server" {
		420 |   count       = local.is-preproduction == false ? 1 : 0
		421 |   vpc_id      = data.aws_vpc.shared.id
		422 |   name        = "Live-DOC-Server"
		423 |   description = "Live-DOC-Server for DEV & PROD"
		424 | 
		425 |   tags = {
		426 |     Name = "${var.networking[0].business-unit}-${local.environment}"
		427 |   }
		428 | }

Check: CKV2_AWS_5: "Ensure that Security Groups are attached to another resource"
	FAILED for resource: aws_security_group.Archive-DOC-Server
	File: /security_group.tf:574-583
	Guide: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-networking-policies/ensure-that-security-groups-are-attached-to-ec2-instances-or-elastic-network-interfaces-enis

		574 | resource "aws_security_group" "Archive-DOC-Server" {
		575 |   count       = local.is-preproduction == false ? 1 : 0
		576 |   vpc_id      = data.aws_vpc.shared.id
		577 |   name        = "Archive-DOC-Server"
		578 |   description = "Archive-DOC-Server for DEV & PROD"
		579 | 
		580 |   tags = {
		581 |     Name = "${var.networking[0].business-unit}-${local.environment}"
		582 |   }
		583 | }


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-12-04T15:07:56Z	INFO	[vulndb] Need to update DB
2024-12-04T15:07:56Z	INFO	[vulndb] Downloading vulnerability DB...
2024-12-04T15:07:56Z	INFO	[vulndb] Downloading artifact...	repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-04T15:07:59Z	INFO	[vulndb] Artifact successfully downloaded	repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-12-04T15:07:59Z	INFO	[vuln] Vulnerability scanning is enabled
2024-12-04T15:07:59Z	INFO	[misconfig] Misconfiguration scanning is enabled
2024-12-04T15:07:59Z	INFO	[misconfig] Need to update the built-in checks
2024-12-04T15:07:59Z	INFO	[misconfig] Downloading the built-in checks...
160.80 KiB / 160.80 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-12-04T15:08:01Z	INFO	[secret] Secret scanning is enabled
2024-12-04T15:08:01Z	INFO	[secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-12-04T15:08:01Z	INFO	[secret] Please see also https://aquasecurity.github.io/trivy/v0.58/docs/scanner/secret#recommendation for faster secret detection
2024-12-04T15:08:02Z	INFO	[terraform scanner] Scanning root module	file_path="."
2024-12-04T15:08:03Z	WARN	[terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.	module="root" variables="networking"
2024-12-04T15:08:04Z	INFO	[terraform executor] Ignore finding	rule="aws-iam-no-user-attached-policies" range="iam.tf:925-932"
2024-12-04T15:08:04Z	INFO	[terraform executor] Ignore finding	rule="aws-s3-encryption-customer-key" range="s3.tf:119-132"
2024-12-04T15:08:04Z	INFO	[terraform executor] Ignore finding	rule="aws-s3-enable-bucket-encryption" range="s3.tf:119-132"
2024-12-04T15:08:04Z	INFO	[terraform executor] Ignore finding	rule="aws-elb-alb-not-public" range="alb_external.tf:92"
2024-12-04T15:08:04Z	INFO	Number of language-specific files	num=0
2024-12-04T15:08:04Z	INFO	Detected config files	num=6
trivy_exitcode=0

@nbuckingham72 nbuckingham72 merged commit 99ef9a7 into main Dec 4, 2024
13 of 14 checks passed
@nbuckingham72 nbuckingham72 deleted the Update_041224_5 branch December 4, 2024 15:15
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