-
Notifications
You must be signed in to change notification settings - Fork 548
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
[canonical-livepatch-onprem] Add Canonical Livepatch on-prem server support #3418
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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.report.plugins import Plugin, UbuntuPlugin | ||
|
||
|
||
class CanonicaLivepatchOnprem(Plugin, UbuntuPlugin): | ||
|
||
short_desc = 'Canonical Livepatch Onprem Service' | ||
|
||
plugin_name = 'canonical_livepatch_onprem' | ||
profiles = ('services',) | ||
services = ("livepatch-server",) | ||
|
||
def setup(self): | ||
self.add_copy_spec([ | ||
"/etc/livepatchd.yaml", | ||
]) | ||
|
||
def postproc(self): | ||
onprem_conf = "/etc/livepatchd.yaml" | ||
protect_keys = [ | ||
"username", | ||
"password", | ||
"token", | ||
"connection_string", | ||
] | ||
|
||
# Redact simple yaml style "key: value". | ||
keys_regex = r"(^(-|\s)*(%s)\s*:\s*)(.*)" % "|".join(protect_keys) | ||
sub_regex = r"\1*********" | ||
self.do_path_regex_sub(onprem_conf, keys_regex, sub_regex) | ||
|
||
# Redact conf | ||
self.do_file_private_sub(onprem_conf) | ||
|
||
# vim: set et ts=4 sw=4 : |
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.
lgtm, just a question: is there an api token or a user/pass we should obfuscate in this file?
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.
There are both, actually - user credentials and a token that authenticates against upstream livepatch.. User password is already encoded, but perhaps not a bad idea to obfuscate. Is that something we'd do in the plugin directly, or elsewhere in sos?
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.
You can do it directly in the plugin itself. Here's an example of obfuscation in a yaml file:
https://github.com/sosreport/sos/blob/main/sos/report/plugins/juju.py#L65
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.
Awesome, thanks for the link! I have some obfuscation code in now that looks like it's having the intended effect 🙂 I'll push once I get the simplification that Arif mentioned sorted out.