mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(virtsecrets): a secret in use is not deleted, and a password is stored as typed
- A secret is in use when a VM names it in a disk, a host device or its vTPM, or a pool in its source, by UUID or by its usage within the usage type, as they run and as saved. The vTPM, host devices and pools' saved definitions were not checked before. - A Ceph key is taken in base64, as `ceph auth get-key` prints it; any other value is a password or passphrase stored as typed, spaces included. - A new secret takes its value at once; a value refused leaves no secret. - TLS and vTPM secrets can be created; the usage has no length limit. - Every POST redirects; the list is read once and only with its users; a secret, VM or pool gone meanwhile is left out. - domain_trees() is shared by the in-use checks of secrets, network filters, networks and pools; the storage page's Ceph secret picker reads the same listing.
This commit is contained in:
parent
0014b5f240
commit
a95ec40f69
17 changed files with 429 additions and 249 deletions
|
|
@ -27,11 +27,11 @@ class SecretRowTests(TestCase):
|
|||
patcher = patch("virtsecrets.views.wvmSecrets")
|
||||
self.conn = patcher.start().return_value
|
||||
self.addCleanup(patcher.stop)
|
||||
self.conn.get_secrets.return_value = []
|
||||
self.conn.get_secrets_info.return_value = []
|
||||
|
||||
def test_secret_actions(self):
|
||||
self.client.post(self.url, {"create": "", "ephemeral": "no", "private": "yes", "usage_type": "ceph",
|
||||
"data": "client.admin"})
|
||||
self.client.post(self.url, {"create": "", "private": "on", "usage_type": "ceph", "usage": "client.admin",
|
||||
"value": VALUE})
|
||||
self.client.post(self.url, {"set_value": "", "uuid": UUID, "value": VALUE})
|
||||
self.client.post(self.url, {"delete": "", "uuid": UUID})
|
||||
self.assertEqual(rows(), [
|
||||
|
|
@ -42,9 +42,12 @@ class SecretRowTests(TestCase):
|
|||
self.assertEqual(set(Logs.objects.values_list("host", flat=True)), {"c1"})
|
||||
|
||||
def test_a_secret_value_is_never_logged(self):
|
||||
# an unexpected error naming the value is raised, its row names only the error's class
|
||||
self.conn.set_secret_value.side_effect = ValueError(f"bad value {VALUE}")
|
||||
self.client.post(self.url, {"set_value": "", "uuid": UUID, "value": VALUE})
|
||||
with self.assertRaises(ValueError):
|
||||
self.client.post(self.url, {"set_value": "", "uuid": UUID, "value": VALUE})
|
||||
self.assertEqual(rows(), [(f"Secret {UUID}: set value: ValueError", False)])
|
||||
self.conn.set_secret_value.side_effect = OperationError("A Ceph key is base64 text")
|
||||
with patch.object(Logs.objects, "create", side_effect=RuntimeError("db down")), \
|
||||
self.assertLogs("logs.audit", "WARNING") as logged:
|
||||
self.client.post(self.url, {"set_value": "", "uuid": UUID, "value": VALUE})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue