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

Made some changes to CAT II #4

Merged
merged 14 commits into from
Aug 6, 2016
Merged
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ rhel7stig_tftp_required: no
# RHEL-07-040580 Set the SNMP community string to this from the default of
# public or private
rhel7stig_snmp_community: Endgam3Ladyb0g

# RHEL-07-040730 The system must not be performing packet forwarding unless the
# system is a router. This variable is used in tasks that should not be run
# if the OS is run as a router. (must override to yes)
rhel7stig_system_is_router: no
11 changes: 8 additions & 3 deletions tasks/audit-cat2.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- name: "MEDIUM | RHEL-07-040640 | AUDIT | The SSH public host key files must have mode 0644 or less permissive."
command: find / -name '*ssh_host*key'
command: find / -name '*.pub'
failed_when: no
changed_when: no
ignore_errors: yes
register: rhel_07_040650_audit
register: rhel_07_040640_audit
tags:
- cat2
- high
Expand All @@ -12,7 +12,12 @@
- always

- name: "MEDIUM | RHEL-07-040650 | AUDIT | The SSH private host key files must have mode 0600 or less permissive."
command: find / -name '*ssh_host*key'
find:
paths: /
recurse: yes
file_type: file
patterns: '*ssh_host*key'
hidden: true
failed_when: no
changed_when: no
ignore_errors: yes
Expand Down
30 changes: 23 additions & 7 deletions tasks/fix-cat2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1440,9 +1440,9 @@

- name: "MEDIUM | RHEL-07-040640 | PATCH | The SSH public host key files must have mode 0644 or less permissive."
file:
dest: "{{ item }}"
mode: 0644
state: file
dest: "{{ item }}"
Copy link
Owner

Choose a reason for hiding this comment

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

Use item.path.

mode: 0644
state: file
with_items: "{{ rhel_07_040640_audit.stdout_lines }}"
Copy link
Owner

Choose a reason for hiding this comment

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

Use rhel_07_040640_audit.files.

tags:
- cat2
Expand All @@ -1452,10 +1452,10 @@

- name: "MEDIUM | RHEL-07-040650 | PATCH | The SSH private host key files must have mode 0600 or less permissive."
file:
dest: "{{ item }}"
mode: 0600
state: file
with_items: "{{ rhel_07_040650_audit.stdout_lines }}"
dest: "{{ item }}"
Copy link
Owner

Choose a reason for hiding this comment

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

Use item.path.

mode: 0600
state: file
with_items: "{{ rhel_07_040650_audit.files | map(attribute='path') | list }}"
Copy link
Owner

Choose a reason for hiding this comment

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

Use rhel_07_04650.files without the filters.

tags:
- cat2
- medium
Expand Down Expand Up @@ -1524,6 +1524,7 @@
regexp: (?i)^#?compression
line: Compression no
validate: sshd -t -f %s
ignore_errors: yes
Copy link
Owner

Choose a reason for hiding this comment

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

Why ignore errors for this task?

notify: restart ssh
tags:
- cat2
Expand All @@ -1537,6 +1538,8 @@
name: net.ipv4.ip_forward
present: yes
value: 0
ignore_errors: yes
Copy link
Owner

Choose a reason for hiding this comment

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

Use the module parameter ignoreererors rather than that task parameter ignore_errors. That tells sysctl to ignore unknown/invalid keys buts will still allow the task to fail if something else is wrong.

Copy link
Owner

Choose a reason for hiding this comment

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

Use ignoreerrors on the module not the task.

when: not rhel7stig_system_is_router
tags:
- cat2
- medium
Expand All @@ -1562,6 +1565,18 @@
- RHEL-07-040810
- firewalld

- name: "MEDIUM | RHEL-07-040810 | PATCH | The system must use a local firewall."
service:
name: firewalld
state: started
enabled: yes
tags:
- cat2
- medium
- patch
- RHEL-07-040810
- firewalld

- name: "MEDIUM | RHEL-07-040820 | PATCH | The system's access control program must be configured to grant or deny system access to specific hosts and services."
command: "true"
tags:
Expand All @@ -1583,6 +1598,7 @@
name: net.ipv6.conf.all.accept_source_route
present: yes
value: 0
Copy link
Owner

Choose a reason for hiding this comment

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

For sysctl tasks, we generally add ignoreerrors: yes task parameter to prevent failure due to unknown keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed on each sysctl task. Getting ready to commit changes now.

ignore_errors: yes
Copy link
Owner

Choose a reason for hiding this comment

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

Same here. Use ignorerrors in the module not the task. (syscstl is special in that it has its own ignoreerrors parameter).

Copy link
Owner

Choose a reason for hiding this comment

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

Use ignoreerrors on the module not the task.

tags:
- cat2
- medium
Expand Down