Skip to content

Commit

Permalink
Merge pull request #5780 from freedomofpress/5776-iptables-persistent…
Browse files Browse the repository at this point in the history
…-for-focal

Fixes #5776 adds iptables-persistent dependency on Focal
  • Loading branch information
conorsch authored Feb 11, 2021
2 parents fc6753e + 8e10aec commit 240a9a9
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 5 deletions.
3 changes: 0 additions & 3 deletions install_files/ansible-base/roles/app/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
name: tor
state: restarted

- name: reload iptables rules
shell: iptables-restore < /etc/network/iptables/rules_v4

## App/securedrop section
- name: restart apache2
service:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resolvconf_target_filepath: /etc/resolv.conf
securedrop_common_packages:
- apt-transport-https
- aptitude
- iptables-persistent
- unattended-upgrades
- ntp
- ntpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
dest: /etc/network/if-up.d/load_iptables
owner: root
mode: "0744"
when:
- ansible_distribution_release == 'xenial'

- name: Create iptables directory.
file:
Expand All @@ -35,6 +37,8 @@
owner: root
group: root
dest: /etc/network/iptables
when:
- ansible_distribution_release == 'xenial'

- name: Determine local platform specific routing info
set_fact:
Expand All @@ -59,14 +63,14 @@
- name: Copy IPv4 iptables rules.
template:
src: rules_v4
dest: /etc/network/iptables/rules_v4
dest: "{{ iptables_v4_path }}"
owner: root
mode: "0644"
notify: drop flag for reboot

- name: Copy IPv6 iptables rules.
copy:
src: iptables_rules_v6
dest: /etc/network/iptables/rules_v6
dest: "{{ iptables_v6_path }}"
owner: root
mode: "0644"
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- include_vars: "{{ ansible_distribution }}_{{ ansible_distribution_release }}.yml"

- include: fetch_tor_config.yml
when: fetch_tor_client_auth_configs

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
iptables_v4_path: /etc/iptables/rules.v4
iptables_v6_path: /etc/iptables/rules.v6
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
iptables_v4_path: /etc/network/iptables/rules_v4
iptables_v6_path: /etc/network/iptables/rules_v6
11 changes: 11 additions & 0 deletions molecule/testinfra/common/test_system_hardening.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,14 @@ def test_no_ecrypt_messages_in_logs(host, logfile):
def test_unused_packages_are_removed(host, package):
""" Check if unused package is present """
assert host.package(package).is_installed is False


def test_iptables_packages(host):
"""
Focal hosts should use iptables-persistent for enforcing
firewall config across reboots.
"""
if host.system_info.codename == "focal":
assert host.package("iptables-persistent").is_installed
else:
assert not host.package("iptables-persistent").is_installed

0 comments on commit 240a9a9

Please sign in to comment.