-
Notifications
You must be signed in to change notification settings - Fork 586
[cleaner] ignores hostnames in SSL certificates #4093
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
base: main
Are you sure you want to change the base?
Conversation
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
568d426
to
3474c83
Compare
sos/cleaner/__init__.py
Outdated
if self.opts.treat_certificates == "obfuscate": | ||
self.ui_log.warning( | ||
"WARNING: certificate files that potentially contain " | ||
"sensitive information will be CONVERTED to text and " | ||
"OBFUSCATED in the final archive.\n" | ||
) | ||
elif self.opts.treat_certificates == "keep": | ||
self.ui_log.warning( | ||
"WARNING: certificate files that potentially contain " | ||
"sensitive information will be KEPT in the final " | ||
"archive as is.\n" | ||
) | ||
elif self.opts.treat_certificates == "remove": | ||
self.ui_log.warning( | ||
"WARNING: certificate files that potentially contain " | ||
"sensitive information will be REMOVED in the final " | ||
"archive.\n" | ||
) |
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.
Just a thought / option to consider: do we really want a WARNING message (either one of those three) printed on every cleaner run?
sos/cleaner/__init__.py
Outdated
continue | ||
is_certificate = file_is_certificate(fname) | ||
if is_certificate: | ||
if is_certificate == "certificatekey": |
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.
In theory, key files should have been removed by report already. But surely they can remain also here, makes sense to remove them despite they dont usually contain any cleaner-sensitive data.
sos/cleaner/__init__.py
Outdated
archive.remove_file(short_name) | ||
continue | ||
if self.opts.treat_certificates == "keep": | ||
continue | ||
if self.opts.treat_certificates == "remove": | ||
archive.remove_file(short_name) |
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.
Originally, I thought we should put some debug message here "removing certificate file" or similar.
But a better approach is updating remove_file
method in sos/cleaner/archives/__init__.py
to have extra argument filetype=binary
and replace:
self.log_info(f"Removing binary file '{fname}' from archive")
to:
self.log_info(f"Removing {filetype} file '{fname}' from archive")
(and call the method from here with proper argument)
sos/cleaner/archives/__init__.py
Outdated
sos_get_command_output( | ||
f"openssl x509 -noout -text -in {str(fname)}", | ||
to_file=f"{fname}.text") | ||
shutil.move(f"{fname}.text", fname) |
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.
Just a thought / option to consider: should we keep original file's permissions and ownership? We are overwriting it here (which makes sense as well as we update the file content).
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.
My only hangup here is actually dropping the .text
suffix. I think if we're converting the cert file, then we should make that obvious, and I do like the idea of having a .text
(or .txt
if you prefer) appended to the filename.
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.
I agree here, this behaviour can be confusing ("does the pem file really contain just text content, or..?").
Maybe worth appending the new filename to the log "Converting certificate ..
above?
Gladly we do the change in cleaner and not in report where we would have to update filelist of collected files - here just removing the old file should be enough.
sos/cleaner/__init__.py
Outdated
clean_grp.add_argument('--treat-certificates', default='obfuscate', | ||
choices=['obfuscate', 'keep', 'remove'], | ||
dest='treat_certificates', | ||
help=('How to treat certificate files.' |
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.
nitpick: Extra dot at the end. Same applies on two equivalent places later on.
return "certificate" | ||
if re.search(r'-----BEGIN [A-Z]+ PRIVATE KEY-----', f.read()): | ||
return "certificatekey" | ||
return None |
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.
Just a thought / option to consider: isnt this return redundant?
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.
Yes, its is :) was added just to make lint happy
I added several comments. Those starting "Just a thought / option to consider:" are really "just a thought" and nothing else - in those cases I am OK with the current change but maybe others can see the mentioned option as a better one? |
The foreman tests failing is foreman infra issue: they have expired GPG key:
I am reporting this to the foreman team. |
I opened theforeman/foreman-infra#2280 for this. |
cb4ddde
to
7a1463f
Compare
3b5ee03
to
7a1463f
Compare
f3fa9f7
to
faab870
Compare
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.
ACK (up to the doubt about CodeQL warning).
Thanks Pablo for applying repetitive feedback! :)
@pmoravec all checks passed.
|
ee8f7f0
to
1c04560
Compare
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.
Ack up to my comment on the filename. I'd like to see us keep the .text
/.txt
, but willing to hear why that might not be a good idea.
sos/cleaner/archives/__init__.py
Outdated
sos_get_command_output( | ||
f"openssl x509 -noout -text -in {str(fname)}", | ||
to_file=f"{fname}.text") | ||
shutil.move(f"{fname}.text", fname) |
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.
My only hangup here is actually dropping the .text
suffix. I think if we're converting the cert file, then we should make that obvious, and I do like the idea of having a .text
(or .txt
if you prefer) appended to the filename.
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.
Sorry @pafernanr for yet another nitpick change requested. This slipped down among the reviews..
475e389
to
3c96a3c
Compare
Hi all, last commit behaves as you requested. |
sos/utilities.py
Outdated
:returns: The type of the certificate or ``None`` | ||
:rtype: ``string`` or ``None`` | ||
""" | ||
if fname[-4:] in [".csr", ".pem"]: |
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.
Can we check against .crt
suffix as well? E.g. various Satellite-related certificates (though afaik neither of them being collected by sos, in neither of plenty locations) have that suffix.
(tiny update: even sosreport from Satellite can contain ./etc/pki/pulp/qpid/ca.crt
until Qpid broker is deprecated in Sat)
Apart of the
|
4126e80
to
803e6fe
Compare
Signed-off-by: Pablo Fernández Rodríguez <[email protected]>
803e6fe
to
e506c7f
Compare
LGTM, however if you could please rebase on current |
Friendly reminder ping to please rebase on current |
748e8ad
to
e506c7f
Compare
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.
ACK, we just should drop the internal merge commit when we will do merge into upstream.
Refer to 3919
New
clean
argument added--treat-certificates
with next options:obfuscate_report
do its job.Notes:
openssl
is not available andobfuscate
is selected. It will be replaced byremove
after show a WARNING message.Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines