This commit is contained in:
Marco Gario 2024-08-15 12:17:00 +00:00
parent 5b34615fe0
commit 7baf39279e
4 changed files with 43 additions and 30 deletions

View file

@ -29,8 +29,8 @@ const core = __importStar(require("@actions/core"));
const toolcache = __importStar(require("@actions/tool-cache"));
const node_forge_1 = require("node-forge");
const actionsUtil = __importStar(require("./actions-util"));
const util = __importStar(require("./util"));
const logging_1 = require("./logging");
const util = __importStar(require("./util"));
const UPDATEJOB_PROXY = "update-job-proxy";
const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912";
const UPDATEJOB_PROXY_URL = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.18.1/update-job-proxy.tar.gz";
@ -87,7 +87,9 @@ async function runWrapper() {
core.saveState("proxy-log-file", proxyLogFilePath);
// Get the configuration options
const credentials = getCredentials(logger);
logger.info(`Credentials loaded for the following registries:\n ${credentials.map(c => credentialToStr(c)).join("\n")}`);
logger.info(`Credentials loaded for the following registries:\n ${credentials
.map((c) => credentialToStr(c))
.join("\n")}`);
const ca = generateCertificateAuthority();
const proxyAuth = getProxyAuth();
const proxyConfig = {
@ -149,7 +151,7 @@ async function startProxy(binPath, config, logFilePath, logger) {
function getCredentials(logger) {
const registriesCredentials = actionsUtil.getOptionalInput("registries_credentials");
const registrySecrets = actionsUtil.getOptionalInput("registry_secrets");
var credentialsStr;
let credentialsStr;
if (registriesCredentials !== undefined) {
logger.info(`Using registries_credentials input.`);
credentialsStr = Buffer.from(registriesCredentials, "base64").toString();
@ -164,10 +166,10 @@ function getCredentials(logger) {
}
// Parse and validate the credentials
const parsed = JSON.parse(credentialsStr);
let out = [];
parsed.forEach(e => {
const out = [];
for (const e of parsed) {
if (e.url === undefined && e.host === undefined) {
throw "Invalid credentials - must specify host or url";
throw new Error("Invalid credentials - must specify host or url");
}
out.push({
type: e.type,
@ -177,7 +179,7 @@ function getCredentials(logger) {
password: e.password,
token: e.token,
});
});
}
return out;
}
// getProxyAuth returns the authentication information for the proxy itself.

File diff suppressed because one or more lines are too long