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

branch[accurics_qndqp7brhr]: Auto Generated Pull Request from Accurics #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion security_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "aws_security_group" "aws-demo-security-group" {
to_port = 0
from_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
cidr_blocks = ["<cidr>"]
Copy link
Owner Author

Choose a reason for hiding this comment

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

Accurics remediation

[HIGH]: Ensure no security groups allow ingress from 0.0.0.0/0 to ALL ports and protocols

Vulnerability
It is recommended that no security group allows unrestricted ingress access. Exposed ports may allow attackers to access the application listening on that port.

Remediation
In AWS Console -

  1. Sign in the AWS Console and go to the Amazon VPC console.
  2. In the navigation pane, select Security Groups.
  3. For each security group, perform the following actions:
    a) Select the security group.
    b) Select the Inbound Rules.
    c) Identify the rules to be removed.
    d) Remove the required rules.
  4. Click Save.

source: accurics-

}

egress {
Expand Down
160 changes: 160 additions & 0 deletions vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,163 @@ resource "aws_vpc" "aws-demo3" {
}
}


resource "aws_flow_log" "aws-demo" {
vpc_id = "${aws_vpc.aws-demo.id}"
iam_role_arn = "<iam_role_arn>"
log_destination = "${aws_s3_bucket.aws-demo.arn}"
traffic_type = "ALL"

tags = {
GeneratedBy = "Accurics"
ParentResourceId = "aws_vpc.aws-demo"
}
}
resource "aws_s3_bucket" "aws-demo" {
bucket = "aws-demo_flow_log_s3_bucket"
acl = "private"
force_destroy = true

versioning {
enabled = true
mfa_delete = true
}

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_s3_bucket_policy" "aws-demo" {
bucket = "${aws_s3_bucket.aws-demo.id}"

policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "aws-demo-restrict-access-to-users-or-roles",
"Effect": "Allow",
"Principal": [
{
"AWS": [
<principal_arn>
]
}
],
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::${aws_s3_bucket.aws-demo.id}/*"
}
]
}
POLICY
}
resource "aws_flow_log" "aws-demo2" {
vpc_id = "${aws_vpc.aws-demo2.id}"
iam_role_arn = "<iam_role_arn>"
log_destination = "${aws_s3_bucket.aws-demo2.arn}"
traffic_type = "ALL"

tags = {
GeneratedBy = "Accurics"
ParentResourceId = "aws_vpc.aws-demo2"
}
}
resource "aws_s3_bucket" "aws-demo2" {
bucket = "aws-demo2_flow_log_s3_bucket"
acl = "private"
force_destroy = true

versioning {
enabled = true
mfa_delete = true
}

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_s3_bucket_policy" "aws-demo2" {
bucket = "${aws_s3_bucket.aws-demo2.id}"

policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "aws-demo2-restrict-access-to-users-or-roles",
"Effect": "Allow",
"Principal": [
{
"AWS": [
<principal_arn>
]
}
],
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::${aws_s3_bucket.aws-demo2.id}/*"
}
]
}
POLICY
}
resource "aws_flow_log" "aws-demo3" {
vpc_id = "${aws_vpc.aws-demo3.id}"
iam_role_arn = "<iam_role_arn>"
log_destination = "${aws_s3_bucket.aws-demo3.arn}"
traffic_type = "ALL"

tags = {
GeneratedBy = "Accurics"
ParentResourceId = "aws_vpc.aws-demo3"
}
}
resource "aws_s3_bucket" "aws-demo3" {
bucket = "aws-demo3_flow_log_s3_bucket"
acl = "private"
force_destroy = true

versioning {
enabled = true
mfa_delete = true
}

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_s3_bucket_policy" "aws-demo3" {
bucket = "${aws_s3_bucket.aws-demo3.id}"

policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "aws-demo3-restrict-access-to-users-or-roles",
"Effect": "Allow",
"Principal": [
{
"AWS": [
<principal_arn>
]
}
],
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::${aws_s3_bucket.aws-demo3.id}/*"
}
]
}
POLICY
}