From d85c365851b59b7e2f4407b89a642626a2cec699 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Thu, 15 Oct 2026 14:53:46 +0200 Subject: [PATCH] Validate credentials in config to be non-empty Apparently older versions of pulp-cli created configs containing empty strings for not supplied values. This can lead to unforseen consequences, e.g. when the empty "cert" leads to choosing "mutualTLS" instead of "basic auth". fixes #1487 (cherry picked from commit 267459f8728f6712f8b5b3ae6f55efba468c13f2) --- CHANGES/1487.bugfix | 1 + src/pulp_cli/config.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 CHANGES/1487.bugfix diff --git a/CHANGES/1487.bugfix b/CHANGES/1487.bugfix new file mode 100644 index 000000000..25269c7c0 --- /dev/null +++ b/CHANGES/1487.bugfix @@ -0,0 +1 @@ +Added config validation for credential values ('username', 'cert', ...) to not be empty. diff --git a/src/pulp_cli/config.py b/src/pulp_cli/config.py index 3e3b95f04..909c23e50 100644 --- a/src/pulp_cli/config.py +++ b/src/pulp_cli/config.py @@ -179,6 +179,9 @@ def validate_config(config: dict[str, t.Any], strict: bool = False) -> None: errors.append(_("Failed to parse the 'base_path'.")) if "api_root" in config and (config["api_root"][0] != "/" or config["api_root"][-1] != "/"): errors.append(_("'api_root' must begin and end with '/'")) + for key in ["username", "cert", "key", "client_id", "client_secret"]: + if config.get(key) == "": + errors.append(_("'{}' should not be an empty string.").format(key)) if "format" in config and config["format"].lower() not in FORMAT_CHOICES: errors.append(_("'format' is not one of {choices}").format(choices=FORMAT_CHOICES)) if "verify_ssl" in config and not isinstance(config["verify_ssl"], bool):