diff options
author | Matt Riedemann <mriedem.os@gmail.com> | 2017-12-08 16:02:44 -0500 |
---|---|---|
committer | Matt Riedemann <mriedem.os@gmail.com> | 2018-02-27 10:16:00 -0500 |
commit | 1291d45418138d28f67873c6e47aa740e48ff80f (patch) | |
tree | d771fdf31e35f0307a2353664f9bffd8ac34aa21 | |
parent | b9391f7563089b1ca51991ed395a134378939b5b (diff) | |
download | nova-1291d45418138d28f67873c6e47aa740e48ff80f.tar.gz |
libvirt: mask InjectionInfo.admin_pass
Logging network information and the admin password
for guest instances is not ideal, so let's not do it.
Change-Id: I328ba88b128c6c125e65d850ed7a6e57049dc7e2
Closes-Bug: #1737207
(cherry picked from commit 6839630e86d958dcda8585664586754d419363a7)
(cherry picked from commit 088bf6df8ee332f1c24493430003a5bf1b77b2ce)
(cherry picked from commit 13b598d371e7d0a67a953a87666d2e6adbc38372)
-rwxr-xr-x | nova/tests/unit/virt/libvirt/test_driver.py | 8 | ||||
-rw-r--r-- | nova/virt/libvirt/driver.py | 10 |
2 files changed, 16 insertions, 2 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index db1a692801..64b97073f1 100755 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -10804,6 +10804,14 @@ class LibvirtConnTestCase(test.NoDBTestCase): ] self.assertEqual(wantFiles, gotFiles) + def test_injection_info_is_sanitized(self): + info = get_injection_info( + network_info=mock.sentinel.network_info, + files=mock.sentinel.files, + admin_pass='verybadpass') + self.assertNotIn('verybadpass', str(info)) + self.assertNotIn('verybadpass', repr(info)) + @mock.patch( 'nova.virt.libvirt.driver.LibvirtDriver._build_device_metadata') @mock.patch('nova.api.metadata.base.InstanceMetadata') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 2c56ea0269..25839e2b25 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -141,8 +141,14 @@ CONSOLE = "console=tty0 console=ttyS0" GuestNumaConfig = collections.namedtuple( 'GuestNumaConfig', ['cpuset', 'cputune', 'numaconfig', 'numatune']) -InjectionInfo = collections.namedtuple( - 'InjectionInfo', ['network_info', 'files', 'admin_pass']) + +class InjectionInfo(collections.namedtuple( + 'InjectionInfo', ['network_info', 'files', 'admin_pass'])): + __slots__ = () + + def __repr__(self): + return ('InjectionInfo(network_info=%r, files=%r, ' + 'admin_pass=<SANITIZED>)') % (self.network_info, self.files) libvirt_volume_drivers = [ 'iscsi=nova.virt.libvirt.volume.iscsi.LibvirtISCSIVolumeDriver', |