Formatting

This commit is contained in:
Marco Gario 2025-01-24 20:27:36 +00:00
parent ecf723239a
commit f6d19ed42e
6 changed files with 57 additions and 35 deletions

11
lib/start-proxy.js generated
View file

@ -41,12 +41,12 @@ function getCredentials(logger, registrySecrets, registriesCredentials, language
try {
parsed = JSON.parse(credentialsStr);
}
catch (error) {
catch {
// Don't log the error since it might contain sensitive information.
logger.error("Failed to parse the credentials data.");
throw new Error("Invalid credentials format.");
}
let out = [];
const out = [];
for (const e of parsed) {
if (e.url === undefined && e.host === undefined) {
// The proxy needs one of these to work. If both are defined, the url has the precedence.
@ -60,7 +60,12 @@ function getCredentials(logger, registrySecrets, registriesCredentials, language
const isPrintable = (str) => {
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)) {
if (!isPrintable(e.type) ||
!isPrintable(e.host) ||
!isPrintable(e.url) ||
!isPrintable(e.username) ||
!isPrintable(e.password) ||
!isPrintable(e.token)) {
throw new Error("Invalid credentials - fields must contain only printable characters");
}
out.push({