Extend isPrintable check to all keys with string values

This commit is contained in:
Michael B. Gale
2026-03-09 19:06:06 +00:00
parent babab88e54
commit 65f7f36302
2 changed files with 15 additions and 15 deletions
+7 -4
View File
@@ -121824,10 +121824,13 @@ function getCredentials(logger, registrySecrets, registriesCredentials, language
const isPrintable2 = (str2) => {
return str2 ? /^[\x20-\x7E]*$/.test(str2) : true;
};
if (!isPrintable2(e.type) || !isPrintable2(e.host) || !isPrintable2(e.url) || !isPrintable2(e.username) || !isPrintable2(e.password) || !isPrintable2(e.token)) {
throw new ConfigurationError(
"Invalid credentials - fields must contain only printable characters"
);
for (const key of Object.keys(e)) {
const val = e[key];
if (typeof val === "string" && !isPrintable2(val)) {
throw new ConfigurationError(
"Invalid credentials - fields must contain only printable characters"
);
}
}
if (!isDefined2(e.username) && (isDefined2(e.password) && isPAT(e.password) || isDefined2(e.token) && isPAT(e.token))) {
logger.warning(
+8 -11
View File
@@ -354,17 +354,14 @@ export function getCredentials(
return str ? /^[\x20-\x7E]*$/.test(str) : true;
};
if (
!isPrintable(e.type) ||
!isPrintable(e.host) ||
!isPrintable(e.url) ||
!isPrintable(e.username) ||
!isPrintable(e.password) ||
!isPrintable(e.token)
) {
throw new ConfigurationError(
"Invalid credentials - fields must contain only printable characters",
);
// Ensure that all string fields only contain printable characters.
for (const key of Object.keys(e)) {
const val = e[key];
if (typeof val === "string" && !isPrintable(val)) {
throw new ConfigurationError(
"Invalid credentials - fields must contain only printable characters",
);
}
}
// If the password or token looks like a GitHub PAT, warn if no username is configured.