2023-11-13 09:33:28 -05:00
|
|
|
{#
|
2024-01-12 11:56:28 -05:00
|
|
|
SPDX-FileCopyrightText: 2022 Thien Tran <contact@tommytran.io>
|
2023-11-13 13:18:06 -05:00
|
|
|
SPDX-FileCopyrightText: 2023 unman <unman@thirdeyesecurity.org>
|
2024-01-29 10:49:54 -05:00
|
|
|
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
2023-11-13 09:33:28 -05:00
|
|
|
|
2024-01-12 11:56:28 -05:00
|
|
|
SPDX-License-Identifier: MIT
|
2023-11-13 09:33:28 -05:00
|
|
|
#}
|
|
|
|
|
|
|
|
{%- from "qvm/template.jinja" import load -%}
|
|
|
|
|
2024-05-10 20:54:52 -04:00
|
|
|
{% set mirage_version = 'v0.9.1' -%}
|
2024-03-19 12:19:54 -04:00
|
|
|
{% set mirage_file_archive = 'mirage-firewall.tar.bz2' -%}
|
|
|
|
{% set mirage_url_archive = 'https://github.com/mirage/qubes-mirage-firewall/releases/download/' ~ mirage_version ~ '/' ~ mirage_file_archive -%}
|
2024-05-10 20:54:52 -04:00
|
|
|
{% set mirage_sha256sum = 'ea876bc7525811a16b0dfebe7ee1e91661eeecf67d240298d4ffd31b6ee41843' %}
|
2024-03-19 12:19:54 -04:00
|
|
|
|
2023-11-13 09:33:28 -05:00
|
|
|
{# Use the netvm of the default_netvm. #}
|
|
|
|
{% set default_netvm = salt['cmd.shell']('qubes-prefs default_netvm') -%}
|
|
|
|
{% set netvm = salt['cmd.shell']('qvm-prefs ' + default_netvm + ' netvm') -%}
|
|
|
|
{#
|
|
|
|
If netvm of default_netvm is empty, user's default_netvm is the first in
|
|
|
|
the chain (sys-net).
|
|
|
|
#}
|
|
|
|
{% if netvm == '' %}
|
|
|
|
{% set netvm = default_netvm %}
|
|
|
|
{% endif %}
|
|
|
|
|
2024-03-19 12:19:54 -04:00
|
|
|
{# The 'updatevm' has networking and 'curl' present. #}
|
|
|
|
{% set updatevm = salt['cmd.shell']('qubes-prefs updatevm') %}
|
|
|
|
|
|
|
|
"sys-mirage-firewall-start-updatevm-{{ updatevm }}":
|
|
|
|
qvm.start:
|
|
|
|
- name: {{ updatevm }}
|
|
|
|
|
|
|
|
"sys-mirage-firewall-fetch-tarball":
|
|
|
|
cmd.run:
|
|
|
|
- require:
|
|
|
|
- qvm: "sys-mirage-firewall-start-updatevm-{{ updatevm }}"
|
|
|
|
- name: |
|
|
|
|
qvm-run {{ updatevm }} -- "
|
|
|
|
mkdir -p /tmp/mirage-firewall-download
|
|
|
|
cd /tmp/mirage-firewall-download
|
|
|
|
curl --location \
|
|
|
|
--connect-timeout 10 \
|
|
|
|
--tlsv1.3 --proto =https \
|
|
|
|
--fail --fail-early \
|
|
|
|
--no-progress-meter --silent --show-error \
|
|
|
|
--remote-name {{ mirage_url_archive }}"
|
|
|
|
- timeout: 30
|
|
|
|
- runas: user
|
|
|
|
|
|
|
|
{# Tarball is brought to dom0 instead of just 'vmlinuz' because:
|
|
|
|
- checksum on releases is only of the tarball, not of individual files;
|
|
|
|
- updatevm may not have 'bzip2' and 'tar';
|
|
|
|
- if we don't trust the provided tarball, we shouldn't even download it.
|
|
|
|
#}
|
|
|
|
"sys-mirage-firewall-bring-tarball-to-dom0":
|
|
|
|
cmd.run:
|
|
|
|
- require:
|
|
|
|
- cmd: "sys-mirage-firewall-fetch-tarball"
|
|
|
|
- name:
|
|
|
|
qvm-run --pass-io {{ updatevm }} -- "cat /tmp/mirage-firewall-download/mirage-firewall.tar.bz2" | tee /tmp/mirage-firewall.tar.bz2 >/dev/null
|
|
|
|
- runas: user
|
|
|
|
- timeout: 10
|
|
|
|
|
|
|
|
"{{ slsdotpath }}-remove-tarball-from-updatevm":
|
|
|
|
cmd.run:
|
|
|
|
- name: qvm-run {{ updatevm }} -- "rm -rf /tmp/mirage-firewall-download"
|
2023-11-13 09:33:28 -05:00
|
|
|
|
|
|
|
"sys-mirage-firewall-extract-to-vm-kernels":
|
|
|
|
archive.extracted:
|
|
|
|
- require:
|
2024-03-19 12:19:54 -04:00
|
|
|
- cmd: "sys-mirage-firewall-bring-tarball-to-dom0"
|
|
|
|
- name: /var/lib/qubes/vm-kernels/
|
|
|
|
- source: /tmp/mirage-firewall.tar.bz2
|
|
|
|
- source_hash: sha256={{ mirage_sha256sum }}
|
2023-11-13 09:33:28 -05:00
|
|
|
- archive_format: tar
|
|
|
|
- options: -j
|
|
|
|
|
2024-03-19 12:19:54 -04:00
|
|
|
"{{ slsdotpath }}-dom0-archive":
|
|
|
|
file.absent:
|
|
|
|
- name: /tmp/mirage-firewall.tar.bz2
|
|
|
|
|
2023-11-13 09:33:28 -05:00
|
|
|
"sys-mirage-firewall-save-version":
|
|
|
|
file.managed:
|
2024-03-19 12:19:54 -04:00
|
|
|
- require:
|
|
|
|
- archive: "sys-mirage-firewall-extract-to-vm-kernels"
|
2023-11-13 09:33:28 -05:00
|
|
|
- name: /var/lib/qubes/vm-kernels/mirage-firewall/version.txt
|
2024-03-19 12:19:54 -04:00
|
|
|
- contents: {{ mirage_version }}
|
2023-11-13 09:33:28 -05:00
|
|
|
- mode: '0644'
|
|
|
|
- user: root
|
|
|
|
- group: root
|
|
|
|
- makedirs: True
|
|
|
|
|
|
|
|
{% load_yaml as defaults -%}
|
2024-01-12 11:56:28 -05:00
|
|
|
name: tpl-sys-mirage-firewall
|
2023-11-13 09:33:28 -05:00
|
|
|
force: True
|
|
|
|
require:
|
2024-01-12 11:56:28 -05:00
|
|
|
- file: sys-mirage-firewall-save-version
|
2023-11-13 09:33:28 -05:00
|
|
|
present:
|
2024-01-12 11:56:28 -05:00
|
|
|
- class: TemplateVM
|
|
|
|
- label: black
|
|
|
|
prefs:
|
2023-11-13 09:33:28 -05:00
|
|
|
- virt_mode: pvh
|
2024-01-12 11:56:28 -05:00
|
|
|
- label: black
|
2024-01-20 13:34:39 -05:00
|
|
|
- audiovm: ""
|
2024-01-12 11:56:28 -05:00
|
|
|
- memory: 64
|
|
|
|
- maxmem: 64
|
|
|
|
- vcpus: 1
|
|
|
|
- kernel: mirage-firewall
|
|
|
|
- kernelopts: ""
|
2024-01-31 09:50:35 -05:00
|
|
|
- include_in_backups: False
|
2024-01-12 11:56:28 -05:00
|
|
|
{%- endload %}
|
|
|
|
{{ load(defaults) }}
|
|
|
|
|
|
|
|
{% load_yaml as defaults -%}
|
|
|
|
name: dvm-sys-mirage-firewall
|
|
|
|
force: True
|
|
|
|
require:
|
|
|
|
- qvm: tpl-sys-mirage-firewall
|
|
|
|
present:
|
|
|
|
- template: tpl-sys-mirage-firewall
|
|
|
|
- label: orange
|
2023-11-13 09:33:28 -05:00
|
|
|
prefs:
|
2024-01-12 11:56:28 -05:00
|
|
|
- template: tpl-sys-mirage-firewall
|
|
|
|
- label: orange
|
|
|
|
- netvm: {{ netvm }}
|
2024-01-20 13:34:39 -05:00
|
|
|
- audiovm: ""
|
2024-01-12 11:56:28 -05:00
|
|
|
- memory: 64
|
|
|
|
- maxmem: 64
|
|
|
|
- vcpus: 1
|
|
|
|
- provides-network: True
|
|
|
|
- template_for_dispvms: True
|
2024-01-31 09:50:35 -05:00
|
|
|
- include_in_backups: False
|
2024-01-12 11:56:28 -05:00
|
|
|
features:
|
|
|
|
- enable:
|
|
|
|
- service.qubes-firewall
|
|
|
|
- no-default-kernelopts
|
|
|
|
{%- endload %}
|
|
|
|
{{ load(defaults) }}
|
|
|
|
|
|
|
|
{% load_yaml as defaults -%}
|
|
|
|
name: disp-sys-mirage-firewall
|
|
|
|
force: True
|
|
|
|
require:
|
|
|
|
- qvm: tpl-sys-mirage-firewall
|
|
|
|
present:
|
|
|
|
- class: DispVM
|
|
|
|
- template: dvm-sys-mirage-firewall
|
|
|
|
- label: orange
|
|
|
|
prefs:
|
|
|
|
- template: dvm-sys-mirage-firewall
|
2023-11-13 09:33:28 -05:00
|
|
|
- label: orange
|
|
|
|
- netvm: {{ netvm }}
|
2024-01-20 13:34:39 -05:00
|
|
|
- audiovm: ""
|
2023-11-13 09:33:28 -05:00
|
|
|
- memory: 64
|
|
|
|
- maxmem: 64
|
|
|
|
- vcpus: 1
|
|
|
|
- provides-network: True
|
2024-01-31 09:50:35 -05:00
|
|
|
- include_in_backups: False
|
2023-11-13 09:33:28 -05:00
|
|
|
features:
|
|
|
|
- enable:
|
|
|
|
- service.qubes-firewall
|
|
|
|
- no-default-kernelopts
|
|
|
|
{%- endload %}
|
|
|
|
{{ load(defaults) }}
|