forked from sosreport/sos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apt] Obfuscate passwords for configs/sources
The configuration of apt was not being obfuscated if any of the URLs had a password; one example was the proxy. There is also a new format for the deb sources, so ensuring that would be obfuscated in the same way. Add some tests to ensure that this is always being obfuscated. Resolves: SET-732 Signed-off-by: Arif Ali <[email protected]>
- Loading branch information
1 parent
6a2845a
commit 91c7c54
Showing
5 changed files
with
65 additions
and
8 deletions.
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,3 @@ | ||
Acquire::http::proxy "http://username:[email protected]:80"; | ||
Acquire::https::proxy "http://username:[email protected]:80"; | ||
Acquire::ftp::proxy "http://username:[email protected]:80"; |
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 @@ | ||
deb http://username:[email protected]/ubuntu jammy main |
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,4 @@ | ||
Types: deb | ||
URIs: http://username:[email protected]/ubuntu | ||
Suites: jammy | ||
Components: main |
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,45 @@ | ||
# Copyright (C) 2024 Canonical Ltd., Arif Ali <[email protected]> | ||
# | ||
# This file is part of the sos project: https://github.com/sosreport/sos | ||
# | ||
# This copyrighted material is made available to anyone wishing to use, | ||
# modify, copy, or redistribute it subject to the terms and conditions of | ||
# version 2 of the GNU General Public License. | ||
# | ||
# See the LICENSE file in the source distribution for further information. | ||
|
||
from sos_tests import StageTwoReportTest | ||
|
||
|
||
class AptConfScrubTest(StageTwoReportTest): | ||
"""Ensure that sources.list and apt conf are picked up and properly | ||
scrubbed | ||
:avocado: tags=stagetwo | ||
""" | ||
|
||
sos_cmd = '-o apt' | ||
ubuntu_only = True | ||
files = [ | ||
('apt-proxy.conf', '/etc/apt/apt.conf.d/50-apt-proxy'), | ||
('apt-sources.list', '/etc/apt/sources.list'), | ||
('apt-sources.sources', '/etc/apt/sources.list.d/ubuntu.sources'), | ||
] | ||
|
||
def test_apt_sources_and_apt_confs_collected(self): | ||
self.assertFileCollected('/etc/apt/apt.conf.d/50-apt-proxy') | ||
self.assertFileCollected('/etc/apt/sources.list') | ||
self.assertFileCollected('/etc/apt/ubuntu.sources') | ||
|
||
def test_apt_sources_and_proxy_scrubbed(self): | ||
# Ensure that we scrubbed all passwords | ||
files_to_check = [ | ||
'/etc/apt/apt.conf.d/50-apt-proxy', | ||
'/etc/apt/sources.list', | ||
'/etc/apt/sources.list.d/ubuntu.sources', | ||
] | ||
password = 'somesecretpassword' | ||
for file in files_to_check: | ||
self.assertFileNotHasContent(file, password) | ||
|
||
# vim: set et ts=4 sw=4 : |