Skip to content

Commit

Permalink
Merge pull request #86 from ansible-lockdown/devel
Browse files Browse the repository at this point in the history
Release v1.0.3 Updates
Signed-off-by: George Nalen <[email protected]>
  • Loading branch information
georgenalen authored Apr 2, 2021
2 parents f9e10d5 + 8e62392 commit f37b8c1
Show file tree
Hide file tree
Showing 87 changed files with 5,666 additions and 4,328 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tests/Dockerfile
packer_cache
delete*
ignore*
test_inv
# VSCode
.vscode

Expand Down
15 changes: 14 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Contributing to MindPoint Group Projects
========================================

Rules
-----
1) All commits must be GPG signed (details in Signing section)
2) All commits must have Signed-off-by (Signed-off-by: Joan Doe <[email protected]>) in the commit message (details in Signing section)
3) All work is done in your own branch
4) All pull requests go into the devel branch. There are automated checks for signed commits, signoff in commit message, and functional testing)
5) Be open and nice to eachother

Workflow
--------
- Your work is done in your own individual branch. Make sure to to Signed-off and GPG sign all commits you intend to merge
- All community Pull Requests are into the devel branch. There are automated checks for GPG signed, Signed-off in commits, and functional tests before being approved. If your pull request comes in from outside of our repo, the pull request will go into a staging branch. There is info needed from our repo for our CI/CD testing.
- Once your changes are merged and a more detailed review is complete, an authorized member will merge your changes into the main branch for a new release

Signing your contribution
-------------------------

Expand Down Expand Up @@ -51,4 +65,3 @@ following text in your contribution commit message:
This message can be entered manually, or if you have configured git
with the correct `user.name` and `user.email`, you can use the `-s`
option to `git commit` to automatically include the signoff message.

45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ RHEL 8 CIS
================

![Build Status](https://img.shields.io/github/workflow/status/ansible-lockdown/RHEL8-CIS/CommunityToDevel?label=Devel%20Build%20Status&style=plastic)
![Build Status](https://img.shields.io/github/workflow/status/ansible-lockdown/RHEL8-CIS/DevelToMain?label=Main%20Build%20Status&style=plastic)
![Release](https://img.shields.io/github/v/release/ansible-lockdown/RHEL8-CIS?style=plastic)


Configure RHEL/Centos 8 machine to be [CIS](https://www.cisecurity.org/cis-benchmarks/) compliant
Expand All @@ -25,10 +27,25 @@ Documentation
[Wiki](https://github.com/ansible-lockdown/RHEL8-CIS/wiki)<br>
[Repo GitHub Page](https://ansible-lockdown.github.io/RHEL8-CIS/)<br>

Auditing (new)
--------------

This can be turned on or off within the defaults/main.yml file with the variable rhel8cis_run_audit. The value is false by default, please refer to the wiki for more details.

This is a much quicker, very lightweight, checking (where possible) config compliance and live/running settings.

A new form of auditing has been develeoped, by using a small (12MB) go binary called [goss](https://github.com/aelsabbahy/goss) along with the relevant configurations to check. Without the need for infrastructure or other tooling.
This audit will not only check the config has the correct setting but aims to capture if it is running with that configuration also trying to remove [false positives](https://www.mindpointgroup.com/blog/is-compliance-scanning-still-relevant/) in the process.

Refer to [RHEL8-CIS-Audit](https://github.com/ansible-lockdown/RHEL8-CIS-Audit).


Requirements
------------

RHEL 8 or CentOS 8 - Other versions are not supported.
Access to download or add the goss binary and content to the system if using auditing. options are available on how to get the content to the system.

**General:**
- Basic knowledge of Ansible, below are some links to the Ansible documentation to help get started if you are unfamiliar with Ansible
- [Main Ansible documentation page](https://docs.ansible.com)
Expand All @@ -38,9 +55,10 @@ Requirements
- Functioning Ansible and/or Tower Installed, configured, and running. This includes all of the base Ansible/Tower configurations, needed packages installed, and infrastructure setup.
- Please read through the tasks in this role to gain an understanding of what each control is doing. Some of the tasks are disruptive and can have unintended consiquences in a live production system. Also familiarize yourself with the variables in the defaults/main.yml file or the [Main Variables Wiki Page](https://github.com/ansible-lockdown/RHEL8-CIS/wiki/Main-Variables).

**Technical Dependencies:**
- Running Ansible/Tower setup (this role is tested against Ansible version 2.9.1 and newer)
- Python3 Ansible run environment
Dependencies
------------
- Python3
- Ansible 2.9+
- python-def (should be included in RHEL/CentOS 8)
- libselinux-python

Expand All @@ -56,14 +74,33 @@ There are many tags available for added control precision. Each control has it's
Below is an example of the tag section from a control within this role. Using this example if you set your run to skip all controls with the tag services, this task will be skipped. The opposite can also happen where you run only controls tagged with services.
```
tags:
- level1
- level1-server
- level1-workstation
- scored
- avahi
- services
- patch
- rule_2.2.4
```

Example Audit Summary
---------------------

This is based on a vagrant image with selections enabled. e.g. No Gui or firewall.
Note: More tests are run during audit as we check config and running state.
````
ok: [default] => {
"msg": [
"The pre remediation results are: ['Total Duration: 5.454s', 'Count: 338, Failed: 47, Skipped: 5'].",
"The post remediation results are: ['Total Duration: 5.007s', 'Count: 338, Failed: 46, Skipped: 5'].",
"Full breakdown can be found in /var/tmp",
""
]
}
PLAY RECAP *******************************************************************************************************************************************
default : ok=270 changed=23 unreachable=0 failed=0 skipped=140 rescued=0 ignored=0
````
Branches
-------
**devel** - This is the default branch and the working development branch. Community pull requests will pull into this branch<br>
Expand Down
24 changes: 24 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[defaults]
host_key_checking=False
display_skipped_hosts=True
system_warnings=False
command_warnings=False
nocows=1
retry_files_save_path=/dev/null
library=~/.ansible/plugins/modules:/usr/share/ansible/plugins/modules:./library

[privilege_escalation]

[paramiko_connection]
record_host_keys=False

[ssh_connection]
transfer_method=scp

[accelerate]

[selinux]

[colors]

[diff]
97 changes: 91 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ rhel8cis_section6: true

rhel8cis_selinux_disable: false

## Python Binary
## This is used for python3 Installations where python2 OS modules are used in ansible
python2_bin: /bin/python2.7

## Benchmark name used by audting control role
# The audit variable found at the base
benchmark: RHEL8-CIS

# Enable goss binary download
rhel8cis_setup_audit: false
# Options are downoad from github or copy from pre downloaded location
# copy or download
get_goss_file: download

# Enable audits to run
rhel8cis_run_audit: false

# These variables correspond with the CIS rule IDs or paragraph numbers defined in
# the CIS benchmark documents.
# PLEASE NOTE: These work in coordination with the section # group variables and tags.
Expand Down Expand Up @@ -308,16 +325,34 @@ rhel8cis_net_snmp: false
rhel8cis_allow_autofs: false

## Section 1 vars

# 1.1.2
# These settings go into the /etc/fstab file for the /tmp mount settings
# The value must contain nosuid,nodev,noexec to conform to CIS standards
# rhel8cis_tmp_tmpfs_settings: "defaults,rw,nosuid,nodev,noexec,relatime 0 0"
# If set true uses the tmp.mount service else using fstab configuration
rhel8cis_tmp_svc: false

# 1.2.1
# This is the login information for your RedHat Subscription
# DO NOT USE PLAIN TEXT PASSWORDS!!!!!
# The intent here is to use a password utility like Ansible Vault here
rhel8cis_rh_sub_user: user
rhel8cis_rh_sub_password: password

# 1.2.2
# Do you require rhnsd
# RedHat Satellite Subscription items
rhel8cis_rhnsd_required: false

# 1.3.3 var log location variable
rhel8cis_varlog_location: "/var/log/sudo.log"

# xinetd required
rhel8cis_xinetd_required: false

# RedHat Satellite Subscription items
rhel8cis_rhnsd_required: false

# 1.4.2 Bootloader password
rhel8cis_bootloader_password_hash: 'grub.pbkdf2.sha512.changethispassword'
rhel8cis_bootloader_password: random
rhel8cis_set_boot_pass: false

Expand Down Expand Up @@ -351,7 +386,7 @@ rhel8cis_selinux_pol: targeted
rhel8cis_gui: no

# Set to 'true' if X Windows is needed in your environment
rhel8cis_xwindows_required: no
rhel8cis_xwindows_required: false

rhel8cis_openldap_clients_required: false
rhel8cis_telnet_required: false
Expand Down Expand Up @@ -394,8 +429,8 @@ rhel8cis_firewall_services:
- dhcpv6-client

# 3.4.3.2 Set nftables new table create
rhel8cis_nft_tables_autoNewTable: true
rhel8cis_nft_tables_tableName: filter
rhel8cis_nft_tables_autonewtable: true
rhel8cis_nft_tables_tablename: filter

# 3.4.3.3 Set nftables new chain create
rhel8cis_nft_tables_autoChainCreate: true
Expand All @@ -408,6 +443,8 @@ rhel8cis_warning_banner: |
## Section4 vars

rhel8cis_auditd:
space_left_action: email
action_mail_acct: root
admin_space_left_action: halt
max_log_file_action: keep_logs

Expand Down Expand Up @@ -479,6 +516,10 @@ rhel8cis_vartmp:
fstype: none
opts: "defaults,nodev,nosuid,noexec,bind"
enabled: no
## PAM
rhel8cis_pam_password:
minlen: "14"
minclass: "4"

# Starting GID for interactive users
rhel8cis_int_gid: 1000
Expand All @@ -492,6 +533,9 @@ rhel8cis_shell_session_timeout:
# RHEL-08-5.4.1.5 Allow ansible to expire password for account with a last changed date in the future. False will just display users in violation, true will expire those users passwords
rhel8cis_futurepwchgdate_autofix: true

# wheel users list
rhel8cis_wheel_users: "root"

## Section6 vars

# RHEL-08_6.1.1 Allow ansible to adjust package descrepancies . False will just display packages with descrepancies, True will correct descrepancies
Expand All @@ -501,3 +545,44 @@ rhelcis_rpm_descrep_autofixes: true
rhel8cis_no_world_write_adjust: true
rhel8cis_passwd_label: "{{ (this_item | default(item)).id }}: {{ (this_item | default(item)).dir }}"
rhel8cis_dotperm_ansibleManaged: true

# Goss Audit Variables
# how to get audit files onto host options
# options are git/copy/get_url
rhel8cis_audit_content: git

# git
rhel8cis_audit_file_git: "https://github.com/ansible-lockdown/{{ benchmark }}-Audit.git"
rhel8cis_audit_git_version: main

# copy:
#rhel8cis_audit_local_copy: "some path to copy from"

# get_url:
#rhel8cis_audit_files_url: "some url maybe s3?"


## audit controls ##
goss_version:
release: v0.3.16
checksum: 'sha256:827e354b48f93bce933f5efcd1f00dc82569c42a179cf2d384b040d8a80bfbfb'

### Audit Settings ###
#goss_checksum: "checksum_{{ goss_version }}"
goss_path: /usr/local/bin/
goss_bin: "{{ goss_path }}goss"
goss_format: documentation
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version.release }}/goss-linux-amd64"

## Goss tests information
goss_audit_dir: "/var/tmp/{{ benchmark }}-Audit/"
goss_file: "{{ goss_audit_dir }}goss.yml"
goss_vars_path: "{{ goss_audit_dir }}/vars/{{ ansible_hostname }}.yml"
goss_out_dir: '/var/tmp'
pre_audit_outfile: "{{ goss_out_dir }}/pre_remediation_scan"
post_audit_outfile: "{{ goss_out_dir }}/post_remediation_scan"

Audit_results: |
The pre remediation results are: {{ pre_audit_summary }}.
The post remediation results are: {{ post_audit_summary }}.
Full breakdown can be found in {{ goss_out_dir }}
44 changes: 0 additions & 44 deletions filter_plugins/filters.py

This file was deleted.

10 changes: 0 additions & 10 deletions filter_plugins/xml2json.py

This file was deleted.

10 changes: 8 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
become: yes
sysctl:
name: net.ipv4.route.flush
value: 1
value: '1'
sysctl_set: yes
ignore_errors: yes
when: ansible_virtualization_type != "docker"

- name: sysctl flush ipv6 route table
become: yes
sysctl:
name: net.ipv6.route.flush
value: 1
value: '1'
sysctl_set: yes
when: ansible_virtualization_type != "docker"

Expand All @@ -35,6 +36,11 @@
masked: no
state: reloaded

- name: remount tmp
command: mount -o remount /tmp
args:
warn: false

- name: generate new grub config
become: yes
command: grub2-mkconfig -o "{{ grub_cfg.stat.lnk_source }}"
Expand Down
Loading

0 comments on commit f37b8c1

Please sign in to comment.