Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb0e00f433 | ||
|
|
3bd20265d4 | ||
|
|
8a385b8114 | ||
|
|
b0393a12ce | ||
|
|
96d6b47912 | ||
|
|
0c840372d8 | ||
|
|
ff939a2b4c | ||
|
|
0609cf729a | ||
|
|
c9c6819892 | ||
|
|
bbe4ce16a1 | ||
|
|
4eb847c90e | ||
|
|
1bf31a197b | ||
|
|
1605f304ec | ||
|
|
12c1f3dd78 | ||
|
|
7f17f9b8b2 | ||
|
|
f09b2b6338 | ||
|
|
2e5e1de407 | ||
|
|
c1974282b1 | ||
|
|
09958ccb91 | ||
|
|
08b0fd14f4 | ||
|
|
ff37289879 | ||
|
|
9f372c285c | ||
|
|
aaf6d307b8 | ||
|
|
3cd532fe41 | ||
|
|
384c097f8a | ||
|
|
346b064682 | ||
|
|
be0d501bc8 | ||
|
|
12aaa7d955 | ||
|
|
f32b2c2c5e | ||
|
|
3877a9bab1 | ||
|
|
cb7f447d9f | ||
|
|
55c83ac92d | ||
|
|
bbc827e4a1 | ||
|
|
999e5fa210 | ||
|
|
215c8042ad | ||
|
|
940819ab84 | ||
|
|
21ca7c533a | ||
|
|
5debcc0c6f | ||
|
|
92bd94a0cf | ||
|
|
aea4499805 | ||
|
|
29945527b8 | ||
|
|
e819f89ccb | ||
|
|
fcb7efc156 | ||
|
|
8fdb4e55b8 | ||
|
|
8ff3d73bbf | ||
|
|
062dd3f092 | ||
|
|
37cff01759 | ||
|
|
4671a32062 | ||
|
|
78bab3f710 | ||
|
|
3b33e0a7aa | ||
|
|
2ed9d8e9da | ||
|
|
df134e6385 |
No files matched your search
@@ -12,7 +12,9 @@ os_hardening:
|
|||||||
ssh_hardening:
|
ssh_hardening:
|
||||||
- 'roles/ssh_hardening/**'
|
- 'roles/ssh_hardening/**'
|
||||||
- 'molecule/ssh_hardening/**'
|
- 'molecule/ssh_hardening/**'
|
||||||
|
- 'molecule/ssh_hardening_custom_tests/**'
|
||||||
- '.github/workflows/ssh_hardening.yml'
|
- '.github/workflows/ssh_hardening.yml'
|
||||||
|
- '.github/workflows/ssh_hardening_custom_tests.yml'
|
||||||
|
|
||||||
nginx_hardening:
|
nginx_hardening:
|
||||||
- 'roles/nginx_hardening/**'
|
- 'roles/nginx_hardening/**'
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
---
|
||||||
|
name: "devsec.ssh_hardening with custom tests"
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'roles/ssh_hardening/**'
|
||||||
|
- 'molecule/ssh_hardening_custom_tests/**'
|
||||||
|
- '.github/workflows/ssh_hardening_custom_tests.yml'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'roles/ssh_hardening/**'
|
||||||
|
- 'molecule/ssh_hardening_custom_tests/**'
|
||||||
|
- '.github/workflows/ssh_hardening_custom_tests.yml'
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
env:
|
||||||
|
PY_COLORS: 1
|
||||||
|
ANSIBLE_FORCE_COLOR: 1
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
molecule_distro:
|
||||||
|
- centos7
|
||||||
|
- centos8
|
||||||
|
- rocky8
|
||||||
|
- fedora
|
||||||
|
- ubuntu1804
|
||||||
|
- ubuntu2004
|
||||||
|
- debian9
|
||||||
|
- debian10
|
||||||
|
- amazon
|
||||||
|
# - arch # needs to be fixed
|
||||||
|
# - opensuse_tumbleweed # baseline is not compatible with suse
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: ansible_collections/devsec/hardening
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Set up Python 3.7
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.7
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt install git
|
||||||
|
python -m pip install --no-cache-dir --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
working-directory: ansible_collections/devsec/hardening
|
||||||
|
|
||||||
|
- name: Create default collection path symlink
|
||||||
|
run: |
|
||||||
|
mkdir -p /home/runner/.ansible
|
||||||
|
ln -s /home/runner/work/ansible-os-hardening/ansible-os-hardening /home/runner/.ansible/collections
|
||||||
|
|
||||||
|
- name: Test with molecule
|
||||||
|
run: |
|
||||||
|
if [ "$MOLECULE_DISTRO" = "opensuse_tumbleweed" ]; then
|
||||||
|
export MOLECULE_DOCKER_COMMAND="/usr/lib/systemd/systemd"
|
||||||
|
fi
|
||||||
|
molecule --version
|
||||||
|
molecule converge -s ssh_hardening_custom_tests
|
||||||
|
env:
|
||||||
|
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
|
||||||
|
working-directory: ansible_collections/devsec/hardening
|
||||||
+72
-1
@@ -1,16 +1,87 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [Unreleased](https://github.com/dev-sec/ansible-collection-hardening/tree/HEAD)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/7.12.0...HEAD)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- os\_hardening: Provide a whitelist for yum repositories with non-signed RPMs [\#485](https://github.com/dev-sec/ansible-collection-hardening/issues/485)
|
||||||
|
- Disable ctrl-alt-del key combination [\#496](https://github.com/dev-sec/ansible-collection-hardening/pull/496) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([lbayerlein](https://github.com/lbayerlein))
|
||||||
|
- implement sysctl-34 - link protection settings [\#494](https://github.com/dev-sec/ansible-collection-hardening/pull/494) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
|
||||||
|
- Add whitelist option for yum repository files [\#487](https://github.com/dev-sec/ansible-collection-hardening/pull/487) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([darxriggs](https://github.com/darxriggs))
|
||||||
|
- Add TLSv1.3 to nginx default configuration [\#470](https://github.com/dev-sec/ansible-collection-hardening/pull/470) [[nginx_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/nginx_hardening)] ([ksaadDE](https://github.com/ksaadDE))
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- Please create the collection in ansible-galaxy [\#407](https://github.com/dev-sec/ansible-collection-hardening/issues/407)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Improve testing: install packages on Arch Linux [\#499](https://github.com/dev-sec/ansible-collection-hardening/pull/499) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([darxriggs](https://github.com/darxriggs))
|
||||||
|
- add old role names to tags in Galaxy [\#495](https://github.com/dev-sec/ansible-collection-hardening/pull/495) ([schurzi](https://github.com/schurzi))
|
||||||
|
- update minimum ansible version for roles [\#493](https://github.com/dev-sec/ansible-collection-hardening/pull/493) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] [[nginx_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/nginx_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
|
||||||
|
- revive old tests with custom ssh settings [\#491](https://github.com/dev-sec/ansible-collection-hardening/pull/491) ([rndmh3ro](https://github.com/rndmh3ro))
|
||||||
|
|
||||||
|
## [7.12.0](https://github.com/dev-sec/ansible-collection-hardening/tree/7.12.0) (2021-10-21)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/7.11.0...7.12.0)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- feat\(os\_hardening\): extend file permission tasks to cover more files [\#489](https://github.com/dev-sec/ansible-collection-hardening/pull/489) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([cmhe](https://github.com/cmhe))
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- mysql remove deprecated 'secure\_auth' parameter in mysql [\#346](https://github.com/dev-sec/ansible-collection-hardening/issues/346)
|
||||||
|
- change baseline urls to full zip-url [\#490](https://github.com/dev-sec/ansible-collection-hardening/pull/490) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] [[nginx_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/nginx_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
|
||||||
|
- fix filter error in ansible.builtin.file mode parameter [\#486](https://github.com/dev-sec/ansible-collection-hardening/pull/486) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([ssttehrani](https://github.com/ssttehrani))
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- Extend os\_hardening minimize\_access task to cover additional passwd/group/shadow/gshadow paths [\#488](https://github.com/dev-sec/ansible-collection-hardening/issues/488)
|
||||||
|
- postgresql\_hardening role [\#484](https://github.com/dev-sec/ansible-collection-hardening/issues/484)
|
||||||
|
- os\_hardening fails on "Create a combined sysctl-dict if overwrites are defined" task [\#482](https://github.com/dev-sec/ansible-collection-hardening/issues/482)
|
||||||
|
- Improve changelog generation [\#381](https://github.com/dev-sec/ansible-collection-hardening/issues/381)
|
||||||
|
|
||||||
|
## [7.11.0](https://github.com/dev-sec/ansible-collection-hardening/tree/7.11.0) (2021-08-30)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/7.10.0...7.11.0)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Use `log_error` file and `datadir` from mysql\_info settings instead of variables `mysql_datadir` and `mysql_hardening_log_file` [\#478](https://github.com/dev-sec/ansible-collection-hardening/pull/478) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] ([123quhiwiwk](https://github.com/123quhiwiwk))
|
||||||
|
- Execute check of MySQL error logfile permissions on Debian 11 only when log\_error is defined [\#477](https://github.com/dev-sec/ansible-collection-hardening/pull/477) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] ([123quhiwiwk](https://github.com/123quhiwiwk))
|
||||||
|
- \[mysql\_hardening\] Setup defaults for MySQL on FreeBSD [\#474](https://github.com/dev-sec/ansible-collection-hardening/pull/474) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] ([sdwilsh](https://github.com/sdwilsh))
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- MariaDB hardening fails, because log\_error file is missing \[Debian 11\] [\#476](https://github.com/dev-sec/ansible-collection-hardening/issues/476)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- ssh\_allow\_tcp\_forwarding is not a boolean [\#480](https://github.com/dev-sec/ansible-collection-hardening/pull/480) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([ReinerNippes](https://github.com/ReinerNippes))
|
||||||
|
- chore\(ssh\_hardening\): set min\_ansible\_version to \>=2.9.10 [\#479](https://github.com/dev-sec/ansible-collection-hardening/pull/479) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([bufferoverflow](https://github.com/bufferoverflow))
|
||||||
|
|
||||||
## [7.10.0](https://github.com/dev-sec/ansible-collection-hardening/tree/7.10.0) (2021-08-15)
|
## [7.10.0](https://github.com/dev-sec/ansible-collection-hardening/tree/7.10.0) (2021-08-15)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/7.9.0...7.10.0)
|
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/7.9.0...7.10.0)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- use Ansible lint in separate task [\#475](https://github.com/dev-sec/ansible-collection-hardening/pull/475) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] [[nginx_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/nginx_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
|
||||||
|
- \[mysql\_hardening\] Allow setting the mysql\_distribution [\#473](https://github.com/dev-sec/ansible-collection-hardening/pull/473) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] ([sdwilsh](https://github.com/sdwilsh))
|
||||||
|
|
||||||
**Fixed bugs:**
|
**Fixed bugs:**
|
||||||
|
|
||||||
- mysql\_hardening cannot work with mysql on freebsd [\#472](https://github.com/dev-sec/ansible-collection-hardening/issues/472)
|
- mysql\_hardening cannot work with mysql on freebsd [\#472](https://github.com/dev-sec/ansible-collection-hardening/issues/472)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- run ansible-lint only once in Github Actions [\#398](https://github.com/dev-sec/ansible-collection-hardening/issues/398)
|
||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
- \[mysql\_hardening\] Allow setting the mysql\_distribution [\#473](https://github.com/dev-sec/ansible-collection-hardening/pull/473) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] ([sdwilsh](https://github.com/sdwilsh))
|
|
||||||
- SSH Hardening: backtick typo [\#471](https://github.com/dev-sec/ansible-collection-hardening/pull/471) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([Slamdunk](https://github.com/Slamdunk))
|
- SSH Hardening: backtick typo [\#471](https://github.com/dev-sec/ansible-collection-hardening/pull/471) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([Slamdunk](https://github.com/Slamdunk))
|
||||||
- fix license in galaxy [\#469](https://github.com/dev-sec/ansible-collection-hardening/pull/469) ([rndmh3ro](https://github.com/rndmh3ro))
|
- fix license in galaxy [\#469](https://github.com/dev-sec/ansible-collection-hardening/pull/469) ([rndmh3ro](https://github.com/rndmh3ro))
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -1,6 +1,6 @@
|
|||||||
namespace: devsec
|
namespace: devsec
|
||||||
name: hardening
|
name: hardening
|
||||||
version: 7.9.0
|
version: 7.12.0
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- dev-sec <[email protected]>
|
- dev-sec <[email protected]>
|
||||||
@@ -17,6 +17,11 @@ tags:
|
|||||||
- nginx
|
- nginx
|
||||||
- mysql
|
- mysql
|
||||||
- openssh
|
- openssh
|
||||||
|
- apache_hardening
|
||||||
|
- mysql_hardening
|
||||||
|
- nginx_hardening
|
||||||
|
- os_hardening
|
||||||
|
- ssh-hardening
|
||||||
dependencies:
|
dependencies:
|
||||||
ansible.posix: '>=1.0.0'
|
ansible.posix: '>=1.0.0'
|
||||||
community.crypto: '>=1.0.0'
|
community.crypto: '>=1.0.0'
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
||||||
|
|
||||||
- name: Execute cinc-auditor tests
|
- name: Execute cinc-auditor tests
|
||||||
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit supermarket://dev-sec/mysql-baseline"
|
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit https://github.com/dev-sec/mysql-baseline/archive/refs/heads/master.zip"
|
||||||
register: test_results
|
register: test_results
|
||||||
changed_when: false
|
changed_when: false
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
||||||
|
|
||||||
- name: Execute cinc-auditor tests
|
- name: Execute cinc-auditor tests
|
||||||
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit supermarket://dev-sec/nginx-baseline"
|
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit https://github.com/dev-sec/nginx-baseline/archive/refs/heads/master.zip"
|
||||||
register: test_results
|
register: test_results
|
||||||
changed_when: false
|
changed_when: false
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
os_security_suid_sgid_blacklist: ['/bin/umount']
|
os_security_suid_sgid_blacklist: ['/bin/umount']
|
||||||
os_security_suid_sgid_whitelist: ['/usr/bin/rlogin']
|
os_security_suid_sgid_whitelist: ['/usr/bin/rlogin']
|
||||||
os_filesystem_whitelist: []
|
os_filesystem_whitelist: []
|
||||||
|
os_ctrlaltdel_disabled: true
|
||||||
|
os_yum_repo_file_whitelist: ['foo.repo']
|
||||||
sysctl_config:
|
sysctl_config:
|
||||||
net.ipv4.ip_forward: 0
|
net.ipv4.ip_forward: 0
|
||||||
net.ipv6.conf.all.forwarding: 0
|
net.ipv6.conf.all.forwarding: 0
|
||||||
|
|||||||
@@ -34,13 +34,13 @@
|
|||||||
- procps-ng
|
- procps-ng
|
||||||
when: ansible_facts.distribution == 'Fedora'
|
when: ansible_facts.distribution == 'Fedora'
|
||||||
|
|
||||||
- name: install packages
|
- name: install required tools on Arch
|
||||||
pacman:
|
pacman:
|
||||||
name:
|
name:
|
||||||
- "awk"
|
- awk
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
ignore_errors: true
|
when: ansible_facts.os_family == 'Archlinux'
|
||||||
|
|
||||||
- name: install required tools on RHEL
|
- name: install required tools on RHEL
|
||||||
yum:
|
yum:
|
||||||
@@ -54,3 +54,7 @@
|
|||||||
- name: create recursing symlink to test minimize access
|
- name: create recursing symlink to test minimize access
|
||||||
shell: "rm -f /usr/bin/zzz && ln -s /usr/bin /usr/bin/zzz"
|
shell: "rm -f /usr/bin/zzz && ln -s /usr/bin /usr/bin/zzz"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
- name: include YUM prepare tasks
|
||||||
|
include: prepare_yum.yml
|
||||||
|
when: ansible_facts.os_family == 'RedHat'
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- name: create 'foo' repository
|
||||||
|
yum_repository:
|
||||||
|
name: foo
|
||||||
|
description: mandatory description
|
||||||
|
baseurl: file:///mandatory-url
|
||||||
|
enabled: false
|
||||||
|
gpgcheck: false
|
||||||
|
|
||||||
|
- name: create 'bar' repository
|
||||||
|
yum_repository:
|
||||||
|
name: bar
|
||||||
|
description: mandatory description
|
||||||
|
baseurl: file:///mandatory-url
|
||||||
|
enabled: false
|
||||||
|
gpgcheck: false
|
||||||
@@ -41,6 +41,10 @@
|
|||||||
include: verify_pam.yml
|
include: verify_pam.yml
|
||||||
when: ansible_facts.distribution in ['Debian', 'Ubuntu'] or ansible_facts.os_family == 'RedHat'
|
when: ansible_facts.distribution in ['Debian', 'Ubuntu'] or ansible_facts.os_family == 'RedHat'
|
||||||
|
|
||||||
|
- name: include YUM tests
|
||||||
|
include: verify_yum.yml
|
||||||
|
when: ansible_facts.os_family == 'RedHat'
|
||||||
|
|
||||||
- name: download cinc-auditor
|
- name: download cinc-auditor
|
||||||
get_url:
|
get_url:
|
||||||
url: https://omnitruck.cinc.sh/install.sh
|
url: https://omnitruck.cinc.sh/install.sh
|
||||||
@@ -51,7 +55,7 @@
|
|||||||
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
||||||
|
|
||||||
- name: Execute cinc-auditor tests
|
- name: Execute cinc-auditor tests
|
||||||
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit supermarket://dev-sec/linux-baseline"
|
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit https://github.com/dev-sec/linux-baseline/archive/refs/heads/master.zip"
|
||||||
register: test_results
|
register: test_results
|
||||||
changed_when: false
|
changed_when: false
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: verify 'gpgcheck' was not enabled for 'foo' repository (in whitelist)
|
||||||
|
command: grep -e 'gpgcheck\s*=\s*0' /etc/yum.repos.d/foo.repo
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: verify 'gpgcheck' was enabled for 'bar' repository (not in whitelist)
|
||||||
|
command: grep -e 'gpgcheck\s*=\s*1' /etc/yum.repos.d/bar.repo
|
||||||
|
changed_when: false
|
||||||
@@ -52,14 +52,14 @@
|
|||||||
- "openssh"
|
- "openssh"
|
||||||
when: ansible_facts.os_family == 'Suse'
|
when: ansible_facts.os_family == 'Suse'
|
||||||
|
|
||||||
- name: install packages
|
- name: install required tools on Arch
|
||||||
pacman:
|
pacman:
|
||||||
name:
|
name:
|
||||||
- "openssh"
|
- openssh
|
||||||
- "awk"
|
- awk
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
ignore_errors: true
|
when: ansible_facts.os_family == 'Archlinux'
|
||||||
|
|
||||||
- name: created needed directory
|
- name: created needed directory
|
||||||
file:
|
file:
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
|
||||||
|
|
||||||
- name: Execute cinc-auditor tests
|
- name: Execute cinc-auditor tests
|
||||||
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit supermarket://dev-sec/nginx-baseline"
|
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit https://github.com/dev-sec/ssh-baseline/archive/refs/heads/master.zip"
|
||||||
register: test_results
|
register: test_results
|
||||||
changed_when: false
|
changed_when: false
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
*******
|
||||||
|
Docker driver installation guide
|
||||||
|
*******
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
* Docker Engine
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
|
|
||||||
|
Please refer to the `Virtual environment`_ documentation for installation best
|
||||||
|
practices. If not using a virtual environment, please consider passing the
|
||||||
|
widely recommended `'--user' flag`_ when invoking ``pip``.
|
||||||
|
|
||||||
|
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
||||||
|
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ python3 -m pip install 'molecule[docker]'
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
---
|
||||||
|
- name: wrapper playbook for kitchen testing "ansible-ssh-hardening" with custom settings
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
environment:
|
||||||
|
http_proxy: "{{ lookup('env', 'http_proxy') | default(omit) }}"
|
||||||
|
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
|
||||||
|
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
|
||||||
|
collections:
|
||||||
|
- devsec.hardening
|
||||||
|
tasks:
|
||||||
|
- include_role:
|
||||||
|
name: ssh_hardening
|
||||||
|
vars:
|
||||||
|
ssh_trusted_user_ca_keys_file: '/etc/ssh/ca.pub'
|
||||||
|
ssh_trusted_user_ca_keys:
|
||||||
|
- '# ssh-rsa ...'
|
||||||
|
ssh_authorized_principals_file: '/etc/ssh/auth_principals/%u'
|
||||||
|
ssh_authorized_principals:
|
||||||
|
- path: "/etc/ssh/auth_principals/root"
|
||||||
|
principals:
|
||||||
|
- "root"
|
||||||
|
owner: "{{ ssh_owner }}"
|
||||||
|
group: "{{ ssh_group }}"
|
||||||
|
directoryowner: "{{ ssh_owner }}"
|
||||||
|
directorygroup: "{{ ssh_group }}"
|
||||||
|
directorymode: "0700"
|
||||||
|
network_ipv6_enable: true
|
||||||
|
ssh_allow_tcp_forwarding: 'yes'
|
||||||
|
ssh_gateway_ports: true
|
||||||
|
ssh_allow_agent_forwarding: true
|
||||||
|
ssh_server_permit_environment_vars: 'yes'
|
||||||
|
ssh_server_accept_env_vars: 'PWD HTTP_PROXY'
|
||||||
|
ssh_client_alive_interval: 100
|
||||||
|
ssh_client_alive_count: 10
|
||||||
|
ssh_client_password_login: true
|
||||||
|
ssh_challengeresponseauthentication: true
|
||||||
|
ssh_compression: true
|
||||||
|
ssh_allow_users: 'root kitchen vagrant'
|
||||||
|
ssh_allow_groups: 'root kitchen vagrant'
|
||||||
|
ssh_deny_users: 'foo bar'
|
||||||
|
ssh_deny_groups: 'foo bar'
|
||||||
|
ssh_authorized_keys_file: '/etc/ssh/authorized_keys/%u'
|
||||||
|
ssh_max_auth_retries: 10
|
||||||
|
ssh_permit_root_login: "without-password"
|
||||||
|
ssh_permit_tunnel: true
|
||||||
|
ssh_print_motd: true
|
||||||
|
ssh_print_last_log: true
|
||||||
|
ssh_banner: true
|
||||||
|
ssh_server_password_login: true
|
||||||
|
sftp_enabled: true
|
||||||
|
sftp_chroot: true
|
||||||
|
# ssh_server_enabled: false
|
||||||
|
ssh_server_ports:
|
||||||
|
- 22
|
||||||
|
- 222
|
||||||
|
ssh_server_match_address:
|
||||||
|
- address: '192.168.1.0/24'
|
||||||
|
rules:
|
||||||
|
- 'AllowTcpForwarding yes'
|
||||||
|
- 'AllowAgentForwarding no'
|
||||||
|
ssh_server_match_group:
|
||||||
|
- group: 'root'
|
||||||
|
rules:
|
||||||
|
- 'AllowTcpForwarding yes'
|
||||||
|
- 'AllowAgentForwarding no'
|
||||||
|
ssh_server_match_user:
|
||||||
|
- user: 'root'
|
||||||
|
rules:
|
||||||
|
- 'AllowTcpForwarding yes'
|
||||||
|
- 'AllowAgentForwarding no'
|
||||||
|
ssh_server_match_local_port:
|
||||||
|
- port: 222
|
||||||
|
rules:
|
||||||
|
- 'AllowTcpForwarding yes'
|
||||||
|
- 'AllowAgentForwarding no'
|
||||||
|
ssh_remote_hosts:
|
||||||
|
- names: ['example.com', 'example2.com']
|
||||||
|
options: ['Port 2222', 'ForwardAgent yes']
|
||||||
|
- names: ['example3.com']
|
||||||
|
options: ['StrictHostKeyChecking no']
|
||||||
|
ssh_use_dns: true
|
||||||
|
ssh_use_pam: true
|
||||||
|
ssh_max_startups: '10:30:60'
|
||||||
|
ssh_host_key_algorithms:
|
||||||
|
- ssh-ed25519
|
||||||
|
- rsa-sha2-512
|
||||||
|
- rsa-sha2-256
|
||||||
|
- ssh-rsa
|
||||||
|
ssh_macs:
|
||||||
|
- hmac-sha2-512
|
||||||
|
- hmac-sha2-256
|
||||||
|
ssh_ciphers:
|
||||||
|
- aes256-ctr
|
||||||
|
- aes192-ctr
|
||||||
|
- aes128-ctr
|
||||||
|
- aes256-cbc
|
||||||
|
ssh_kex:
|
||||||
|
- diffie-hellman-group-exchange-sha256
|
||||||
|
- diffie-hellman-group-exchange-sha1
|
||||||
|
ssh_custom_options:
|
||||||
|
- "Include /etc/ssh/ssh_config.d/*"
|
||||||
|
sshd_custom_options:
|
||||||
|
- "AcceptEnv LANG"
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
role-file: molecule/ssh_hardening/requirements.yml
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
platforms:
|
||||||
|
- name: instance
|
||||||
|
image: "rndmh3ro/docker-${MOLECULE_DISTRO}-ansible:latest"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
tmpfs:
|
||||||
|
- /tmp
|
||||||
|
- /run
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
tty: true
|
||||||
|
env:
|
||||||
|
http_proxy: "${http_proxy}"
|
||||||
|
https_proxy: "${https_proxy}"
|
||||||
|
no_proxy: "${no_proxy}"
|
||||||
|
container: docker
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
config_options:
|
||||||
|
defaults:
|
||||||
|
interpreter_python: auto_silent
|
||||||
|
callback_whitelist: profile_tasks, timer, yaml
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
create_sequence:
|
||||||
|
- dependency
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
check_sequence:
|
||||||
|
- dependency
|
||||||
|
- destroy
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- check
|
||||||
|
- destroy
|
||||||
|
converge_sequence:
|
||||||
|
- dependency
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
destroy_sequence:
|
||||||
|
- destroy
|
||||||
|
test_sequence:
|
||||||
|
- dependency
|
||||||
|
- destroy
|
||||||
|
- syntax
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- idempotence
|
||||||
|
- verify
|
||||||
|
- destroy
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
---
|
||||||
|
- name: wrapper playbook for kitchen testing "ansible-ssh-hardening" with default settings
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
environment:
|
||||||
|
http_proxy: "{{ lookup('env', 'http_proxy') | default(omit) }}"
|
||||||
|
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
|
||||||
|
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
|
||||||
|
tasks:
|
||||||
|
- name: use python3
|
||||||
|
set_fact:
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
when: ansible_facts.distribution == 'Fedora'
|
||||||
|
|
||||||
|
- name: install packages
|
||||||
|
yum:
|
||||||
|
name:
|
||||||
|
- openssh-clients
|
||||||
|
- openssh-server
|
||||||
|
- libselinux-python
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: install packages
|
||||||
|
dnf:
|
||||||
|
name:
|
||||||
|
- openssh-clients
|
||||||
|
- openssh-server
|
||||||
|
- procps-ng
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: install packages
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- openssh-client
|
||||||
|
- openssh-server
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: install required tools on SuSE
|
||||||
|
# cannot use zypper module, since it depends on python-xml
|
||||||
|
shell: "zypper -n install python-xml"
|
||||||
|
when: ansible_facts.os_family == 'Suse'
|
||||||
|
|
||||||
|
- name: install packages
|
||||||
|
zypper:
|
||||||
|
name:
|
||||||
|
- "openssh"
|
||||||
|
when: ansible_facts.os_family == 'Suse'
|
||||||
|
|
||||||
|
- name: install required tools on Arch
|
||||||
|
pacman:
|
||||||
|
name:
|
||||||
|
- openssh
|
||||||
|
- awk
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
when: ansible_facts.os_family == 'Archlinux'
|
||||||
|
|
||||||
|
- name: created needed directory
|
||||||
|
file:
|
||||||
|
path: "/var/run/sshd"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: create ssh host keys
|
||||||
|
command: "ssh-keygen -A"
|
||||||
|
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat']) and ansible_facts.distribution_major_version < '7') or
|
||||||
|
ansible_facts.distribution == "Fedora" or
|
||||||
|
ansible_facts.distribution == "Amazon" or
|
||||||
|
ansible_facts.os_family == "Suse"
|
||||||
|
changed_when: false
|
||||||
|
ignore_errors: true
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
roles:
|
||||||
|
- geerlingguy.git
|
||||||
@@ -27,12 +27,14 @@ It configures:
|
|||||||
- mysql_hardening
|
- mysql_hardening
|
||||||
```
|
```
|
||||||
|
|
||||||
This role expects an existing installation of MySQL or MariaDB. Please ensure that the following variables are set accordingly:
|
This role expects an existing installation of MySQL or MariaDB. Changes of options `log_error` or `datadir` in `mysql_hardening_options` will not be checked for correct permissions. Please change/set `log_error` or `datadir` with the installation role of MySQL before running this role, or you can run this role twice.
|
||||||
|
Please ensure that the following variables are set accordingly:
|
||||||
|
|
||||||
- `mysql_hardening_enabled: yes` role is enabled by default and can be disabled without removing it from a playbook. You can use conditional variable, for example: `mysql_hardening_enabled: "{{ true if mysql_enabled else false }}"`
|
- `mysql_hardening_enabled: yes` role is enabled by default and can be disabled without removing it from a playbook. You can use conditional variable, for example: `mysql_hardening_enabled: "{{ true if mysql_enabled else false }}"`
|
||||||
- `mysql_hardening_user: 'mysql'` The user that mysql runs as.
|
- `mysql_hardening_user: 'mysql'` The user that mysql runs as.
|
||||||
- `mysql_datadir: '/var/lib/mysql'` The MySQL data directory
|
|
||||||
- `mysql_hardening_mysql_hardening_conf_file: '/etc/mysql/conf.d/hardening.cnf'` The path to the configuration file where the hardening will be performed
|
- `mysql_hardening_mysql_hardening_conf_file: '/etc/mysql/conf.d/hardening.cnf'` The path to the configuration file where the hardening will be performed
|
||||||
|
- _deprecated: `mysql_datadir: '/var/lib/mysql'` The MySQL data directory_
|
||||||
|
- `mysql_datadir` is no longer necessary, as MySQL data directory is automatically taken from `mysql_info`. But it can still be defined and will also be checked for correct permissions.
|
||||||
|
|
||||||
## Role Variables
|
## Role Variables
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ mysql_daemon_enabled: true
|
|||||||
mysql_hardening_restart_mysql: true
|
mysql_hardening_restart_mysql: true
|
||||||
|
|
||||||
# general configuration
|
# general configuration
|
||||||
mysql_datadir: '/var/lib/mysql'
|
|
||||||
mysql_hardening_mysql_hardening_conf_file: '{{mysql_hardening_mysql_confd_dir}}/hardening.cnf'
|
mysql_hardening_mysql_hardening_conf_file: '{{mysql_hardening_mysql_confd_dir}}/hardening.cnf'
|
||||||
# You have to change this to your own strong enough mysql root password
|
# You have to change this to your own strong enough mysql root password
|
||||||
mysql_root_password: '-----====>SetR00tPa$$wordH3r3!!!<====-----'
|
mysql_root_password: '-----====>SetR00tPa$$wordH3r3!!!<====-----'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
description: 'This Ansible playbook provides security configuration for mysql.'
|
description: 'This Ansible playbook provides security configuration for mysql.'
|
||||||
company: Hardening Framework Team
|
company: Hardening Framework Team
|
||||||
license: Apache License 2.0
|
license: Apache License 2.0
|
||||||
min_ansible_version: '1.9'
|
min_ansible_version: '2.9.10'
|
||||||
platforms:
|
platforms:
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
|
|||||||
@@ -10,19 +10,27 @@
|
|||||||
|
|
||||||
- name: Ensure permissions on mysql-datadir are correct
|
- name: Ensure permissions on mysql-datadir are correct
|
||||||
file:
|
file:
|
||||||
path: '{{ mysql_datadir }}'
|
path: '{{ item }}'
|
||||||
state: directory
|
state: directory
|
||||||
owner: '{{ mysql_hardening_user }}'
|
owner: '{{ mysql_hardening_user }}'
|
||||||
group: '{{ mysql_hardening_user }}'
|
group: '{{ mysql_hardening_user }}'
|
||||||
mode: '0750'
|
mode: '0750'
|
||||||
|
when: item is defined and item != ""
|
||||||
|
loop:
|
||||||
|
- '{{ mysql_settings.settings.datadir }}'
|
||||||
|
- '{{ mysql_datadir|default("") }}'
|
||||||
|
|
||||||
- name: Ensure permissions on mysql-logfile are correct
|
- name: Ensure permissions on mysql-logfile are correct
|
||||||
file:
|
file:
|
||||||
path: '{{ mysql_hardening_log_file }}'
|
path: '{{ item }}'
|
||||||
state: file
|
state: file
|
||||||
owner: '{{ mysql_hardening_user }}'
|
owner: '{{ mysql_hardening_user }}'
|
||||||
group: '{{ mysql_hardening_group }}'
|
group: '{{ mysql_hardening_group }}'
|
||||||
mode: '0640'
|
mode: '0640'
|
||||||
|
when: item is defined and item != ""
|
||||||
|
loop:
|
||||||
|
- '{{ mysql_settings.settings.log_error }}'
|
||||||
|
- '{{ mysql_hardening_log_file|default("") }}'
|
||||||
|
|
||||||
- name: Check mysql configuration-directory exists and has right permissions
|
- name: Check mysql configuration-directory exists and has right permissions
|
||||||
file:
|
file:
|
||||||
|
|||||||
@@ -44,6 +44,12 @@
|
|||||||
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
||||||
register: mysql_version
|
register: mysql_version
|
||||||
|
|
||||||
|
- name: Check MySQL/MariaDB settings
|
||||||
|
community.mysql.mysql_info:
|
||||||
|
filter: settings
|
||||||
|
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
||||||
|
register: mysql_settings
|
||||||
|
|
||||||
# see https://stackoverflow.com/a/59451077/2953919 for the
|
# see https://stackoverflow.com/a/59451077/2953919 for the
|
||||||
# dict2items and vice versa magic
|
# dict2items and vice versa magic
|
||||||
- name: Drop the secure-auth parameter on MySQL >=8.0.3 (not mariadb)
|
- name: Drop the secure-auth parameter on MySQL >=8.0.3 (not mariadb)
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ mysql_daemon: mysql
|
|||||||
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
||||||
|
|
||||||
mysql_hardening_log_file: '/var/log/mysql/error.log'
|
|
||||||
|
|
||||||
mysql_hardening_group: 'adm'
|
mysql_hardening_group: 'adm'
|
||||||
|
|
||||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||||
|
|||||||
@@ -2,5 +2,3 @@
|
|||||||
mysql_daemon: mysqld
|
mysql_daemon: mysqld
|
||||||
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
||||||
|
|
||||||
mysql_hardening_mysql_log_file: '/var/log/mysqld.log'
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
mysql_daemon: mysql-server
|
||||||
|
|
||||||
|
mysql_hardening_mysql_conf_file: '/usr/local/etc/mysql/my.cnf'
|
||||||
|
mysql_hardening_mysql_confd_dir: '/usr/local/etc/mysql/conf.d'
|
||||||
|
|
||||||
|
mysql_hardening_group: 'mysql'
|
||||||
|
|
||||||
|
mysql_cnf_owner: 'root' # owner of /usr/local/etc/mysql/*.cnf files
|
||||||
|
mysql_cnf_group: 'mysql' # owner of /usr/local/etc/mysql/*.cnf files
|
||||||
@@ -4,6 +4,4 @@ mysql_daemon: mysqld
|
|||||||
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
||||||
|
|
||||||
mysql_hardening_log_file: '/var/log/mysqld.log'
|
|
||||||
|
|
||||||
mysql_hardening_group: 'adm'
|
mysql_hardening_group: 'adm'
|
||||||
@@ -3,8 +3,6 @@ mysql_daemon: mariadb
|
|||||||
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
||||||
|
|
||||||
mysql_hardening_log_file: '/var/log/mariadb/mariadb.log'
|
|
||||||
|
|
||||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
mysql_daemon: mariadb
|
mysql_daemon: mariadb
|
||||||
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
||||||
mysql_hardening_log_file: '/var/log/mariadb/mariadb.log'
|
|
||||||
|
|
||||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
mysql_daemon: mariadb
|
mysql_daemon: mariadb
|
||||||
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
||||||
mysql_hardening_log_file: '/var/log/mariadb/mariadb.log'
|
|
||||||
|
|
||||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ mysql_daemon: mysql
|
|||||||
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
||||||
|
|
||||||
mysql_hardening_log_file: '/var/log/mysql/error.log'
|
|
||||||
|
|
||||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ mysql_daemon: mysql
|
|||||||
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
||||||
|
|
||||||
mysql_hardening_log_file: '/var/log/mysql/error.log'
|
|
||||||
|
|
||||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ mysql_daemon: mysql
|
|||||||
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
||||||
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
||||||
|
|
||||||
mysql_hardening_log_file: '/var/log/mysql/error.log'
|
|
||||||
|
|
||||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ nginx_add_header: [
|
|||||||
|
|
||||||
nginx_set_cookie_flag: "* HttpOnly secure"
|
nginx_set_cookie_flag: "* HttpOnly secure"
|
||||||
nginx_ssl_prefer_server_ciphers: "on"
|
nginx_ssl_prefer_server_ciphers: "on"
|
||||||
nginx_ssl_protocols: "TLSv1.2"
|
nginx_ssl_protocols: "TLSv1.2 TLSv1.3"
|
||||||
nginx_ssl_ciphers: "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256"
|
nginx_ssl_ciphers: "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256"
|
||||||
nginx_ssl_session_tickets: "off"
|
nginx_ssl_session_tickets: "off"
|
||||||
nginx_dh_size: "2048"
|
nginx_dh_size: "2048"
|
||||||
@@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
description: 'This Ansible role provides secure nginx configurations. http://dev-sec.io/'
|
description: 'This Ansible role provides secure nginx configurations. http://dev-sec.io/'
|
||||||
company: Hardening Framework Team
|
company: Hardening Framework Team
|
||||||
license: Apache License 2.0
|
license: Apache License 2.0
|
||||||
min_ansible_version: '2.5'
|
min_ansible_version: '2.9.10'
|
||||||
platforms:
|
platforms:
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
|
|||||||
@@ -229,6 +229,9 @@ We know that this is the case on Raspberry Pi.
|
|||||||
- `os_cron_enabled`
|
- `os_cron_enabled`
|
||||||
- Default: `true`
|
- Default: `true`
|
||||||
- Description: Set to false to disable installing and configuring cron.
|
- Description: Set to false to disable installing and configuring cron.
|
||||||
|
- `os_ctrlaltdel_disabled`
|
||||||
|
- Default: `false`
|
||||||
|
- Description: Set to true to disable ctrl-alt-delete key combination.
|
||||||
- `os_limits_enabled`
|
- `os_limits_enabled`
|
||||||
- Default: `true`
|
- Default: `true`
|
||||||
- Description: Set to false to disable installing and configuring limits.
|
- Description: Set to false to disable installing and configuring limits.
|
||||||
@@ -262,6 +265,9 @@ We know that this is the case on Raspberry Pi.
|
|||||||
- `os_yum_enabled`
|
- `os_yum_enabled`
|
||||||
- Default: `true`
|
- Default: `true`
|
||||||
- Description: Set to false to disable installing and configuring yum.
|
- Description: Set to false to disable installing and configuring yum.
|
||||||
|
- `os_yum_repo_file_whitelist`
|
||||||
|
- Default: `[]`
|
||||||
|
- Description: List of yum repository files under /etc/yum.repos.d/ which should not be altered.
|
||||||
- `os_apt_enabled`
|
- `os_apt_enabled`
|
||||||
- Default: `true`
|
- Default: `true`
|
||||||
- Description: Set to false to disable installing and configuring apt.
|
- Description: Set to false to disable installing and configuring apt.
|
||||||
|
|||||||
@@ -290,6 +290,16 @@ sysctl_config:
|
|||||||
# Mitigates CVE-2021-33909 and other exploits.
|
# Mitigates CVE-2021-33909 and other exploits.
|
||||||
kernel.unprivileged_userns_clone: 0
|
kernel.unprivileged_userns_clone: 0
|
||||||
|
|
||||||
|
# For more info on the following settings see: https://www.kernel.org/doc/html/latest/admin-guide/sysctl/fs.html
|
||||||
|
# Restrict FIFO special device creation behavior
|
||||||
|
fs.protected_fifos: 1
|
||||||
|
# Restrict hardlink creation behavior
|
||||||
|
fs.protected_hardlinks: 1
|
||||||
|
# Restrict regular files creation behavior
|
||||||
|
fs.protected_regular: 2
|
||||||
|
# Restrict symlink following behavior
|
||||||
|
fs.protected_symlinks: 1
|
||||||
|
|
||||||
# Do not delete the following line or otherwise the playbook will fail
|
# Do not delete the following line or otherwise the playbook will fail
|
||||||
# at task 'create a combined sysctl-dict if overwrites are defined'
|
# at task 'create a combined sysctl-dict if overwrites are defined'
|
||||||
sysctl_overwrite:
|
sysctl_overwrite:
|
||||||
@@ -334,6 +344,9 @@ proc_mnt_options: 'rw,nosuid,nodev,noexec,relatime,hidepid={{ hidepid_option }}'
|
|||||||
# Set to false to disable installing and configuring cron.
|
# Set to false to disable installing and configuring cron.
|
||||||
os_cron_enabled: true
|
os_cron_enabled: true
|
||||||
|
|
||||||
|
# Set to true to disable ctrl-alt-del key combination.
|
||||||
|
os_ctrlaltdel_disabled: false
|
||||||
|
|
||||||
# Set to false to disable installing and configuring limits.
|
# Set to false to disable installing and configuring limits.
|
||||||
os_limits_enabled: true
|
os_limits_enabled: true
|
||||||
|
|
||||||
@@ -367,6 +380,9 @@ os_rhosts_enabled: true
|
|||||||
# Set to false to disable installing and configuring yum.
|
# Set to false to disable installing and configuring yum.
|
||||||
os_yum_enabled: true
|
os_yum_enabled: true
|
||||||
|
|
||||||
|
# List of yum repository files under /etc/yum.repos.d/ which should not be altered.
|
||||||
|
os_yum_repo_file_whitelist: []
|
||||||
|
|
||||||
# Set to false to disable installing and configuring apt.
|
# Set to false to disable installing and configuring apt.
|
||||||
os_apt_enabled: true
|
os_apt_enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
description: 'This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.'
|
description: 'This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.'
|
||||||
company: Hardening Framework Team
|
company: Hardening Framework Team
|
||||||
license: Apache License 2.0
|
license: Apache License 2.0
|
||||||
min_ansible_version: '2.5'
|
min_ansible_version: '2.9.10'
|
||||||
platforms:
|
platforms:
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: Disable CTRL-ALT-DEL
|
||||||
|
systemd:
|
||||||
|
name: ctrl-alt-del.target
|
||||||
|
masked: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
when: ansible_service_mgr == "systemd"
|
||||||
@@ -30,6 +30,10 @@
|
|||||||
tags: cron
|
tags: cron
|
||||||
when: os_cron_enabled | bool
|
when: os_cron_enabled | bool
|
||||||
|
|
||||||
|
- import_tasks: ctrlaltdel.yml
|
||||||
|
tags: ctrlaltdel
|
||||||
|
when: os_ctrlaltdel_disabled | bool
|
||||||
|
|
||||||
- import_tasks: limits.yml
|
- import_tasks: limits.yml
|
||||||
tags: limits
|
tags: limits
|
||||||
when: os_limits_enabled | bool
|
when: os_limits_enabled | bool
|
||||||
|
|||||||
@@ -27,19 +27,43 @@
|
|||||||
- "{{ minimize_access_directories.results }}"
|
- "{{ minimize_access_directories.results }}"
|
||||||
- stdout_lines
|
- stdout_lines
|
||||||
|
|
||||||
|
- name: Find shadow files
|
||||||
|
stat:
|
||||||
|
path: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- '/etc/shadow'
|
||||||
|
- '/etc/gshadow'
|
||||||
|
- '/etc/shadow-'
|
||||||
|
- '/etc/gshadow-'
|
||||||
|
register: minimize_access_shadow_files
|
||||||
|
|
||||||
- name: Change shadow ownership to root and mode to 0600 | os-02
|
- name: Change shadow ownership to root and mode to 0600 | os-02
|
||||||
file:
|
file:
|
||||||
dest: '/etc/shadow'
|
dest: "{{ item.item }}"
|
||||||
owner: '{{ os_shadow_perms.owner }}'
|
owner: '{{ os_shadow_perms.owner }}'
|
||||||
group: '{{ os_shadow_perms.group }}'
|
group: '{{ os_shadow_perms.group }}'
|
||||||
mode: '{{ os_shadow_perms.mode }}'
|
mode: '{{ os_shadow_perms.mode }}'
|
||||||
|
when: item.stat.exists
|
||||||
|
loop: "{{ minimize_access_shadow_files.results }}"
|
||||||
|
|
||||||
|
- name: Find passwd files
|
||||||
|
stat:
|
||||||
|
path: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- '/etc/passwd'
|
||||||
|
- '/etc/group'
|
||||||
|
- '/etc/passwd-'
|
||||||
|
- '/etc/group-'
|
||||||
|
register: minimize_access_passwd_files
|
||||||
|
|
||||||
- name: Change passwd ownership to root and mode to 0644 | os-03
|
- name: Change passwd ownership to root and mode to 0644 | os-03
|
||||||
file:
|
file:
|
||||||
dest: '/etc/passwd'
|
dest: "{{ item.item }}"
|
||||||
owner: '{{ os_passwd_perms.owner }}'
|
owner: '{{ os_passwd_perms.owner }}'
|
||||||
group: '{{ os_passwd_perms.group }}'
|
group: '{{ os_passwd_perms.group }}'
|
||||||
mode: '{{ os_passwd_perms.mode }}'
|
mode: '{{ os_passwd_perms.mode }}'
|
||||||
|
when: item.stat.exists
|
||||||
|
loop: "{{ minimize_access_passwd_files.results }}"
|
||||||
|
|
||||||
- name: Change su-binary to only be accessible to user and group root
|
- name: Change su-binary to only be accessible to user and group root
|
||||||
file:
|
file:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
- 'CentOS-Vault'
|
- 'CentOS-Vault'
|
||||||
when: os_security_packages_clean | bool
|
when: os_security_packages_clean | bool
|
||||||
|
|
||||||
- name: Get yum-repository-files
|
- name: Get yum repository files
|
||||||
find:
|
find:
|
||||||
paths: '/etc/yum.repos.d'
|
paths: '/etc/yum.repos.d'
|
||||||
patterns: '*.repo'
|
patterns: '*.repo'
|
||||||
@@ -18,14 +18,14 @@
|
|||||||
# for the 'default([])' see here:
|
# for the 'default([])' see here:
|
||||||
# https://github.com/dev-sec/ansible-os-hardening/issues/99 and
|
# https://github.com/dev-sec/ansible-os-hardening/issues/99 and
|
||||||
# https://stackoverflow.com/questions/37067827/ansible-deprecation-warning-for-undefined-variable-despite-when-clause
|
# https://stackoverflow.com/questions/37067827/ansible-deprecation-warning-for-undefined-variable-despite-when-clause
|
||||||
- name: Activate gpg-check for yum-repository-files
|
- name: Activate gpg-check for yum repository files
|
||||||
replace:
|
replace:
|
||||||
path: '{{ item.path }}'
|
path: '{{ item }}'
|
||||||
regexp: '^\s*gpgcheck.*'
|
regexp: '^\s*gpgcheck.*'
|
||||||
replace: 'gpgcheck=1'
|
replace: 'gpgcheck=1'
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
with_items:
|
with_items:
|
||||||
- '{{ yum_repos.files | default([]) }}'
|
- "{{ yum_repos.files | default([]) | map(attribute='path') | difference(os_yum_repo_file_whitelist | map('regex_replace', '^', '/etc/yum.repos.d/') | list) }}"
|
||||||
|
|
||||||
# failed_when is needed because by default replace module will fail if the file doesn't exists.
|
# failed_when is needed because by default replace module will fail if the file doesn't exists.
|
||||||
# status.rc is only defined if an error accrued and only error code (rc) 257 will be ignored.
|
# status.rc is only defined if an error accrued and only error code (rc) 257 will be ignored.
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ ssh_remote_hosts: []
|
|||||||
# Set this to "without-password" or "yes" to allow root to login
|
# Set this to "without-password" or "yes" to allow root to login
|
||||||
ssh_permit_root_login: 'no' # sshd
|
ssh_permit_root_login: 'no' # sshd
|
||||||
|
|
||||||
# false to disable TCP Forwarding. Set to true to allow TCP Forwarding.
|
# false to disable TCP Forwarding. Set to 'yes', 'no', 'local', 'all' or 'remote' to allow TCP Forwarding.
|
||||||
ssh_allow_tcp_forwarding: 'no' # sshd
|
ssh_allow_tcp_forwarding: 'no' # sshd
|
||||||
|
|
||||||
# false to disable binding forwarded ports to non-loopback addresses. Set to true to force binding on wildcard address.
|
# false to disable binding forwarded ports to non-loopback addresses. Set to true to force binding on wildcard address.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
description: 'This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.'
|
description: 'This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.'
|
||||||
company: Hardening Framework Team
|
company: Hardening Framework Team
|
||||||
license: Apache License 2.0
|
license: Apache License 2.0
|
||||||
min_ansible_version: '2.5'
|
min_ansible_version: '2.9.10'
|
||||||
platforms:
|
platforms:
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
- name: Create ssh authorized principals directories
|
- name: Create ssh authorized principals directories
|
||||||
file:
|
file:
|
||||||
path: '{{ item.path | dirname }}'
|
path: '{{ item.path | dirname }}'
|
||||||
mode: '{{ item.directorymode | default(0700) }}'
|
mode: '{{ item.directorymode | default("700") }}'
|
||||||
owner: '{{ item.directoryowner | default(ssh_owner) }}'
|
owner: '{{ item.directoryowner | default(ssh_owner) }}'
|
||||||
group: '{{ item.directorygroup | default(ssh_group) }}'
|
group: '{{ item.directorygroup | default(ssh_group) }}'
|
||||||
state: directory
|
state: directory
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
template:
|
template:
|
||||||
src: 'authorized_principals.j2'
|
src: 'authorized_principals.j2'
|
||||||
dest: '{{ item.path }}'
|
dest: '{{ item.path }}'
|
||||||
mode: '{{ item.filemode | default(0600) }}'
|
mode: '{{ item.filemode | default("600") }}'
|
||||||
owner: '{{ item.owner| default(ssh_owner) }}'
|
owner: '{{ item.owner| default(ssh_owner) }}'
|
||||||
group: '{{ item.group | default(ssh_group) }}'
|
group: '{{ item.group | default(ssh_group) }}'
|
||||||
loop: '{{ ssh_authorized_principals }}'
|
loop: '{{ ssh_authorized_principals }}'
|
||||||
Reference in new issue
Block a user