Skip to content

[upload] Add proxy server details for sos uploads#4158

Draft
dwolstroRH wants to merge 1 commit into
sosreport:mainfrom
dwolstroRH:add-proxy-server
Draft

[upload] Add proxy server details for sos uploads#4158
dwolstroRH wants to merge 1 commit into
sosreport:mainfrom
dwolstroRH:add-proxy-server

Conversation

@dwolstroRH

Copy link
Copy Markdown
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?

Comment thread sos/report/__init__.py Outdated
'upload_target': None,
'add_preset': '',
'del_preset': '',
<<<<<<< Updated upstream

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

Comment thread sos/upload/targets/__init__.py Outdated
raise Exception("connection failed, did you set a user and "
"password?")
raise Exception("connection failed, did you set a user"
" and password?")

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread sos/upload/targets/__init__.py Outdated
@packit-as-a-service

Copy link
Copy Markdown

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.

Comment thread sos/upload/targets/__init__.py Outdated
# --- 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
Copy Markdown
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 thread sos/report/__init__.py
Comment thread sos/upload/targets/__init__.py Outdated
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)

@pmoravec pmoravec Nov 14, 2025

Copy link
Copy Markdown
Contributor

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 thread sos/upload/targets/__init__.py Outdated
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
Copy Markdown
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..?

Comment thread sos/upload/targets/__init__.py Outdated
return {}

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

Copy link
Copy Markdown
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)

Comment thread sos/upload/targets/__init__.py Outdated
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
Copy Markdown
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
Copy Markdown
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

@arif-ali arif-ali left a comment

Copy link
Copy Markdown
Member

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

Comment thread sos/upload/targets/__init__.py Outdated
Comment thread sos/upload/targets/__init__.py Outdated
session.connect(self.get_proxy_host(), self.get_proxy_port())

session.login(proxy_formatted_user, self.proxy_password,
password)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@packit-as-a-service

Copy link
Copy Markdown

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
Copy Markdown

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.

Comment thread sos/upload/targets/__init__.py Outdated
Comment thread sos/upload/targets/__init__.py Outdated
if not self.get_proxy_user():
msg = (f"Please provide a proxy user (if required) for proxy "
f"{self.get_proxy_host()}: ")
self.proxy_user = input(_(msg))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I want to provide "no user" (see Arif's point for no user/pass), we shall convert empty response to None, maybe? (I havent tested it though).

Comment thread sos/upload/targets/__init__.py Outdated
Comment on lines +974 to +975
if self.get_proxy_user() or \
self.get_proxy_password():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it a valid use case a proxy allows user with no password? I dont know this.

If it is a valid use case, we prohibit it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure. Everything that I've read has discouraged that setup profusely, but technically it can be done. Maybe I can put a warning message and prompt the user to confirm they want to execute without a password?

ie, "Warning! You have entered a proxy user without an accompanying password. It is highly recommended to avoid this usage. Do you wish to proceed? (y/N)"

Comment on lines +987 to +988
if self.get_proxy_user() or \
self.get_proxy_password():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto the same use case (if it is valid).

@pmoravec

Copy link
Copy Markdown
Contributor

In general, ack and thanks for such nontrivial feature. Just few minor points remain to resolve (or decide).

Related: RHEL-2356

Signed-off-by: David Wolstromer <dwolstro@redhat.com>

@pmoravec pmoravec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sounds good to me, yet I tested it in a limited manner only.

@pmoravec pmoravec added feature request Kind/Enhancement Status/RedHat QE RH QE has been requested to review Reviewed/Needs 2nd Ack Require a 2nd ack from a maintainer Kind/Upload upload component of sos labels Feb 14, 2026
@dwolstroRH dwolstroRH marked this pull request as draft February 16, 2026 16:32
@jcastill

Copy link
Copy Markdown
Member

@mhradile @tiredPotato @dzalezak this PR is ready for RH QE - can we assign one of you to it?

@mhradile

Copy link
Copy Markdown
Contributor

@mhradile @tiredPotato @dzalezak this PR is ready for RH QE - can we assign one of you to it?

Hello @jcastill , I stared but could not continue on this, would like to get back to it but currently can not. Feel free to assign it to me though.

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

Labels

feature request Kind/Enhancement Kind/Upload upload component of sos Reviewed/Needs 2nd Ack Require a 2nd ack from a maintainer Status/RedHat QE RH QE has been requested to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants