Skip to content

Commit

Permalink
Merge pull request dev-sec#438 from dev-sec/remove_depracted_secure-auth
Browse files Browse the repository at this point in the history
 remove secure-auth param if mysql >= 8.0.3
  • Loading branch information
schurzi committed Apr 1, 2021
2 parents 04cb0a2 + 07950d8 commit 6ca9346
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/mysql_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
molecule_distro:
- centos7
- centos8
- ubuntu1604
- ubuntu1804
- ubuntu2004
- debian9
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/nginx_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
molecule_distro:
- centos7
- centos8
- ubuntu1604
- ubuntu1804
- ubuntu2004
- debian9
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/os_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
molecule_distro:
- centos7
- centos8
- ubuntu1604
- ubuntu1804
- ubuntu2004
- debian9
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ssh_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
- centos7
- centos8
- fedora
- ubuntu1604
- ubuntu1804
- ubuntu2004
- debian9
Expand Down
1 change: 1 addition & 0 deletions molecule/mysql_hardening/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dependency:
name: galaxy
options:
role-file: molecule/mysql_hardening/requirements.yml
requirements-file: molecule/mysql_hardening/requirements.yml
driver:
name: docker
lint: |
Expand Down
23 changes: 23 additions & 0 deletions roles/mysql_hardening/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@
when: "not lookup('varnames', '^' + item.key + '$')"
with_dict: '{{ os_vars }}'

- name: Gather package facts to check for mysql/mariadb version
ansible.builtin.package_facts:
manager: auto

- name: Check if MySQL or MariaDB is used
set_fact:
mysql_distribution: "{{ ansible_facts.packages['mysql-server'] is defined | ternary('mysql', 'mariadb') }}"

- name: Check which MySQL/MariaDB version is used
community.mysql.mysql_info:
filter: version
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
register: mysql_version

# see https://stackoverflow.com/a/59451077/2953919 for the
# dict2items and vice versa magic
- name: Drop the secure-auth parameter on MySQL >=8.0.3 (not mariadb)
set_fact:
mysql_hardening_options: "{{ mysql_hardening_options| dict2items | rejectattr('key', 'search', 'secure-auth') | list | items2dict }}"
when:
- mysql_version.version.full is version('8.0.3', '>=')
- mysql_distribution == "mysql"

- include: configure.yml
when: mysql_hardening_enabled | bool
tags:
Expand Down

0 comments on commit 6ca9346

Please sign in to comment.