-
Notifications
You must be signed in to change notification settings - Fork 687
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
Get testinfra working on Qubes #5712
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
*filter | ||
:INPUT DROP | ||
:FORWARD DROP | ||
:OUTPUT DROP | ||
:LOGNDROP - | ||
-A INPUT -p tcp -m state --state RELATED,ESTABLISHED -m comment --comment "Allow traffic back for tor" -j ACCEPT | ||
-A INPUT -i lo -p tcp -m tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "Allow tor connection from local loopback to connect to source int" -j ACCEPT | ||
-A INPUT -i lo -p tcp -m tcp --dport 8080 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "Allow tor connection from local loopback to connect to journalist int" -j ACCEPT | ||
-A INPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -i lo -p tcp -m state --state RELATED,ESTABLISHED -m comment --comment "for redis worker all application user local loopback user" -j ACCEPT | ||
{% for address in dns_server -%} | ||
-A INPUT -s {{ address }}/32 -p tcp -m tcp --sport 53 -m state --state RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
-A INPUT -s {{ address }}/32 -p udp -m udp --sport 53 -m state --state RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
{% endfor -%} | ||
-A INPUT -p udp -m udp --sport 123 --dport 123 -m state --state RELATED,ESTABLISHED -m comment --comment ntp -j ACCEPT | ||
-A INPUT -p tcp -m multiport --sports 80,8080,443 -m state --state RELATED,ESTABLISHED -m comment --comment "apt updates" -j ACCEPT | ||
-A INPUT -s {{ mon_ip }}/32 -p udp -m udp --sport 1514 -m state --state RELATED,ESTABLISHED -m comment --comment "OSSEC server agent" -j ACCEPT | ||
-A INPUT -s {{ mon_ip }}/32 -p tcp -m tcp --dport 22 -m comment --comment "Block explicitly SSH from the adjacent SD component" -j DROP | ||
-A INPUT -s {{ ssh_ip }}/32 -i {{ default_interface }} -p tcp -m tcp --dport 22 -m state --state NEW -m limit --limit 3/min --limit-burst 3 -m comment --comment "Rate limit incoming ssh traffic" -j ACCEPT | ||
-A INPUT -s {{ ssh_ip }}/32 -i {{ default_interface }} -p tcp -m tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
-A INPUT -i lo -m comment --comment "Allow lo to lo traffic all protocols" -j ACCEPT | ||
-A INPUT -p tcp -m state --state INVALID -m comment --comment "drop but do not log inbound invalid state packets" -j DROP | ||
-A INPUT -m comment --comment "Drop and log all other incoming traffic" -j LOGNDROP | ||
-A OUTPUT -p tcp -m owner --uid-owner {{ tor_user_id }} -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "Allow tor outbound" -j ACCEPT | ||
-A OUTPUT -m owner --uid-owner {{ tor_user_id }} -m comment --comment "Drop all other traffic for tor" -j LOGNDROP | ||
-A OUTPUT -o lo -p tcp -m tcp --sport 80 -m owner --uid-owner {{ securedrop_user_id }} -m state --state RELATED,ESTABLISHED -m comment --comment "Restrict the apache user outbound connections" -j ACCEPT | ||
-A OUTPUT -o lo -p tcp -m tcp --sport 8080 -m owner --uid-owner {{ securedrop_user_id }} -m state --state RELATED,ESTABLISHED -m comment --comment "Restrict the apache user outbound connections" -j ACCEPT | ||
-A OUTPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -o lo -p tcp -m owner --uid-owner {{ securedrop_user_id }} -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "for redis worker all application user local loopback user" -j ACCEPT | ||
-A OUTPUT -m owner --uid-owner {{ securedrop_user_id }} -m comment --comment "Drop all other traffic by the securedrop user" -j LOGNDROP | ||
-A OUTPUT -m owner --gid-owner {{ ssh_group_gid }} -m comment --comment "Drop all other outbound traffic for ssh user" -j LOGNDROP | ||
{% for address in dns_server -%} | ||
-A OUTPUT -d {{ address }}/32 -p tcp -m tcp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
-A OUTPUT -d {{ address }}/32 -p udp -m udp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
{% endfor -%} | ||
-A OUTPUT -p udp -m udp --sport 123 --dport 123 -m owner --uid-owner 0 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment ntp -j ACCEPT | ||
-A OUTPUT -p tcp -m multiport --dports 80,8080,443 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "apt updates" -j ACCEPT | ||
-A OUTPUT -d {{ mon_ip }}/32 -p udp -m udp --dport 1514 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "OSSEC server agent" -j ACCEPT | ||
-A OUTPUT -o eth0 -p tcp -m owner --uid-owner 0 -m tcp --sport 22 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
-A OUTPUT -o lo -m comment --comment "Allow lo to lo traffic all protocols" -j ACCEPT | ||
-A OUTPUT -m comment --comment "Drop all other outgoing traffic" -j DROP | ||
-A LOGNDROP -p tcp -m limit --limit 5/min -j LOG --log-tcp-options --log-ip-options --log-uid | ||
-A LOGNDROP -p udp -m limit --limit 5/min -j LOG --log-ip-options --log-uid | ||
-A LOGNDROP -p icmp -m limit --limit 5/min -j LOG --log-ip-options --log-uid | ||
-A LOGNDROP -j DROP | ||
COMMIT |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
*filter | ||
:INPUT DROP | ||
:FORWARD DROP | ||
:OUTPUT DROP | ||
:LOGNDROP - | ||
-A INPUT -p tcp -m state --state RELATED,ESTABLISHED -m comment --comment "Allow traffic back for tor" -j ACCEPT | ||
{% for address in dns_server -%} | ||
-A INPUT -s {{ address }}/32 -p tcp -m tcp --sport 53 -m state --state RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
-A INPUT -s {{ address }}/32 -p udp -m udp --sport 53 -m state --state RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
{% endfor -%} | ||
-A INPUT -p udp -m udp --sport 123 --dport 123 -m state --state RELATED,ESTABLISHED -m comment --comment ntp -j ACCEPT | ||
-A INPUT -p tcp -m multiport --sports 80,8080,443 -m state --state RELATED,ESTABLISHED -m comment --comment "apt updates" -j ACCEPT | ||
-A INPUT -s {{ app_ip }}/32 -p udp -m udp --dport 1514 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "Allow OSSEC agent to monitor" -j ACCEPT | ||
{% for address in dns_server -%} | ||
-A INPUT -s {{ address }}/32 -p tcp -m tcp --sport 53 -m state --state RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
-A INPUT -s {{ address }}/32 -p udp -m udp --sport 53 -m state --state RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
{% endfor -%} | ||
-A INPUT -p tcp -m tcp --sport 587 -m state --state RELATED,ESTABLISHED -m comment --comment "Allow ossec email alerts out" -j ACCEPT | ||
-A INPUT -s {{ app_ip }}/32 -p tcp -m tcp --dport 22 -m comment --comment "Block explicitly SSH from the adjacent SD component" -j DROP | ||
-A INPUT -s {{ ssh_ip }}/32 -i {{ default_interface }} -p tcp -m tcp --dport 22 -m state --state NEW -m limit --limit 3/min --limit-burst 3 -m comment --comment "Rate limit incoming ssh traffic" -j ACCEPT | ||
-A INPUT -s {{ ssh_ip }}/32 -i {{ default_interface }} -p tcp -m tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
-A INPUT -i lo -m comment --comment "Allow lo to lo traffic all protocols" -j ACCEPT | ||
-A INPUT -p tcp -m state --state INVALID -m comment --comment "drop but do not log inbound invalid state packets" -j DROP | ||
-A INPUT -m comment --comment "Drop and log all other incoming traffic" -j LOGNDROP | ||
-A OUTPUT -p tcp -m owner --uid-owner {{ tor_user_id }} -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "Allow tor outbound" -j ACCEPT | ||
-A OUTPUT -m owner --uid-owner {{ tor_user_id }} -m comment --comment "Drop all other traffic for tor" -j LOGNDROP | ||
-A OUTPUT -m owner --gid-owner {{ ssh_group_gid }} -m comment --comment "Drop all other outbound traffic for ssh user" -j LOGNDROP | ||
{% for address in dns_server -%} | ||
-A OUTPUT -d {{ address }}/32 -p tcp -m tcp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
-A OUTPUT -d {{ address }}/32 -p udp -m udp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "tcp/udp dns" -j ACCEPT | ||
{% endfor -%} | ||
-A OUTPUT -p udp -m udp --sport 123 --dport 123 -m owner --uid-owner 0 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment ntp -j ACCEPT | ||
-A OUTPUT -p tcp -m multiport --dports 80,8080,443 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "apt updates" -j ACCEPT | ||
-A OUTPUT -d {{ app_ip }}/32 -p udp -m udp --sport 1514 -m state --state RELATED,ESTABLISHED -m comment --comment "Allow OSSEC agent to monitor" -j ACCEPT | ||
{% for address in dns_server -%} | ||
-A OUTPUT -d {{ address }}/32 -p tcp -m tcp --dport 53 -m owner --uid-owner {{ postfix_user_id }} -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "postfix dns rule" -j ACCEPT | ||
-A OUTPUT -d {{ address }}/32 -p udp -m udp --dport 53 -m owner --uid-owner {{ postfix_user_id }} -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "postfix dns rule" -j ACCEPT | ||
{% endfor -%} | ||
-A OUTPUT -p tcp -m tcp --dport 587 -m owner --uid-owner {{ postfix_user_id }} -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "Allow ossec email alerts out" -j ACCEPT | ||
-A OUTPUT -o {{ default_interface }} -p tcp -m owner --uid-owner 0 -m tcp --sport 22 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
-A OUTPUT -o lo -m comment --comment "Allow lo to lo traffic all protocols" -j ACCEPT | ||
-A OUTPUT -m comment --comment "Drop all other outgoing traffic" -j DROP | ||
-A LOGNDROP -p tcp -m limit --limit 5/min -j LOG --log-tcp-options --log-ip-options --log-uid | ||
-A LOGNDROP -p udp -m limit --limit 5/min -j LOG --log-ip-options --log-uid | ||
-A LOGNDROP -p icmp -m limit --limit 5/min -j LOG --log-ip-options --log-uid | ||
-A LOGNDROP -j DROP | ||
COMMIT |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
# Testinfra vars file for app-staigng. | ||
wanted_apache_headers: | ||
- 'Header edit Set-Cookie ^(.*)$ $1;HttpOnly' | ||
- 'Header always append X-Frame-Options: DENY' | ||
- 'Header set Referrer-Policy "same-origin"' | ||
- 'Header set X-XSS-Protection: "1; mode=block"' | ||
- 'Header set X-Content-Type-Options: nosniff' | ||
- 'Header set X-Download-Options: noopen' | ||
- "Header set X-Content-Security-Policy: \"default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; font-src 'self';\"" | ||
- "Header set Content-Security-Policy: \"default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; font-src 'self';\"" | ||
- 'Header unset Etag' | ||
|
||
securedrop_venv: /opt/venvs/securedrop-app-code | ||
securedrop_venv_bin: "{{ securedrop_venv }}/bin" | ||
securedrop_venv_site_packages: "{{ securedrop_venv }}/lib/python3.5/site-packages" | ||
securedrop_code: /var/www/securedrop | ||
securedrop_data: /var/lib/securedrop | ||
securedrop_user: www-data | ||
|
||
app_hostname: app-staging | ||
monitor_hostname: mon-staging | ||
|
||
apache_listening_address: 127.0.0.1 | ||
apache_source_log: /var/log/apache2/source-error.log | ||
apache_allow_from: 127.0.0.1 | ||
|
||
dns_server: | ||
- 8.8.8.8 | ||
- 8.8.4.4 | ||
mon_ip: 10.137.0.51 | ||
app_ip: 10.137.0.50 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In practice, do you reuse these IPv4 addresses between Xenial & Focal envs? I'm still figuring out what works for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Poking around in the IP-related logic specific to the Qubes staging env, found some dead code that should be removed:
If you agree, now's a good time to snip them out—and in the corresponding Focal locations, too. |
||
|
||
pip_deps: | ||
- name: 'Flask' | ||
version: '1.0.2' | ||
|
||
apparmor_complain: [] | ||
|
||
app_directories: | ||
- /var/www/securedrop | ||
- /var/lib/securedrop | ||
- /var/lib/securedrop/store | ||
- /var/lib/securedrop/keys | ||
- /var/lib/securedrop/tmp | ||
|
||
tor_services: | ||
- name: source | ||
ports: | ||
- "80" | ||
authenticated: no | ||
version: 2 | ||
|
||
- name: journalist | ||
ports: | ||
- "80" | ||
- "8080" | ||
authenticated: yes | ||
client: journalist | ||
version: 2 | ||
|
||
- name: journalistv3 | ||
ports: | ||
- "80" | ||
authenticated: yes | ||
version: 3 | ||
|
||
- name: sourcev3 | ||
ports: | ||
- "80" | ||
authenticated: no | ||
version: 3 | ||
|
||
# Staging permits presence of "source-error.log". | ||
allowed_apache_logfiles: | ||
- /var/log/apache2/access.log | ||
- /var/log/apache2/error.log | ||
- /var/log/apache2/journalist-access.log | ||
- /var/log/apache2/journalist-error.log | ||
- /var/log/apache2/other_vhosts_access.log | ||
- /var/log/apache2/source-error.log | ||
|
||
fpf_apt_repo_url: "https://apt-test.freedom.press" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The firewall rules template is duplicated in its entirety for just L18 & L19, which differ slightly from the existing staging rules:
Can you explain that difference? Inspecting the logic in the restrict-direct-access role, it's not immediately obvious to me why the qubes env would differ in the fw rules that land on the host.