summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-04-07 23:06:01 +0200
committerChristian Breunig <christian@breunig.cc>2026-04-07 23:08:17 +0200
commite51e53bf30d233b3b2a7e347eb00b1e6b671af77 (patch)
tree4c1815107661d996da9b39f3503508e6bef2e441 /python
parent56d98d7e152f4211dbba7825aac00f7024df4275 (diff)
downloadvyos-1x-e51e53bf30d233b3b2a7e347eb00b1e6b671af77.tar.gz
vyos-1x-e51e53bf30d233b3b2a7e347eb00b1e6b671af77.zip
remote: T4732: redact u/p from URL on error
The upload error message echoes the full urlstring, which may include embedded credentials (e.g., https://user:pass@host/...). With this commit the information has been redacted.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/remote.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python/vyos/remote.py b/python/vyos/remote.py
index 3a2501c57..b69e8d32b 100644
--- a/python/vyos/remote.py
+++ b/python/vyos/remote.py
@@ -43,6 +43,8 @@ from ftplib import error_reply
from ftplib import parse150
from requests import Session
from requests.adapters import HTTPAdapter
+from urllib.parse import urlsplit
+from urllib.parse import urlunsplit
from urllib3 import PoolManager
from urllib3.connection import HTTPConnection
@@ -614,7 +616,10 @@ def upload(local_path, urlstring, progressbar=False,
progressbar = progressbar and is_interactive()
urlc(urlstring, progressbar, False, source_host, source_port, timeout, vrf).upload(local_path)
except Exception as err:
- print_error(f'Unable to upload "{urlstring}": {err}')
+ url = urlsplit(urlstring)
+ _, _, netloc = url.netloc.rpartition('@')
+ redacted_location = urlunsplit(url._replace(netloc=netloc))
+ print_error(f'Unable to upload "{redacted_location}": {err}')
sys.exit(1)
except KeyboardInterrupt:
print_error('\nUpload aborted by user.')