Skip to content

Conversation

@dwolstroRH
Copy link
Contributor

Related: RHEL-2356


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname email@example.com?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?
  • Are all passwords or private data gathered by this PR obfuscated?

'upload_target': None,
'add_preset': '',
'del_preset': '',
<<<<<<< Updated upstream
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is one of the issues causing the pylint error. You just need to resolve the conflict with the stashed changes and force push again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed.

"""
Determines the correct authenticated HTTP proxy syntax for the local
Netcat/Ncat executable by running test commands.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add here (or perhaps as a comment in the gh PR interface) why do we need to determine the syntax?
And what happens if we don't have this function at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add in a more verbose comment to try to explain why we use this function and why (I think) it's needed. Basically, if we don't have this function, only certain versions of ncat/nc will work correctly with the proxy command. This function tries to figure out the correct syntax of the proxy command needed based on the installed version of ncat/nc

@jcastill
Copy link
Member

Make sure you add these options to any relevant man page (at least the upload and report ones).

raise Exception("connection failed, did you set a user and "
"password?")
raise Exception("connection failed, did you set a user"
" and password?")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this specific change? Unless I'm mistaken, the original line was within col limit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly have no idea why I updated that. I can change it back if you want me to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, I just wasn't sure if I missed something. Doesn't look bad to me, so unless anyone else objects, this change can be kept

@packit-as-a-service
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-4158
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

# --- 3. Fallback (If no standard syntax is found) ---
# If the system netcat doesn't support an authenticated proxy,
# you might need to use a dedicated tool like 'corkscrew' or 'connect'.
return ("Warning: Native authenticated proxy syntax not found for 'nc'. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: replace nc by {nc_executable} (and have it as an f-string)?

Currently, you call the method with default nc_executable='nc' only. If you plan this argumet to have different values in future, let be prepared here.

Comment on lines +368 to +380
proxy_grp.add_argument('--proxy-user',
default=None,
help='Specify the User for the proxy server')
proxy_grp.add_argument('--proxy-pass',
default=None,
help='Specify the Password for the proxy user')
proxy_grp.add_argument('--proxy-host',
default=None,
help='Specify the host for the proxy server')
proxy_grp.add_argument('--proxy-port',
default=None,
help='Specify the Port for the proxy server')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to enhance man pages accordingly.

When you will describe --proxy-pass, it is worth mentioning that using the option on cmdline reveals the password to anybody running ps at the same time.

Comment on lines +272 to +277
if self.get_proxy_host():
self.generate_proxy_list(use_prompts=True)
self.ui_log.info('')
else:
if self.get_proxy_host():
self.generate_proxy_list(use_prompts=False)
Copy link
Contributor

@pmoravec pmoravec Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code de-duplication: isnt it better to call (after the if not cmdline_opts.batch .. block):

if self.get_proxy_host():
    self.generate_proxy_list(use_prompts=(not cmdline_opts.batch and not cmdline_opts.quiet))

?

Well, then the log_info of empty line would be entered before the prompt, not welcomed, I guess?

Comment on lines +962 to +964
self.ui_log.error(
"Both proxy user and proxy password must be"
" specified. Proxy server will be ignored."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I enter empty user and password? That should be allowed, no..?

return {}

if self.get_proxy_host() and self.get_proxy_port():
proxy = (f"{proxy}{self.get_proxy_host()}:"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So proxy stores just credentials so far, which is bit confusing. Worth adding a comment or having proxy_creds variable (up to this point)?

(also a nitpick, you can ignore this comment if you think the code is self-explanatory)

proxy = (f"{proxy}{self.get_proxy_host()}:"
f"{self.get_proxy_port()}")
proxy_list['http'] = f"http://{proxy}"
proxy_list['https'] = f"http://{proxy}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt be there https:// instead of http://? (but I am not an expert on the syntax here..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! thanks

Copy link
Member

@arif-ali arif-ali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primarily around if we don't have a user/password, but just a proxy, we should be able to use the proxy on its own

try:
session = ftplib.FTP(url, user, password, timeout=15)
if self.use_proxy_server:
proxy_formatted_user = f"{user}@{url} {self.proxy_user}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a user and password is not provided, and is actually not needed for the proxy. I have seen in at least one environment where a proxy user/password is not required to upload a sos.

session.connect(self.get_proxy_host(), self.get_proxy_port())

session.login(proxy_formatted_user, self.proxy_password,
password)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment applies, what if it is anonymous FTP, but still need a proxy without username/password?

@dwolstroRH
Copy link
Contributor Author

Make sure you add these options to any relevant man page (at least the upload and report ones).

Can you send me the link to where it is explained how to do this? I've never updated a man page before. (is it on the source)?

@jcastill
Copy link
Member

I don't think there's a link that explains how to do it, neither here nor on the source, but I may have missed it.
What you need to do is add the options in two places:

  • In the SYNOPSIS section, i.e. below the .SH SYNOPSIS header, where you add the options only. Perhaps a good place to add them would be between these two:
          [--upload-protocol protocol]\fR
          [--experimental]\fR
  • And in the OPTIONS section, i.e. below .SH OPTIONS, where you add the options again, in the same order, but with a small explanation. This explanation can be the same as the one you have in the option list proxy_grp.

You should add these options to at least the sos-upload.1 man page, but I imagine having them in sos-report.1 could be necessary as well.

Related: RHEL-2356

Signed-off-by: David Wolstromer <dwolstro@redhat.com>
@packit-as-a-service
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/sosreport-sos-4158
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

1 similar comment
@packit-as-a-service
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/sosreport-sos-4158
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants