Skip to content
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

Install securedrop-log and setup #447

Merged
merged 5 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sd-app: prep-salt ## Provisions SD APP VM

sd-whonix: prep-salt ## Provisions SD Whonix VM
sudo qubesctl --show-output state.sls sd-whonix
sudo qubesctl --show-output --skip-dom0 --targets sd-whonix-buster-template,sd-whonix state.highstate
sudo qubesctl --show-output --skip-dom0 --targets whonix-gw-15,sd-whonix state.highstate
emkll marked this conversation as resolved.
Show resolved Hide resolved

sd-viewer: prep-salt ## Provisions SD Submission Viewing VM
sudo qubesctl --show-output state.sls sd-viewer
Expand Down Expand Up @@ -111,9 +111,11 @@ remove-sd-log: assert-dom0 ## Destroys SD logging VM
@./scripts/destroy-vm sd-log

clean: assert-dom0 prep-salt ## Destroys all SD VMs
sudo qubesctl --show-output state.sls sd-clean-default-dispvm
$(MAKE) destroy-all
sudo qubesctl --show-output --skip-dom0 --targets whonix-gw-15 state.sls sd-clean-whonix
sudo qubesctl --show-output state.sls sd-clean-all
sudo dnf -y -q remove securedrop-workstation-dom0-config 2>/dev/null || true
$(MAKE) destroy-all
$(MAKE) clean-salt

test: assert-dom0 ## Runs all application tests (no integration tests yet)
Expand Down
12 changes: 11 additions & 1 deletion dom0/sd-app-files.sls
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ include:
- fpf-apt-test-repo

# FPF repo is setup in "securedrop-workstation" template
install-securedrop-client-package:
install-securedrop-client-and-securedrop-log-package:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

pkg.installed:
- pkgs:
- securedrop-client
- securedrop-log
emkll marked this conversation as resolved.
Show resolved Hide resolved
- require:
- sls: fpf-apt-test-repo


sd-rsyslog-for-sd-app:
emkll marked this conversation as resolved.
Show resolved Hide resolved
file.managed:
- name: /etc/sd-rsyslog.conf
- source: "salt://sd-rsyslog.conf.j2"
- template: jinja
- context:
vmname: sd-app
1 change: 1 addition & 0 deletions dom0/sd-clean-all.sls
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set-fedora-as-default-dispvm:
include:
- sd-usb-autoattach-remove


remove-dom0-sdw-config-files:
file.absent:
- names:
Expand Down
6 changes: 6 additions & 0 deletions dom0/sd-clean-default-dispvm.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :

set-fedora-as-default-dispvm:
cmd.run:
- name: qvm-check fedora-30-dvm && qubes-prefs default_dispvm fedora-30-dvm || qubes-prefs default_dispvm ''
20 changes: 20 additions & 0 deletions dom0/sd-clean-whonix.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :

##
# removes securedrop-log rsyslog plugin in whonix-gw-15
##

remove-securedrop-log-package-from-whonix:
pkg.removed:
- pkgs:
- securedrop-log

sd-cleanup-whonix-gw-15:
cmd.run:
- names:
- sudo rm -f /etc/rsyslog.d/sdlog.conf
- sudo rm -f /etc/apt/sources.list.d/securedrop_workstation.list
- sudo systemctl restart rsyslog
- sudo apt-key del 4ED79CC3362D7D12837046024A3BE4A92211B03C
- sudo apt-key del 22245C81E3BAEB4138B36061310F561200F4AD77
16 changes: 16 additions & 0 deletions dom0/sd-devices-files.sls
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ sd-devices-install-libreoffice:
sd-devices-install-package:
pkg.installed:
- name: securedrop-export


sd-devices-install-securedrop-log-package:
pkg.installed:
- pkgs:
- securedrop-log
- require:
- sls: fpf-apt-test-repo

sd-rsyslog-for-sd-devices:
file.managed:
- name: /etc/sd-rsyslog.conf
- source: "salt://sd-rsyslog.conf.j2"
- template: jinja
- context:
vmname: sd-devices
12 changes: 11 additions & 1 deletion dom0/sd-log-template-files.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
include:
- fpf-apt-test-repo

install-securedrop-log-package:
sd-log-install-securedrop-log-package:
pkg.installed:
- pkgs:
- redis-server
- redis
- securedrop-log
- require:
- sls: fpf-apt-test-repo

redis:
service.running:
- enable: True

securedrop-log:
service.running:
- enable: True
8 changes: 8 additions & 0 deletions dom0/sd-log.sls
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ sd-log-private-volume-size:
qvm-volume resize sd-log:private {{ d.vmsizes.sd_log }}GiB
- require:
- qvm: sd-log

# Permit the SecureDrop Proxy to manage Client connections
sd-dom-dom0-securedrop.Log:
file.prepend:
- name: /etc/qubes-rpc/policy/securedrop.Log
- text: |
@tag:sd-workstation sd-log allow
@anyvm @anyvm deny
12 changes: 11 additions & 1 deletion dom0/sd-proxy-template-files.sls
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ sd-proxy-configure-mimetypes:

# Depends on FPF-controlled apt repo, already present
# in underlying "securedrop-workstation" base template.
install-securedrop-proxy-package:
install-securedrop-proxy-and-securedrop-log-package:
pkg.installed:
- pkgs:
- securedrop-proxy
- securedrop-log
- require:
- sls: fpf-apt-test-repo


{% import_json "sd/config.json" as d %}

install-securedrop-proxy-yaml-config:
Expand All @@ -58,3 +60,11 @@ install-securedrop-proxy-yaml-config:
- context:
hostname: {{ d.hidserv.hostname }}
- mode: 0644

sd-rsyslog-for-sd-proxy:
file.managed:
- name: /etc/sd-rsyslog.conf
- source: "salt://sd-rsyslog.conf.j2"
- template: jinja
- context:
vmname: sd-proxy
3 changes: 3 additions & 0 deletions dom0/sd-rsyslog.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[sd-rsyslog]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 templating

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Templating definitely good. We might be able to use grains["localhost"] to get the VM name, rather than passing in context every time. (See output of e.g. sudo qubesctl --skip-dom0 --show-output --target sys-firewall grains.items.) If that works, we could stick the tasks for 1) install pkg; 2) configure rsyslog in a single state file and include it, reducing a lot of duplication.

remotevm = sd-log
localvm = {{ vmname }}
15 changes: 15 additions & 0 deletions dom0/sd-viewer-files.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,18 @@ sd-viewer-install-libreoffice:
attempts: 3
interval: 60
- install_recommends: False

sd-viewer-install-logging:
pkg.installed:
- pkgs:
- securedrop-log
- require:
- sls: fpf-apt-test-repo

sd-rsyslog-for-sd-viewer:
file.managed:
- name: /etc/sd-rsyslog.conf
- source: "salt://sd-rsyslog.conf.j2"
- template: jinja
- context:
vmname: sd-viewer
43 changes: 43 additions & 0 deletions dom0/sd-whonix-rsyslog-enable.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :

##
# Enables securedrop-log rsyslog plugin in sd-whonix
##

sd-rsyslog-for-sd-whonix:
file.managed:
- name: /rw/config/sd-rsyslog.conf
- source: "salt://sd-rsyslog.conf.j2"
- template: jinja
- context:
vmname: sd-whonix


# We can not place the file on the template under /etc/rsyslog.d/ because of whonix
# template. This sdlog.conf file is the same from the securedrop-log package, to
# make sure that rsyslogd use our logging plugin.
sd-rsyslog-sdlog-conf-for-sd-whonix:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment here, for future maintainers, as to why this is required here and not in other VMs, where this file is handled by the sd-log package: https://github.com/freedomofpress/securedrop-log/blob/d1799b2477f4250eae43b472472df19a49f5cb75/sdlog.conf

file.managed:
- name: /rw/config/sdlog.conf
- source: "salt://sdlog.conf"

# Because whonix-gw-15 template is not allowing to create the config file on
# package install time, we do it via rc.local call.
sd-rc-enable-logging:
file.blockreplace:
- name: /rw/config/rc.local
- append_if_not_found: True
- marker_start: "### BEGIN securedrop-workstation ###"
- marker_end: "### END securedrop-workstation ###"
- content: |
# Add sd-rsyslog.conf file for syslog
ln -sf /rw/config/sd-rsyslog.conf /etc/sd-rsyslog.conf
if [ ! -f /etc/rsyslog.d/sdlog.conf ]; then
ln -sf /rw/config/sdlog.conf /etc/rsyslog.d/sdlog.conf
fi
systemctl restart rsyslog
cmd.run:
- name: ln -sf /rw/config/sd-rsyslog.conf /etc/sd-rsyslog.conf && systemctl restart rsyslog


22 changes: 22 additions & 0 deletions dom0/sd-whonix-template-files.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
emkll marked this conversation as resolved.
Show resolved Hide resolved
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :

##
# sd-whonix-template-files
# ========
#
# Installs configuration packages specific to the sd-whonix
# used for network calls.
#
##

include:
- fpf-apt-test-repo

sd-whonix-install-logging:
pkg.installed:
- pkgs:
- securedrop-log
- require:
- sls: fpf-apt-test-repo

8 changes: 8 additions & 0 deletions dom0/sd-workstation-template-files.sls
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ sd-workstation-template-install-kernel-config-packages:
- require:
- sls: fpf-apt-test-repo


sd-workstation-install-securedrop-log-package:
emkll marked this conversation as resolved.
Show resolved Hide resolved
pkg.installed:
- pkgs:
- securedrop-log
- require:
- sls: fpf-apt-test-repo

# Ensure that paxctld starts immediately. For AppVMs,
# use qvm.features.enabled = ["paxctld"] to ensure service start.
sd-workstation-template-enable-paxctld:
Expand Down
10 changes: 7 additions & 3 deletions dom0/sd-workstation.top
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ base:
- sd-upgrade-templates
- sd-dom0-qvm-rpc
- sd-sys-whonix-vms
- sd-log
- sd-devices
- sd-gpg
- sd-proxy
- sd-viewer
- sd-app
- sd-whonix
- sd-remove-unused-templates
- sd-log

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: empty line

sd-log-buster-template:
emkll marked this conversation as resolved.
Show resolved Hide resolved
- sd-log-template-files
sd-devices-buster-template:
- sd-devices-files
sd-gpg:
Expand All @@ -34,12 +37,13 @@ base:
- sd-sys-firewall-files
sd-whonix:
- sd-whonix-hidserv-key
sd-log-buster-template:
- sd-log-template-files
- sd-whonix-rsyslog-enable
securedrop-workstation-buster:
- sd-workstation-template-files
sys-usb:
- sd-usb-autoattach-add
whonix-gw-15:
emkll marked this conversation as resolved.
Show resolved Hide resolved
- sd-whonix-template-files

# "Placeholder" config to trigger TemplateVM boots,
# so upgrades can be applied automatically via cron.
Expand Down
4 changes: 4 additions & 0 deletions dom0/sdlog.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module(load="omprog")
action(type="omprog"
binary="/usr/sbin/sd-rsyslog"
template="RSYSLOG_TraditionalFileFormat")
7 changes: 7 additions & 0 deletions scripts/provision-all
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ sudo qubesctl --show-output --skip-dom0 --targets sys-firewall state.sls sd-sys-
echo "Set up dom0 config files, including RPC policies, and create VMs"
sudo qubesctl --show-output state.highstate

echo "Setup sd-log-buster-template vm first"
sudo qubesctl --show-output --skip-dom0 --targets sd-log-buster-template state.highstate
# Provision whonix-gw-15 with log additions because it isn't tagged with sd-workstation (we don't want it removed after a make clean)
sudo qubesctl --show-output --skip-dom0 --targets whonix-gw-15 state.highstate
#sudo qubesctl --show-output --skip-dom0 --targets whonix-gw-15 state.sls sd-whonix-template-files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: commented out instead of deleted, might lead to confusion

qvm-shutdown --wait whonix-gw-15

# Format list of all VMs comma-separated, for use as qubesctl target
# We run this after dom0's highstate, so that the VMs are available for listing by tag.
all_sdw_vms_target="$(qvm-ls --tags sd-workstation --raw-list | perl -npE 's/\n/,/g' | perl -npE 's/,$//' )"
Expand Down
16 changes: 16 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,19 @@ def _fileExists(self, remote_path):
return False

return True

def logging_configured(self, vmname=""):
"""
Make sure rsyslog is configured to send in data to sd-log vm.
"""
if not vmname:
vmname = self.vm_name
self.assertTrue(self._fileExists("/etc/sd-rsyslog.conf"))
# Then we check the configuration inside of the file.
file_content = self._get_file_contents("/etc/sd-rsyslog.conf")
static_content = """[sd-rsyslog]
remotevm = sd-log
localvm = {0}
""".format(vmname)
self.assertEqual(file_content, static_content)
self.assertTrue(self._package_is_installed("securedrop-log"))
3 changes: 3 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def test_sd_client_apparmor(self):
results = json.loads(self._run(cmd))
self.assertTrue(results['profiles']['/usr/bin/securedrop-client'] == "enforce")

def test_logging_configured(self):
self.logging_configured()


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_App_Tests)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_proxy_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def test_whonix_ws_repo_enabled(self):
"""
assert self._fileExists(self.whonix_apt_list)

def test_logging_configured(self):
self.logging_configured()


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Proxy_Tests)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sd_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def test_sd_export_package_installed(self):
self.assertTrue(self._package_is_installed("printer-driver-brlaser"))
self.assertTrue(self._package_is_installed("securedrop-export"))

def test_logging_configured(self):
self.logging_configured(vmname="sd-devices")


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Devices_Tests)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sd_whonix.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def test_sd_whonix_repo_enabled(self):
"""
assert self._fileExists(self.whonix_apt_list)

def test_logging_configured(self):
self.logging_configured()


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Whonix_Tests)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def test_sd_viewer_evince_installed(self):
def test_sd_viewer_libreoffice_installed(self):
self.assertTrue(self._package_is_installed("libreoffice"))

def test_logging_configured(self):
self.logging_configured()


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Viewer_Tests)
Expand Down
Loading