mirror of
https://github.com/github/codeql-action
synced 2026-05-29 05:00:55 +03:00
Extend isPrintable check to all keys with string values
This commit is contained in:
Generated
+7
-4
@@ -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
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user