-
Notifications
You must be signed in to change notification settings - Fork 46
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
Restrict and test and qubes-rpc policies for dom0 #187
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: set syntax=yaml ts=2 sw=2 sts=2 et : | ||
## | ||
# Explicitly deny as a catch-all for SecureDrop workstation provisioned VMs. | ||
# All SecureDrop-workstation provisioned VMS should have the sd-workstation tag. | ||
# To be both be mindful of developers using the workstation and ensure | ||
# RPC policies are not too permissive, this should be the first action | ||
# performed by the install. All other provisioning steps will prepend to this | ||
# list grants. | ||
# using blockreplace will ensure that we will be able to more reliably update | ||
# these policies during updates. | ||
## | ||
dom0-rpc-qubes.ClipboardPaste: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.ClipboardPaste | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm sd-journalist ask | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.FeaturesRequest: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.FeaturesRequest | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.Filecopy: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.Filecopy | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
sd-journalist sd-svs allow | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.OpenInVM: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.OpenInVM | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
sd-journalist sd-svs allow | ||
$tag:sd-svs-disp-vm sd-svs allow | ||
sd-svs $dispvm:sd-svs-disp allow | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.OpenURL: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.OpenURL | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.PdfConvert: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.PdfConvert | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.StartApp: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.StartApp | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.USB: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.USB | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.VMRootShell: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.VMRootShell | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.VMshell: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.VMShell | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.Gpg: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.Gpg | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
sd-svs sd-gpg allow | ||
$anyvm $tag:sd-workstation deny | ||
dom0-rpc-qubes.GpgImportKey: | ||
file.blockreplace: | ||
- name: /etc/qubes-rpc/policy/qubes.GpgImportKey | ||
- prepend_if_not_found: True | ||
- marker_start: "### BEGIN securedrop-workstation ###" | ||
- marker_end: "### END securedrop-workstation ###" | ||
- content: | | ||
$anyvm $tag:sd-workstation deny |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 : | ||
|
||
base: | ||
dom0: | ||
- sd-dom0-qvm-rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,6 @@ sd-gpg: | |
- label: purple | ||
- prefs: | ||
- netvm: "" | ||
- tags: | ||
- add: | ||
- sd-workstation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ sd-workstation-template: | |
- prefs: | ||
- virt-mode: hvm | ||
- kernel: '' | ||
- tags: | ||
- add: | ||
- sd-workstation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import io | ||
import os | ||
import unittest | ||
import yaml | ||
|
||
QUBES_POLICY_PREFIX = "/etc/qubes-rpc/policy/qubes." | ||
|
||
|
||
class SD_Qubes_Rpc_Tests(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.expected = self._loadVars() | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_Policies(self): | ||
# Using a for loop instead of pytest.parametrize due to | ||
# the absence of pytest in dom0. | ||
fail = False | ||
for policy in self.expected: | ||
if not self._startsWith(policy['policy'], | ||
policy['starts_with']): | ||
fail = True | ||
self.assertFalse(fail) | ||
|
||
def _startsWith(self, filename, expectedPolicy): | ||
filePath = os.path.join(QUBES_POLICY_PREFIX + filename) | ||
with io.open(filePath, 'r') as f: | ||
actualPolicy = f.read() | ||
if actualPolicy.startswith(expectedPolicy): | ||
return True | ||
else: | ||
print("\n\n#### BEGIN RPC policy error report ####\n\n") | ||
print("Policy for {} is:\n{}".format(filename, | ||
actualPolicy)) | ||
print("Policy for {} should be:\n{}".format(filename, | ||
expectedPolicy)) | ||
print("\n\n#### END RPC policy error report ####\n\n") | ||
return False | ||
|
||
def _loadVars(self): | ||
filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
"vars", "qubes-rpc.yml") | ||
with io.open(filepath, 'r') as f: | ||
data = yaml.safe_load(f) | ||
return data | ||
|
||
|
||
def load_tests(loader, tests, pattern): | ||
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Qubes_Rpc_Tests) | ||
return suite |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit: more aggressive output would be helpful here for when the policies fail. Consider adding more newlines and header blocks like: