From 2c4718fb75729889da8ac3f310194f685895ed4a Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Tue, 7 Jun 2022 10:07:19 +0100 Subject: [PATCH 1/5] fix title Signed-off-by: Mark Bolwell --- tasks/section_6/cis_6.2.x.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/section_6/cis_6.2.x.yml b/tasks/section_6/cis_6.2.x.yml index a1558db..31dafa8 100644 --- a/tasks/section_6/cis_6.2.x.yml +++ b/tasks/section_6/cis_6.2.x.yml @@ -189,7 +189,7 @@ - "The following paths have colon end: {{ rhel9cis_6_2_7_path_colon_end.stdout_lines }}" - "The following paths have a dot in the path: {{ rhel9cis_6_2_7_dot_in_path.stdout_lines }}" - - name: "6.2.7 | PATCH | Ensure root PATH Integrity (Scored) | Determine rights and owner" + - name: "6.2.7 | PATCH | Ensure root PATH Integrity | Determine rights and owner" file: > path='{{ item }}' follow=yes @@ -230,7 +230,7 @@ stat: path: "{{ item }}" register: rhel_08_6_2_9_audit - with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int ) | selectattr('uid', '!=', 65534) | map(attribute='dir') | list }}" + with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int ) | selectattr('uid', '<', max_int_uid | int ) | map(attribute='dir') | list }}" - name: "6.2.9 | AUDIT | Ensure all users' home directories exist" command: find -H {{ item.0 | quote }} -not -type l -perm /027 @@ -315,7 +315,7 @@ - name: "6.2.11 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive" stat: path: "{{ item }}" - with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int ) | selectattr('uid', '!=', 65534) | map(attribute='dir') | list }}" + with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int ) | selectattr('uid', '<', max_int_uid | int ) | map(attribute='dir') | list }}" register: rhel_08_6_2_11_audit - name: "6.2.11 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive" From 2090cc4a45d84488225e7a29ebfc1a7f621909f1 Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Tue, 7 Jun 2022 10:07:26 +0100 Subject: [PATCH 2/5] not required file Signed-off-by: Mark Bolwell --- tasks/audit_homedirperms.yml | 46 ------------------------------------ 1 file changed, 46 deletions(-) delete mode 100644 tasks/audit_homedirperms.yml diff --git a/tasks/audit_homedirperms.yml b/tasks/audit_homedirperms.yml deleted file mode 100644 index 596fed5..0000000 --- a/tasks/audit_homedirperms.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- name: "SCORED | 6.2.8 | PATCH | Ensure users' home directories permissions are 750 or more restrictive" - find: - paths: - - "{{ homedir }}" - recurse: true - file_type: any - register: rhel_09_6_2_8_results - when: - - rhel9cis_rule_6_2_8|bool - tags: - - level1 - - patch - - rule_6.2.8 - -- name: "SCORED | 6.2.8 | PATCH | Ensure users' home directories permissions are 750 or more restrictive" - file: - path: "{{ line_item.path }}" - mode: 0640 - loop: "{{ rhel_09_6_2_8_results.files }}" - loop_control: - label: "{{ line_item.path }}" - loop_var: line_item - when: - - rhel_09_6_2_8_results.files.isreg is defined - - rhel9cis_rule_6_2_8|bool - tags: - - level1 - - patch - - rule_6.2.8 - -- name: "SCORED | 6.2.8 | PATCH | Ensure users' home directories permissions are 750 or more restrictive" - file: - path: "{{ line_item.path }}" - mode: 0750 - loop: "{{ rhel_09_6_2_8_results.files }}" - loop_control: - label: "{{ line_item.path }}" - loop_var: line_item - when: - - rhel_09_6_2_8_results.files.isdir is defined - - rhel9cis_rule_6_2_8|bool - tags: - - level1 - - patch - - rule_6.2.8 From a8446b989b53156d9e62820f1bbb105f4d915944 Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Tue, 7 Jun 2022 10:23:18 +0100 Subject: [PATCH 3/5] added latest rhel9 image Signed-off-by: Mark Bolwell --- .github/workflows/OS.tfvars | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/OS.tfvars b/.github/workflows/OS.tfvars index 99064fb..5baddfc 100644 --- a/.github/workflows/OS.tfvars +++ b/.github/workflows/OS.tfvars @@ -1,8 +1,8 @@ #Ami Rocky 85 -ami_id = "ami-043ceee68871e0bb5" -ami_os = "rocky8" -ami_username = "rocky" -ami_user_home = "/home/rocky" +ami_id = "ami-0c41531b8d18cc72b" +ami_os = "rhel9" +ami_username = "ec2-user" +ami_user_home = "/home/ec2-user" instance_tags = { Name = "RHEL9-CIS" Environment = "lockdown_github_repo_workflow" From fdb3eb62862f3aba5fccbdf753d8049bf52d3a31 Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Tue, 7 Jun 2022 12:01:30 +0100 Subject: [PATCH 4/5] terraform format Signed-off-by: Mark Bolwell --- .github/workflows/github_networks.tf | 4 +- .github/workflows/github_vars.tfvars | 2 +- .github/workflows/main.tf | 10 +- .github/workflows/terraform.tfstate | 8 + .github/workflows/terraform.tfstate.backup | 370 +++++++++++++++++++++ .github/workflows/variables.tf | 2 +- 6 files changed, 387 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/terraform.tfstate create mode 100644 .github/workflows/terraform.tfstate.backup diff --git a/.github/workflows/github_networks.tf b/.github/workflows/github_networks.tf index d5a0db0..4db9025 100644 --- a/.github/workflows/github_networks.tf +++ b/.github/workflows/github_networks.tf @@ -1,11 +1,11 @@ resource "aws_vpc" "Main" { cidr_block = var.main_vpc_cidr - tags = var.instance_tags + tags = var.instance_tags } resource "aws_internet_gateway" "IGW" { vpc_id = aws_vpc.Main.id tags = { - Name = "${var.namespace}-IGW" + Name = "${var.namespace}-IGW" } } diff --git a/.github/workflows/github_vars.tfvars b/.github/workflows/github_vars.tfvars index 38be3ed..4d40f72 100644 --- a/.github/workflows/github_vars.tfvars +++ b/.github/workflows/github_vars.tfvars @@ -3,7 +3,7 @@ // Declared in variables.tf // -namespace = "github_actions" +namespace = "github_actions" // Matching pair name found in AWS for keypairs PEM key ami_key_pair_name = "github_actions" diff --git a/.github/workflows/main.tf b/.github/workflows/main.tf index 9ad9240..29fd6f3 100644 --- a/.github/workflows/main.tf +++ b/.github/workflows/main.tf @@ -28,7 +28,7 @@ resource "aws_security_group" "github_actions" { protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } - + ingress { from_port = 80 to_port = 80 @@ -44,7 +44,7 @@ resource "aws_security_group" "github_actions" { } tags = { Name = "${var.namespace}-SG" - } + } } // instance setup @@ -57,16 +57,16 @@ resource "aws_instance" "testing_vm" { tags = var.instance_tags vpc_security_group_ids = [aws_security_group.github_actions.id] root_block_device { - delete_on_termination = true + delete_on_termination = true } } // generate inventory file resource "local_file" "inventory" { - filename = "./hosts.yml" + filename = "./hosts.yml" directory_permission = "0755" file_permission = "0644" - content = < Date: Wed, 8 Jun 2022 12:31:29 +0100 Subject: [PATCH 5/5] updted syslog logic for audit Signed-off-by: Mark Bolwell --- templates/ansible_vars_goss.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ansible_vars_goss.yml.j2 b/templates/ansible_vars_goss.yml.j2 index 0947ce3..6654add 100644 --- a/templates/ansible_vars_goss.yml.j2 +++ b/templates/ansible_vars_goss.yml.j2 @@ -448,7 +448,7 @@ rhel9cis_nft_tables_autochaincreate: {{ rhel9cis_nft_tables_autochaincreate }} # Section 4 ## syslog -rhel9_cis_rsyslog: {{ rhel9cis_syslog }} +rhel9cis_syslog: {{ rhel9cis_preferred_log_capture }} # Section 5 ## 5.2.4 Note the following to understand precedence and layout