mirror of
https://github.com/github/codeql-action.git
synced 2024-10-23 08:00:03 +08:00
fixes
This commit is contained in:
parent
5b34615fe0
commit
7baf39279e
16
lib/start-proxy-action.js
generated
16
lib/start-proxy-action.js
generated
@ -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
@ -6,8 +6,8 @@ import * as toolcache from "@actions/tool-cache";
|
||||
import { pki } from "node-forge";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import * as util from "./util";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import * as util from "./util";
|
||||
|
||||
const UPDATEJOB_PROXY = "update-job-proxy";
|
||||
const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912";
|
||||
@ -100,7 +100,11 @@ async function runWrapper() {
|
||||
|
||||
// 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();
|
||||
@ -116,7 +120,12 @@ async function runWrapper() {
|
||||
await startProxy(proxyBin, proxyConfig, proxyLogFilePath, logger);
|
||||
}
|
||||
|
||||
async function startProxy(binPath: string, config: ProxyConfig, logFilePath: string, logger: Logger) {
|
||||
async function startProxy(
|
||||
binPath: string,
|
||||
config: ProxyConfig,
|
||||
logFilePath: string,
|
||||
logger: Logger,
|
||||
) {
|
||||
const host = "127.0.0.1";
|
||||
let port = 49152;
|
||||
try {
|
||||
@ -170,10 +179,12 @@ async function startProxy(binPath: string, config: ProxyConfig, logFilePath: str
|
||||
// It prefers `registries_credentials` over `registry_secrets`.
|
||||
// If neither is set, it returns an empty array.
|
||||
function getCredentials(logger: Logger): Credential[] {
|
||||
const registriesCredentials = actionsUtil.getOptionalInput("registries_credentials");
|
||||
const registriesCredentials = actionsUtil.getOptionalInput(
|
||||
"registries_credentials",
|
||||
);
|
||||
const registrySecrets = actionsUtil.getOptionalInput("registry_secrets");
|
||||
|
||||
var credentialsStr: string;
|
||||
let credentialsStr: string;
|
||||
if (registriesCredentials !== undefined) {
|
||||
logger.info(`Using registries_credentials input.`);
|
||||
credentialsStr = Buffer.from(registriesCredentials, "base64").toString();
|
||||
@ -187,25 +198,25 @@ function getCredentials(logger: Logger): Credential[] {
|
||||
|
||||
// Parse and validate the credentials
|
||||
const parsed = JSON.parse(credentialsStr) as Credential[];
|
||||
let out: Credential[] = []
|
||||
parsed.forEach(e => {
|
||||
const out: Credential[] = [];
|
||||
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,
|
||||
host: e.host,
|
||||
url: e.url,
|
||||
username: e.username,
|
||||
password: e.password,
|
||||
token: e.token,
|
||||
})
|
||||
});
|
||||
type: e.type,
|
||||
host: e.host,
|
||||
url: e.url,
|
||||
username: e.username,
|
||||
password: e.password,
|
||||
token: e.token,
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// getProxyAuth returns the authentication information for the proxy itself.
|
||||
function getProxyAuth(): BasicAuthCredentials | undefined{
|
||||
function getProxyAuth(): BasicAuthCredentials | undefined {
|
||||
const proxy_password = actionsUtil.getOptionalInput("proxy_password");
|
||||
if (proxy_password) {
|
||||
return {
|
||||
@ -213,10 +224,9 @@ function getProxyAuth(): BasicAuthCredentials | undefined{
|
||||
password: proxy_password,
|
||||
};
|
||||
}
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
async function getProxyBinaryPath(): Promise<string> {
|
||||
let proxyBin = toolcache.find(UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION);
|
||||
if (!proxyBin) {
|
||||
@ -233,8 +243,9 @@ async function getProxyBinaryPath(): Promise<string> {
|
||||
}
|
||||
|
||||
function credentialToStr(c: Credential): string {
|
||||
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`
|
||||
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${
|
||||
c.username
|
||||
}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`;
|
||||
}
|
||||
|
||||
|
||||
void runWrapper();
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: "CodeQL: Start proxy"
|
||||
description: "[Experimental] Start HTTP proxy server"
|
||||
description: "[Experimental] Start HTTP proxy server. This action is for internal GitHub used only and will change without notice."
|
||||
author: "GitHub"
|
||||
inputs:
|
||||
registry_secrets:
|
||||
|
Loading…
Reference in New Issue
Block a user