Merge pull request #318 from github/api-param-object
Introduce parameter object for API params that travel together
This commit is contained in:
commit
27520b94c4
36 changed files with 255 additions and 258 deletions
6
lib/analyze-action.js
generated
6
lib/analyze-action.js
generated
|
|
@ -39,7 +39,11 @@ async function run() {
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||||
}
|
}
|
||||||
stats = await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), actionsUtil.getRequiredInput("upload") === "true", "actions", actionsUtil.getRequiredInput("output"), util.getMemoryFlag(actionsUtil.getOptionalInput("ram")), util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger), config, logger);
|
const apiDetails = {
|
||||||
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
|
};
|
||||||
|
stats = await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), apiDetails, actionsUtil.getRequiredInput("upload") === "true", "actions", actionsUtil.getRequiredInput("output"), util.getMemoryFlag(actionsUtil.getOptionalInput("ram")), util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger), config, logger);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"analyze-action.js","sourceRoot":"","sources":["../src/analyze-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAImB;AACnB,iDAA2C;AAC3C,uCAA6C;AAC7C,6CAAkD;AAClD,6CAA+B;AAM/B,KAAK,UAAU,gBAAgB,CAC7B,SAAe,EACf,KAAuC,EACvC,KAAa;;IAEb,MAAM,MAAM,GACV,OAAA,KAAK,0CAAE,wBAAwB,MAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAClE,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,QAAQ,EACR,MAAM,EACN,SAAS,QACT,KAAK,0CAAE,OAAO,QACd,KAAK,0CAAE,KAAK,CACb,CAAC;IACF,MAAM,YAAY,GAAuB;QACvC,GAAG,gBAAgB;QACnB,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;KACjB,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAI,KAAK,GAAqC,SAAS,CAAC;IACxD,IAAI;QACF,WAAW,CAAC,0BAA0B,EAAE,CAAC;QACzC,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,QAAQ,EACR,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;YAC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vD,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,EACrE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,EACpE,MAAM,EACN,MAAM,CACP,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnB,IAAI,KAAK,YAAY,6BAAmB,EAAE;YACxC,KAAK,GAAG,EAAE,GAAG,KAAK,CAAC,mBAAmB,EAAE,CAAC;SAC1C;QAED,MAAM,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO;KACR;IAED,MAAM,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,IAAI,CAAC,SAAS,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||||
4
lib/analyze.js
generated
4
lib/analyze.js
generated
|
|
@ -117,7 +117,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
||||||
return statusReport;
|
return statusReport;
|
||||||
}
|
}
|
||||||
exports.runQueries = runQueries;
|
exports.runQueries = runQueries;
|
||||||
async function runAnalyze(repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, doUpload, mode, outputDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logger) {
|
async function runAnalyze(repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, apiDetails, doUpload, mode, outputDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logger) {
|
||||||
// Delete the tracer config env var to avoid tracing ourselves
|
// Delete the tracer config env var to avoid tracing ourselves
|
||||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
|
|
@ -129,7 +129,7 @@ async function runAnalyze(repositoryNwo, commitOid, ref, analysisKey, analysisNa
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
return { ...queriesStats };
|
return { ...queriesStats };
|
||||||
}
|
}
|
||||||
const uploadStats = await upload_lib.upload(outputDir, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger);
|
const uploadStats = await upload_lib.upload(outputDir, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, apiDetails, mode, logger);
|
||||||
return { ...queriesStats, ...uploadStats };
|
return { ...queriesStats, ...uploadStats };
|
||||||
}
|
}
|
||||||
exports.runAnalyze = runAnalyze;
|
exports.runAnalyze = runAnalyze;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAE3D,gEAAkD;AAClD,qCAAqC;AAErC,2CAA0D;AAG1D,gEAAkD;AAClD,yDAA2C;AAC3C,6CAA+B;AAE/B,MAAa,mBAAoB,SAAQ,KAAK;IAG5C,YAAY,mBAAwC,EAAE,OAAe;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;CACF;AATD,kDASC;AAmCD,KAAK,UAAU,oBAA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|
|
@ -28,7 +28,7 @@ var DisallowedAPIVersionReason;
|
||||||
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
|
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
|
||||||
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||||
let hasBeenWarnedAboutVersion = false;
|
let hasBeenWarnedAboutVersion = false;
|
||||||
exports.getApiClient = function (githubAuth, githubUrl, mode, logger, allowLocalRun = false, possibleFailureExpected = false) {
|
exports.getApiClient = function (apiDetails, mode, logger, allowLocalRun = false, possibleFailureExpected = false) {
|
||||||
if (util_1.isLocalRun() && !allowLocalRun) {
|
if (util_1.isLocalRun() && !allowLocalRun) {
|
||||||
throw new Error("Invalid API call in local run");
|
throw new Error("Invalid API call in local run");
|
||||||
}
|
}
|
||||||
|
|
@ -58,8 +58,8 @@ exports.getApiClient = function (githubAuth, githubUrl, mode, logger, allowLocal
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return new customOctokit(githubUtils.getOctokitOptions(githubAuth, {
|
return new customOctokit(githubUtils.getOctokitOptions(apiDetails.auth, {
|
||||||
baseUrl: getApiUrl(githubUrl),
|
baseUrl: getApiUrl(apiDetails.url),
|
||||||
userAgent: "CodeQL Action",
|
userAgent: "CodeQL Action",
|
||||||
log: console_log_level_1.default({ level: "debug" }),
|
log: console_log_level_1.default({ level: "debug" }),
|
||||||
}));
|
}));
|
||||||
|
|
@ -79,7 +79,11 @@ function getApiUrl(githubUrl) {
|
||||||
// Once all code has been converted this function should be removed or made canonical
|
// Once all code has been converted this function should be removed or made canonical
|
||||||
// and called only from the action entrypoints.
|
// and called only from the action entrypoints.
|
||||||
function getActionsApiClient(allowLocalRun = false) {
|
function getActionsApiClient(allowLocalRun = false) {
|
||||||
return exports.getApiClient(actions_util_1.getRequiredInput("token"), actions_util_1.getRequiredEnvParam("GITHUB_SERVER_URL"), "actions", logging_1.getActionsLogger(), allowLocalRun);
|
const apiDetails = {
|
||||||
|
auth: actions_util_1.getRequiredInput("token"),
|
||||||
|
url: actions_util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
|
};
|
||||||
|
return exports.getApiClient(apiDetails, "actions", logging_1.getActionsLogger(), allowLocalRun);
|
||||||
}
|
}
|
||||||
exports.getActionsApiClient = getActionsApiClient;
|
exports.getActionsApiClient = getActionsApiClient;
|
||||||
function apiVersionInRange(version, minimumVersion, maximumVersion) {
|
function apiVersionInRange(version, minimumVersion, maximumVersion) {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAE7B,wCAA+C;AAC/C,uEAAyD;AACzD,6DAA+C;AAE/C,0EAAgD;AAChD,+CAAiC;AAEjC,iDAAuE;AACvE,2EAA6D;AAC7D,uCAAqD;AACrD,iCAA0C;AAE1C,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,+FAAc,CAAA;IACd,+FAAc,CAAA;AAChB,CAAC,EAHW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAGrC;AAED,MAAM,gCAAgC,GAAG,6BAA6B,CAAC;AACvE,MAAM,0CAA0C,GAC9C,oCAAoC,CAAC;AACvC,IAAI,yBAAyB,GAAG,KAAK,CAAC;AAEzB,QAAA,YAAY,GAAG,UAC1B,UAAkB,EAClB,SAAiB,EACjB,IAAU,EACV,MAAc,EACd,aAAa,GAAG,KAAK,EACrB,uBAAuB,GAAG,KAAK;IAE/B,IAAI,iBAAU,EAAE,IAAI,CAAC,aAAa,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,MAAM,aAAa,G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gBAAgB,EAAE;QACtE,OAAO,wBAAwB,CAAC;KACjC;IAED,6BAA6B;IAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,uFAAuF;AACvF,qFAAqF;AACrF,+CAA+C;AAC/C,SAAgB,mBAAmB,CAAC,aAAa,GAAG,KAAK;IACvD,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,+BAAgB,CAAC,OAAO,CAAC;QAC/B,GAAG,EAAE,kCAAmB,CAAC,mBAAmB,CAAC;KAC9C,CAAC;IAEF,OAAO,oBAAY,CAAC,UAAU,EAAE,SAAS,EAAE,0BAAgB,EAAE,EAAE,aAAa,CAAC,CAAC;AAChF,CAAC;AAPD,kDAOC;AAED,SAAgB,iBAAiB,CAC/B,OAAe,EACf,cAAsB,EACtB,cAAsB;IAEtB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,cAAc,EAAE,CAAC,EAAE;QACrD,OAAO,0BAA0B,CAAC,cAAc,CAAC;KAClD;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,cAAc,EAAE,CAAC,EAAE;QACrD,OAAO,0BAA0B,CAAC,cAAc,CAAC;KAClD;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAZD,8CAYC"}
|
||||||
16
lib/codeql.js
generated
16
lib/codeql.js
generated
|
|
@ -64,13 +64,13 @@ function getCodeQLActionRepository(mode, logger) {
|
||||||
const relativeScriptPathParts = actions_util_1.getRelativeScriptPath().split(path.sep);
|
const relativeScriptPathParts = actions_util_1.getRelativeScriptPath().split(path.sep);
|
||||||
return `${relativeScriptPathParts[0]}/${relativeScriptPathParts[1]}`;
|
return `${relativeScriptPathParts[0]}/${relativeScriptPathParts[1]}`;
|
||||||
}
|
}
|
||||||
async function getCodeQLBundleDownloadURL(githubAuth, githubUrl, mode, logger) {
|
async function getCodeQLBundleDownloadURL(apiDetails, mode, logger) {
|
||||||
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
||||||
const potentialDownloadSources = [
|
const potentialDownloadSources = [
|
||||||
// This GitHub instance, and this Action.
|
// This GitHub instance, and this Action.
|
||||||
[githubUrl, codeQLActionRepository],
|
[apiDetails.url, codeQLActionRepository],
|
||||||
// This GitHub instance, and the canonical Action.
|
// This GitHub instance, and the canonical Action.
|
||||||
[githubUrl, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
[apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||||
// GitHub.com, and the canonical Action.
|
// GitHub.com, and the canonical Action.
|
||||||
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||||
];
|
];
|
||||||
|
|
@ -88,7 +88,7 @@ async function getCodeQLBundleDownloadURL(githubAuth, githubUrl, mode, logger) {
|
||||||
const [repositoryOwner, repositoryName] = repository.split("/");
|
const [repositoryOwner, repositoryName] = repository.split("/");
|
||||||
try {
|
try {
|
||||||
const release = await api
|
const release = await api
|
||||||
.getApiClient(githubAuth, githubUrl, mode, logger, false, true)
|
.getApiClient(apiDetails, mode, logger, false, true)
|
||||||
.repos.getReleaseByTag({
|
.repos.getReleaseByTag({
|
||||||
owner: repositoryOwner,
|
owner: repositoryOwner,
|
||||||
repo: repositoryName,
|
repo: repositoryName,
|
||||||
|
|
@ -122,7 +122,7 @@ async function toolcacheDownloadTool(url, headers, tempDir, logger) {
|
||||||
await pipeline(response.message, fs.createWriteStream(dest));
|
await pipeline(response.message, fs.createWriteStream(dest));
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
async function setupCodeQL(codeqlURL, githubAuth, githubUrl, tempDir, toolsDir, mode, logger) {
|
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, logger) {
|
||||||
// Setting these two env vars makes the toolcache code safe to use outside,
|
// Setting these two env vars makes the toolcache code safe to use outside,
|
||||||
// of actions but this is obviously not a great thing we're doing and it would
|
// of actions but this is obviously not a great thing we're doing and it would
|
||||||
// be better to write our own implementation to use outside of actions.
|
// be better to write our own implementation to use outside of actions.
|
||||||
|
|
@ -157,15 +157,15 @@ async function setupCodeQL(codeqlURL, githubAuth, githubUrl, tempDir, toolsDir,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!codeqlURL) {
|
if (!codeqlURL) {
|
||||||
codeqlURL = await getCodeQLBundleDownloadURL(githubAuth, githubUrl, mode, logger);
|
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, logger);
|
||||||
}
|
}
|
||||||
const headers = { accept: "application/octet-stream" };
|
const headers = { accept: "application/octet-stream" };
|
||||||
// We only want to provide an authorization header if we are downloading
|
// We only want to provide an authorization header if we are downloading
|
||||||
// from the same GitHub instance the Action is running on.
|
// from the same GitHub instance the Action is running on.
|
||||||
// This avoids leaking Enterprise tokens to dotcom.
|
// This avoids leaking Enterprise tokens to dotcom.
|
||||||
if (codeqlURL.startsWith(`${githubUrl}/`)) {
|
if (codeqlURL.startsWith(`${apiDetails.url}/`)) {
|
||||||
logger.debug("Downloading CodeQL bundle with token.");
|
logger.debug("Downloading CodeQL bundle with token.");
|
||||||
headers.authorization = `token ${githubAuth}`;
|
headers.authorization = `token ${apiDetails.auth}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.debug("Downloading CodeQL bundle without token.");
|
logger.debug("Downloading CodeQL bundle without token.");
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
22
lib/codeql.test.js
generated
22
lib/codeql.test.js
generated
|
|
@ -20,6 +20,10 @@ const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
|
const sampleApiDetails = {
|
||||||
|
auth: "token",
|
||||||
|
url: "https://github.com",
|
||||||
|
};
|
||||||
ava_1.default("download codeql bundle cache", async (t) => {
|
ava_1.default("download codeql bundle cache", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
const versions = ["20200601", "20200610"];
|
const versions = ["20200601", "20200610"];
|
||||||
|
|
@ -28,7 +32,7 @@ ava_1.default("download codeql bundle cache", async (t) => {
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, "token", "https://github.example.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
}
|
}
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
|
|
@ -40,12 +44,12 @@ ava_1.default("download codeql bundle cache explicitly requested with pinned dif
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -54,9 +58,9 @@ ava_1.default("don't download codeql bundle cache with pinned different version
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await codeql.setupCodeQL(undefined, "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
|
|
@ -66,7 +70,7 @@ ava_1.default("download codeql bundle cache with different version cached (not p
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
|
|
@ -76,7 +80,7 @@ ava_1.default("download codeql bundle cache with different version cached (not p
|
||||||
nock_1.default("https://github.com")
|
nock_1.default("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL(undefined, "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
|
|
@ -86,7 +90,7 @@ ava_1.default('download codeql bundle cache with pinned different version cached
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
|
|
@ -96,7 +100,7 @@ ava_1.default('download codeql bundle cache with pinned different version cached
|
||||||
nock_1.default("https://github.com")
|
nock_1.default("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("latest", "token", "https://github.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
34
lib/config-utils.js
generated
34
lib/config-utils.js
generated
|
|
@ -301,10 +301,10 @@ exports.getUnknownLanguagesError = getUnknownLanguagesError;
|
||||||
/**
|
/**
|
||||||
* Gets the set of languages in the current repository
|
* Gets the set of languages in the current repository
|
||||||
*/
|
*/
|
||||||
async function getLanguagesInRepo(repository, githubAuth, githubUrl, mode, logger) {
|
async function getLanguagesInRepo(repository, apiDetails, mode, logger) {
|
||||||
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
||||||
const response = await api
|
const response = await api
|
||||||
.getApiClient(githubAuth, githubUrl, mode, logger, true)
|
.getApiClient(apiDetails, mode, logger, true)
|
||||||
.repos.listLanguages({
|
.repos.listLanguages({
|
||||||
owner: repository.owner,
|
owner: repository.owner,
|
||||||
repo: repository.repo,
|
repo: repository.repo,
|
||||||
|
|
@ -333,7 +333,7 @@ async function getLanguagesInRepo(repository, githubAuth, githubUrl, mode, logge
|
||||||
* If no languages could be detected from either the workflow or the repository
|
* If no languages could be detected from either the workflow or the repository
|
||||||
* then throw an error.
|
* then throw an error.
|
||||||
*/
|
*/
|
||||||
async function getLanguages(languagesInput, repository, githubAuth, githubUrl, mode, logger) {
|
async function getLanguages(languagesInput, repository, apiDetails, mode, logger) {
|
||||||
// Obtain from action input 'languages' if set
|
// Obtain from action input 'languages' if set
|
||||||
let languages = (languagesInput || "")
|
let languages = (languagesInput || "")
|
||||||
.split(",")
|
.split(",")
|
||||||
|
|
@ -342,7 +342,7 @@ async function getLanguages(languagesInput, repository, githubAuth, githubUrl, m
|
||||||
logger.info(`Languages from configuration: ${JSON.stringify(languages)}`);
|
logger.info(`Languages from configuration: ${JSON.stringify(languages)}`);
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
// Obtain languages as all languages in the repo that can be analysed
|
// Obtain languages as all languages in the repo that can be analysed
|
||||||
languages = await getLanguagesInRepo(repository, githubAuth, githubUrl, mode, logger);
|
languages = await getLanguagesInRepo(repository, apiDetails, mode, logger);
|
||||||
logger.info(`Automatically detected languages: ${JSON.stringify(languages)}`);
|
logger.info(`Automatically detected languages: ${JSON.stringify(languages)}`);
|
||||||
}
|
}
|
||||||
// If the languages parameter was not given and no languages were
|
// If the languages parameter was not given and no languages were
|
||||||
|
|
@ -388,12 +388,12 @@ function shouldAddConfigFileQueries(queriesInput) {
|
||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
async function getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, mode, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, apiDetails, mode, logger) {
|
||||||
const languages = await getLanguages(languagesInput, repository, githubAuth, githubUrl, mode, logger);
|
const languages = await getLanguages(languagesInput, repository, apiDetails, mode, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
await addDefaultQueries(codeQL, languages, queries);
|
await addDefaultQueries(codeQL, languages, queries);
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl, logger);
|
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails.url, logger);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
|
|
@ -410,7 +410,7 @@ exports.getDefaultConfig = getDefaultConfig;
|
||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, mode, logger) {
|
async function loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, apiDetails, mode, logger) {
|
||||||
let parsedYAML;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
// Treat the config file as relative to the workspace
|
// Treat the config file as relative to the workspace
|
||||||
|
|
@ -418,7 +418,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
||||||
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parsedYAML = await getRemoteConfig(configFile, githubAuth, githubUrl, mode, logger);
|
parsedYAML = await getRemoteConfig(configFile, apiDetails, mode, logger);
|
||||||
}
|
}
|
||||||
// Validate that the 'name' property is syntactically correct,
|
// Validate that the 'name' property is syntactically correct,
|
||||||
// even though we don't use the value yet.
|
// even though we don't use the value yet.
|
||||||
|
|
@ -430,7 +430,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
||||||
throw new Error(getNameInvalid(configFile));
|
throw new Error(getNameInvalid(configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const languages = await getLanguages(languagesInput, repository, githubAuth, githubUrl, mode, logger);
|
const languages = await getLanguages(languagesInput, repository, apiDetails, mode, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
const pathsIgnore = [];
|
const pathsIgnore = [];
|
||||||
const paths = [];
|
const paths = [];
|
||||||
|
|
@ -449,7 +449,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
||||||
// unless they're prefixed with "+", in which case they supplement those
|
// unless they're prefixed with "+", in which case they supplement those
|
||||||
// in the config file.
|
// in the config file.
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl, logger);
|
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails.url, logger);
|
||||||
}
|
}
|
||||||
if (shouldAddConfigFileQueries(queriesInput) &&
|
if (shouldAddConfigFileQueries(queriesInput) &&
|
||||||
QUERIES_PROPERTY in parsedYAML) {
|
QUERIES_PROPERTY in parsedYAML) {
|
||||||
|
|
@ -461,7 +461,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
||||||
typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
||||||
throw new Error(getQueryUsesInvalid(configFile));
|
throw new Error(getQueryUsesInvalid(configFile));
|
||||||
}
|
}
|
||||||
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, checkoutPath, githubUrl, logger, configFile);
|
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, checkoutPath, apiDetails.url, logger, configFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
||||||
|
|
@ -513,15 +513,15 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
||||||
* This will parse the config from the user input if present, or generate
|
* This will parse the config from the user input if present, or generate
|
||||||
* a default config. The parsed config is then stored to a known location.
|
* a default config. The parsed config is then stored to a known location.
|
||||||
*/
|
*/
|
||||||
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, mode, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, apiDetails, mode, logger) {
|
||||||
let config;
|
let config;
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
logger.debug("No configuration file was provided");
|
logger.debug("No configuration file was provided");
|
||||||
config = await getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, mode, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, apiDetails, mode, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, mode, logger);
|
config = await loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, apiDetails, mode, logger);
|
||||||
}
|
}
|
||||||
// Save the config so we can easily access it again in the future
|
// Save the config so we can easily access it again in the future
|
||||||
await saveConfig(config, logger);
|
await saveConfig(config, logger);
|
||||||
|
|
@ -546,7 +546,7 @@ function getLocalConfig(configFile, checkoutPath) {
|
||||||
}
|
}
|
||||||
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
||||||
}
|
}
|
||||||
async function getRemoteConfig(configFile, githubAuth, githubUrl, mode, logger) {
|
async function getRemoteConfig(configFile, apiDetails, mode, logger) {
|
||||||
// retrieve the various parts of the config location, and ensure they're present
|
// retrieve the various parts of the config location, and ensure they're present
|
||||||
const format = new RegExp("(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)");
|
const format = new RegExp("(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)");
|
||||||
const pieces = format.exec(configFile);
|
const pieces = format.exec(configFile);
|
||||||
|
|
@ -555,7 +555,7 @@ async function getRemoteConfig(configFile, githubAuth, githubUrl, mode, logger)
|
||||||
throw new Error(getConfigFileRepoFormatInvalidMessage(configFile));
|
throw new Error(getConfigFileRepoFormatInvalidMessage(configFile));
|
||||||
}
|
}
|
||||||
const response = await api
|
const response = await api
|
||||||
.getApiClient(githubAuth, githubUrl, mode, logger, true)
|
.getApiClient(apiDetails, mode, logger, true)
|
||||||
.repos.getContent({
|
.repos.getContent({
|
||||||
owner: pieces.groups.owner,
|
owner: pieces.groups.owner,
|
||||||
repo: pieces.groups.repo,
|
repo: pieces.groups.repo,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
44
lib/config-utils.test.js
generated
44
lib/config-utils.test.js
generated
|
|
@ -23,6 +23,10 @@ const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
|
const sampleApiDetails = {
|
||||||
|
auth: "token",
|
||||||
|
url: "https://github.example.com",
|
||||||
|
};
|
||||||
// Returns the filepath of the newly-created file
|
// Returns the filepath of the newly-created file
|
||||||
function createConfigFile(inputFileContents, tmpDir) {
|
function createConfigFile(inputFileContents, tmpDir) {
|
||||||
const configFilePath = path.join(tmpDir, "input");
|
const configFilePath = path.join(tmpDir, "input");
|
||||||
|
|
@ -66,8 +70,8 @@ ava_1.default("load empty config", async (t) => {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logger);
|
const config = await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logger);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logger));
|
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logger));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("loading config saves config", async (t) => {
|
ava_1.default("loading config saves config", async (t) => {
|
||||||
|
|
@ -86,7 +90,7 @@ ava_1.default("loading config saves config", async (t) => {
|
||||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// Sanity check that getConfig returns undefined before we have called initConfig
|
// Sanity check that getConfig returns undefined before we have called initConfig
|
||||||
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
||||||
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logger);
|
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logger);
|
||||||
// The saved config file should now exist
|
// The saved config file should now exist
|
||||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
|
|
@ -97,7 +101,7 @@ ava_1.default("loading config saves config", async (t) => {
|
||||||
ava_1.default("load input outside of workspace", async (t) => {
|
ava_1.default("load input outside of workspace", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, "../input", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, "../input", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -110,7 +114,7 @@ ava_1.default("load non-local input with invalid repo syntax", async (t) => {
|
||||||
// no filename given, just a repo
|
// no filename given, just a repo
|
||||||
const configFile = "octo-org/codeql-config@main";
|
const configFile = "octo-org/codeql-config@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -124,7 +128,7 @@ ava_1.default("load non-existent input", async (t) => {
|
||||||
const configFile = "input";
|
const configFile = "input";
|
||||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -184,7 +188,7 @@ ava_1.default("load non-empty input", async (t) => {
|
||||||
};
|
};
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
const actualConfig = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
// Should exactly equal the object we constructed earlier
|
// Should exactly equal the object we constructed earlier
|
||||||
t.deepEqual(actualConfig, expectedConfig);
|
t.deepEqual(actualConfig, expectedConfig);
|
||||||
});
|
});
|
||||||
|
|
@ -220,7 +224,7 @@ ava_1.default("Default queries are used", async (t) => {
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
// Check resolve queries was called correctly
|
// Check resolve queries was called correctly
|
||||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||||
t.deepEqual(resolveQueriesArgs[0].queries, [
|
t.deepEqual(resolveQueriesArgs[0].queries, [
|
||||||
|
|
@ -263,7 +267,7 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries
|
// It'll be called once for the default queries
|
||||||
// and once for `./foo` from the config file.
|
// and once for `./foo` from the config file.
|
||||||
|
|
@ -296,7 +300,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries and once for `./override`,
|
// It'll be called once for the default queries and once for `./override`,
|
||||||
// but won't be called for './foo' from the config file.
|
// but won't be called for './foo' from the config file.
|
||||||
|
|
@ -328,7 +332,7 @@ ava_1.default("Queries in workflow file can be used in tandem with the 'disable
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for `./workflow-query`,
|
// It'll be called once for `./workflow-query`,
|
||||||
// but won't be called for the default one since that was disabled
|
// but won't be called for the default one since that was disabled
|
||||||
|
|
@ -354,7 +358,7 @@ ava_1.default("Multiple queries can be specified in workflow file, no config fil
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly:
|
// Check resolveQueries was called correctly:
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// and then once for each of the two queries from the workflow
|
// and then once for each of the two queries from the workflow
|
||||||
|
|
@ -393,7 +397,7 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// once for each of additional1 and additional2,
|
// once for each of additional1 and additional2,
|
||||||
|
|
@ -432,7 +436,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, queries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.fail("initConfig did not throw error");
|
t.fail("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -475,7 +479,7 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
||||||
const configFile = "octo-org/codeql-config/config.yaml@main";
|
const configFile = "octo-org/codeql-config/config.yaml@main";
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -485,7 +489,7 @@ ava_1.default("Remote config handles the case where a directory is provided", as
|
||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -501,7 +505,7 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -513,7 +517,7 @@ ava_1.default("No detected languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
mockListLanguages([]);
|
mockListLanguages([]);
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -525,7 +529,7 @@ ava_1.default("Unknown languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = "ruby,english";
|
const languages = "ruby,english";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -550,7 +554,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
||||||
const inputFile = path.join(tmpDir, configFile);
|
const inputFile = path.join(tmpDir, configFile);
|
||||||
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", "runner", logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, sampleApiDetails, "runner", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
8
lib/init-action.js
generated
8
lib/init-action.js
generated
|
|
@ -58,10 +58,14 @@ async function run() {
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), "actions", logger);
|
const apiDetails = {
|
||||||
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
|
};
|
||||||
|
const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), apiDetails, actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), "actions", logger);
|
||||||
codeql = initCodeQLResult.codeql;
|
codeql = initCodeQLResult.codeql;
|
||||||
toolsVersion = initCodeQLResult.toolsVersion;
|
toolsVersion = initCodeQLResult.toolsVersion;
|
||||||
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), "actions", logger);
|
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), apiDetails, "actions", logger);
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
if (config.languages.includes(languages_1.Language.python) &&
|
||||||
actionsUtil.getRequiredInput("setup-python-dependencies") === "true") {
|
actionsUtil.getRequiredInput("setup-python-dependencies") === "true") {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAG9C,iCAMgB;AAChB,2CAAuC;AACvC,uCAA6C;AAC7C,6CAAkD;AAsBlD,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,MAA0B,EAC1B,YAAoB;;IAEpB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,MAAM,EACN,SAAS,EACT,SAAS,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,iBAAiB,GAAG,WAAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CACvE,GAAG,CACJ,CAAC;IACF,MAAM,qBAAqB,GAAG,MAAM,CAAC,iBAAiB,CACpD,yBAAyB,CAC1B;QACC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,YAAY,SAAG,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,0CAAE,IAAI,EAAE,CAAC;IACnE,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC9D,OAAO,CAAC,IAAI,CACV,GAAG,CAAC,MAAM,CAAC,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K,CAAC,CAAC;aACjC;YAED,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;gBAChC,MAAM,0BAAmB,CACvB,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,MAAM,EACN,YAAY,CACb,CAAC;aACH;SACF;QAED,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;KACjD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,MAAM,EACN,SAAS,EACT,SAAS,EACT,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,KAAK,CACZ,CACF,CAAC;QACF,OAAO;KACR;IACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACjE,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||||
8
lib/init.js
generated
8
lib/init.js
generated
|
|
@ -16,17 +16,17 @@ const codeql_1 = require("./codeql");
|
||||||
const configUtils = __importStar(require("./config-utils"));
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
const tracer_config_1 = require("./tracer-config");
|
const tracer_config_1 = require("./tracer-config");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
async function initCodeQL(codeqlURL, githubAuth, githubUrl, tempDir, toolsDir, mode, logger) {
|
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, logger) {
|
||||||
logger.startGroup("Setup CodeQL tools");
|
logger.startGroup("Setup CodeQL tools");
|
||||||
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, githubAuth, githubUrl, tempDir, toolsDir, mode, logger);
|
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, logger);
|
||||||
await codeql.printVersion();
|
await codeql.printVersion();
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return { codeql, toolsVersion };
|
return { codeql, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, mode, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, apiDetails, mode, logger) {
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, mode, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, apiDetails, mode, logger);
|
||||||
analysisPaths.printPathFiltersWarning(config, logger);
|
analysisPaths.printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAClD,qCAA+C;AAC/C,4DAA8C;AAG9C,mDAAwE;AACxE,6CAA+B;AAExB,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAAkB,EAClB,SAAiB,EACjB,OAAe,EACf,QAAgB,EAChB,IAAe,E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AE,CAAC;AACpB,CAAC;AAnDD,8CAmDC"}
|
||||||
20
lib/runner.js
generated
20
lib/runner.js
generated
|
|
@ -103,14 +103,18 @@ program
|
||||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||||
fs.rmdirSync(tempDir, { recursive: true });
|
fs.rmdirSync(tempDir, { recursive: true });
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
|
const apiDetails = {
|
||||||
|
auth: cmd.githubAuth,
|
||||||
|
url: util_1.parseGithubUrl(cmd.githubUrl),
|
||||||
|
};
|
||||||
let codeql;
|
let codeql;
|
||||||
if (cmd.codeqlPath !== undefined) {
|
if (cmd.codeqlPath !== undefined) {
|
||||||
codeql = codeql_1.getCodeQL(cmd.codeqlPath);
|
codeql = codeql_1.getCodeQL(cmd.codeqlPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeql = (await init_1.initCodeQL(undefined, cmd.githubAuth, util_1.parseGithubUrl(cmd.githubUrl), tempDir, toolsDir, "runner", logger)).codeql;
|
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, "runner", logger)).codeql;
|
||||||
}
|
}
|
||||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, util_1.parseGithubUrl(cmd.githubUrl), "runner", logger);
|
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), apiDetails, "runner", logger);
|
||||||
const tracerConfig = await init_1.runInit(codeql, config);
|
const tracerConfig = await init_1.runInit(codeql, config);
|
||||||
if (tracerConfig === undefined) {
|
if (tracerConfig === undefined) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -219,7 +223,11 @@ program
|
||||||
throw new Error("Config file could not be found at expected location. " +
|
throw new Error("Config file could not be found at expected location. " +
|
||||||
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
|
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
|
||||||
}
|
}
|
||||||
await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, util_1.parseGithubUrl(cmd.githubUrl), cmd.upload, "runner", outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger);
|
const apiDetails = {
|
||||||
|
auth: cmd.githubAuth,
|
||||||
|
url: util_1.parseGithubUrl(cmd.githubUrl),
|
||||||
|
};
|
||||||
|
await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, apiDetails, cmd.upload, "runner", outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error("Analyze failed");
|
logger.error("Analyze failed");
|
||||||
|
|
@ -240,8 +248,12 @@ program
|
||||||
.option("--debug", "Print more verbose output", false)
|
.option("--debug", "Print more verbose output", false)
|
||||||
.action(async (cmd) => {
|
.action(async (cmd) => {
|
||||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||||
|
const apiDetails = {
|
||||||
|
auth: cmd.githubAuth,
|
||||||
|
url: util_1.parseGithubUrl(cmd.githubUrl),
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, util_1.parseGithubUrl(cmd.githubUrl), "runner", logger);
|
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, apiDetails, "runner", logger);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error("Upload failed");
|
logger.error("Upload failed");
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
12
lib/upload-lib.js
generated
12
lib/upload-lib.js
generated
|
|
@ -43,14 +43,14 @@ function combineSarifFiles(sarifFiles) {
|
||||||
exports.combineSarifFiles = combineSarifFiles;
|
exports.combineSarifFiles = combineSarifFiles;
|
||||||
// Upload the given payload.
|
// Upload the given payload.
|
||||||
// If the request fails then this will retry a small number of times.
|
// If the request fails then this will retry a small number of times.
|
||||||
async function uploadPayload(payload, repositoryNwo, githubAuth, githubUrl, mode, logger) {
|
async function uploadPayload(payload, repositoryNwo, apiDetails, mode, logger) {
|
||||||
logger.info("Uploading results");
|
logger.info("Uploading results");
|
||||||
// If in test mode we don't want to upload the results
|
// If in test mode we don't want to upload the results
|
||||||
const testMode = process.env["TEST_MODE"] === "true" || false;
|
const testMode = process.env["TEST_MODE"] === "true" || false;
|
||||||
if (testMode) {
|
if (testMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const client = api.getApiClient(githubAuth, githubUrl, mode, logger);
|
const client = api.getApiClient(apiDetails, mode, logger);
|
||||||
const reqURL = mode === "actions"
|
const reqURL = mode === "actions"
|
||||||
? "PUT /repos/:owner/:repo/code-scanning/analysis"
|
? "PUT /repos/:owner/:repo/code-scanning/analysis"
|
||||||
: "POST /repos/:owner/:repo/code-scanning/sarifs";
|
: "POST /repos/:owner/:repo/code-scanning/sarifs";
|
||||||
|
|
@ -65,7 +65,7 @@ async function uploadPayload(payload, repositoryNwo, githubAuth, githubUrl, mode
|
||||||
// Uploads a single sarif file or a directory of sarif files
|
// Uploads a single sarif file or a directory of sarif files
|
||||||
// depending on what the path happens to refer to.
|
// depending on what the path happens to refer to.
|
||||||
// Returns true iff the upload occurred and succeeded
|
// Returns true iff the upload occurred and succeeded
|
||||||
async function upload(sarifPath, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger) {
|
async function upload(sarifPath, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, apiDetails, mode, logger) {
|
||||||
const sarifFiles = [];
|
const sarifFiles = [];
|
||||||
if (!fs.existsSync(sarifPath)) {
|
if (!fs.existsSync(sarifPath)) {
|
||||||
throw new Error(`Path does not exist: ${sarifPath}`);
|
throw new Error(`Path does not exist: ${sarifPath}`);
|
||||||
|
|
@ -85,7 +85,7 @@ async function upload(sarifPath, repositoryNwo, commitOid, ref, analysisKey, ana
|
||||||
else {
|
else {
|
||||||
sarifFiles.push(sarifPath);
|
sarifFiles.push(sarifPath);
|
||||||
}
|
}
|
||||||
return await uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger);
|
return await uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, apiDetails, mode, logger);
|
||||||
}
|
}
|
||||||
exports.upload = upload;
|
exports.upload = upload;
|
||||||
// Counts the number of results in the given SARIF file
|
// Counts the number of results in the given SARIF file
|
||||||
|
|
@ -119,7 +119,7 @@ function validateSarifFileSchema(sarifFilePath, logger) {
|
||||||
exports.validateSarifFileSchema = validateSarifFileSchema;
|
exports.validateSarifFileSchema = validateSarifFileSchema;
|
||||||
// Uploads the given set of sarif files.
|
// Uploads the given set of sarif files.
|
||||||
// Returns true iff the upload occurred and succeeded
|
// Returns true iff the upload occurred and succeeded
|
||||||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger) {
|
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, apiDetails, mode, logger) {
|
||||||
logger.info(`Uploading sarif files: ${JSON.stringify(sarifFiles)}`);
|
logger.info(`Uploading sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||||
if (mode === "actions") {
|
if (mode === "actions") {
|
||||||
// This check only works on actions as env vars don't persist between calls to the runner
|
// This check only works on actions as env vars don't persist between calls to the runner
|
||||||
|
|
@ -170,7 +170,7 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
||||||
const numResultInSarif = countResultsInSarif(sarifPayload);
|
const numResultInSarif = countResultsInSarif(sarifPayload);
|
||||||
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
||||||
// Make the upload
|
// Make the upload
|
||||||
await uploadPayload(payload, repositoryNwo, githubAuth, githubUrl, mode, logger);
|
await uploadPayload(payload, repositoryNwo, apiDetails, mode, logger);
|
||||||
return {
|
return {
|
||||||
raw_upload_size_bytes: rawUploadSizeBytes,
|
raw_upload_size_bytes: rawUploadSizeBytes,
|
||||||
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
6
lib/upload-sarif-action.js
generated
6
lib/upload-sarif-action.js
generated
|
|
@ -26,7 +26,11 @@ async function run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const uploadStats = await upload_lib.upload(actionsUtil.getRequiredInput("sarif_file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), "actions", logging_1.getActionsLogger());
|
const apiDetails = {
|
||||||
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
|
};
|
||||||
|
const uploadStats = await upload_lib.upload(actionsUtil.getRequiredInput("sarif_file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), apiDetails, "actions", logging_1.getActionsLogger());
|
||||||
await sendSuccessStatusReport(startedAt, uploadStats);
|
await sendSuccessStatusReport(startedAt, uploadStats);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAM3C,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,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AW,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,EAClD,WAAW,CAAC,gBAAgB,EAAE,EAC9B,WAAW,CAAC,gBAAgB,CAAC,eAAe,CAAC,EAC7C,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EACtC,UAAU,EACV,SAAS,EACT,0BAAgB,EAAE,CACnB,CAAC;QACF,MAAM,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;KACvD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,SAAS,EACT,SAAS,EACT,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,KAAK,CACZ,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,IAAI,CAAC,SAAS,CAAC,sCAAsC,CAAC,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||||
|
|
@ -64,6 +64,10 @@ async function run() {
|
||||||
"Config file could not be found at expected location. Has the 'init' action been called?"
|
"Config file could not be found at expected location. Has the 'init' action been called?"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const apiDetails = {
|
||||||
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
|
};
|
||||||
stats = await runAnalyze(
|
stats = await runAnalyze(
|
||||||
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||||
await actionsUtil.getCommitOid(),
|
await actionsUtil.getCommitOid(),
|
||||||
|
|
@ -73,8 +77,7 @@ async function run() {
|
||||||
actionsUtil.getWorkflowRunID(),
|
actionsUtil.getWorkflowRunID(),
|
||||||
actionsUtil.getRequiredInput("checkout_path"),
|
actionsUtil.getRequiredInput("checkout_path"),
|
||||||
actionsUtil.getRequiredInput("matrix"),
|
actionsUtil.getRequiredInput("matrix"),
|
||||||
actionsUtil.getRequiredInput("token"),
|
apiDetails,
|
||||||
actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
actionsUtil.getRequiredInput("upload") === "true",
|
actionsUtil.getRequiredInput("upload") === "true",
|
||||||
"actions",
|
"actions",
|
||||||
actionsUtil.getRequiredInput("output"),
|
actionsUtil.getRequiredInput("output"),
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import * as path from "path";
|
||||||
import * as toolrunner from "@actions/exec/lib/toolrunner";
|
import * as toolrunner from "@actions/exec/lib/toolrunner";
|
||||||
|
|
||||||
import * as analysisPaths from "./analysis-paths";
|
import * as analysisPaths from "./analysis-paths";
|
||||||
|
import { GitHubApiDetails } from "./api-client";
|
||||||
import { getCodeQL } from "./codeql";
|
import { getCodeQL } from "./codeql";
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import { isScannedLanguage, Language } from "./languages";
|
import { isScannedLanguage, Language } from "./languages";
|
||||||
|
|
@ -224,8 +225,7 @@ export async function runAnalyze(
|
||||||
workflowRunID: number | undefined,
|
workflowRunID: number | undefined,
|
||||||
checkoutPath: string,
|
checkoutPath: string,
|
||||||
environment: string | undefined,
|
environment: string | undefined,
|
||||||
githubAuth: string,
|
apiDetails: GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
doUpload: boolean,
|
doUpload: boolean,
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
outputDir: string,
|
outputDir: string,
|
||||||
|
|
@ -268,8 +268,7 @@ export async function runAnalyze(
|
||||||
workflowRunID,
|
workflowRunID,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
environment,
|
environment,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
mode,
|
mode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,18 @@ export enum DisallowedAPIVersionReason {
|
||||||
ACTION_TOO_NEW,
|
ACTION_TOO_NEW,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GitHubApiDetails {
|
||||||
|
auth: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
|
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
|
||||||
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR =
|
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR =
|
||||||
"CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
"CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||||
let hasBeenWarnedAboutVersion = false;
|
let hasBeenWarnedAboutVersion = false;
|
||||||
|
|
||||||
export const getApiClient = function (
|
export const getApiClient = function (
|
||||||
githubAuth: string,
|
apiDetails: GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
allowLocalRun = false,
|
allowLocalRun = false,
|
||||||
|
|
@ -78,8 +82,8 @@ export const getApiClient = function (
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return new customOctokit(
|
return new customOctokit(
|
||||||
githubUtils.getOctokitOptions(githubAuth, {
|
githubUtils.getOctokitOptions(apiDetails.auth, {
|
||||||
baseUrl: getApiUrl(githubUrl),
|
baseUrl: getApiUrl(apiDetails.url),
|
||||||
userAgent: "CodeQL Action",
|
userAgent: "CodeQL Action",
|
||||||
log: consoleLogLevel({ level: "debug" }),
|
log: consoleLogLevel({ level: "debug" }),
|
||||||
})
|
})
|
||||||
|
|
@ -104,13 +108,12 @@ function getApiUrl(githubUrl: string): string {
|
||||||
// Once all code has been converted this function should be removed or made canonical
|
// Once all code has been converted this function should be removed or made canonical
|
||||||
// and called only from the action entrypoints.
|
// and called only from the action entrypoints.
|
||||||
export function getActionsApiClient(allowLocalRun = false) {
|
export function getActionsApiClient(allowLocalRun = false) {
|
||||||
return getApiClient(
|
const apiDetails = {
|
||||||
getRequiredInput("token"),
|
auth: getRequiredInput("token"),
|
||||||
getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
"actions",
|
};
|
||||||
getActionsLogger(),
|
|
||||||
allowLocalRun
|
return getApiClient(apiDetails, "actions", getActionsLogger(), allowLocalRun);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function apiVersionInRange(
|
export function apiVersionInRange(
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,11 @@ import * as util from "./util";
|
||||||
|
|
||||||
setupTests(test);
|
setupTests(test);
|
||||||
|
|
||||||
|
const sampleApiDetails = {
|
||||||
|
auth: "token",
|
||||||
|
url: "https://github.com",
|
||||||
|
};
|
||||||
|
|
||||||
test("download codeql bundle cache", async (t) => {
|
test("download codeql bundle cache", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
const versions = ["20200601", "20200610"];
|
const versions = ["20200601", "20200610"];
|
||||||
|
|
@ -28,8 +33,7 @@ test("download codeql bundle cache", async (t) => {
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`,
|
`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -56,8 +60,7 @@ test("download codeql bundle cache explicitly requested with pinned different ve
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -75,8 +78,7 @@ test("download codeql bundle cache explicitly requested with pinned different ve
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
"https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz",
|
"https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz",
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -98,8 +100,7 @@ test("don't download codeql bundle cache with pinned different version cached",
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -110,8 +111,7 @@ test("don't download codeql bundle cache with pinned different version cached",
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
undefined,
|
undefined,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -135,8 +135,7 @@ test("download codeql bundle cache with different version cached (not pinned)",
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -162,8 +161,7 @@ test("download codeql bundle cache with different version cached (not pinned)",
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
undefined,
|
undefined,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -187,8 +185,7 @@ test('download codeql bundle cache with pinned different version cached if "late
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -215,8 +212,7 @@ test('download codeql bundle cache with pinned different version cached if "late
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
await codeql.setupCodeQL(
|
||||||
"latest",
|
"latest",
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.com",
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
|
||||||
|
|
@ -160,17 +160,16 @@ function getCodeQLActionRepository(mode: util.Mode, logger: Logger): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCodeQLBundleDownloadURL(
|
async function getCodeQLBundleDownloadURL(
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
||||||
const potentialDownloadSources = [
|
const potentialDownloadSources = [
|
||||||
// This GitHub instance, and this Action.
|
// This GitHub instance, and this Action.
|
||||||
[githubUrl, codeQLActionRepository],
|
[apiDetails.url, codeQLActionRepository],
|
||||||
// This GitHub instance, and the canonical Action.
|
// This GitHub instance, and the canonical Action.
|
||||||
[githubUrl, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
[apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||||
// GitHub.com, and the canonical Action.
|
// GitHub.com, and the canonical Action.
|
||||||
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||||
];
|
];
|
||||||
|
|
@ -192,7 +191,7 @@ async function getCodeQLBundleDownloadURL(
|
||||||
const [repositoryOwner, repositoryName] = repository.split("/");
|
const [repositoryOwner, repositoryName] = repository.split("/");
|
||||||
try {
|
try {
|
||||||
const release = await api
|
const release = await api
|
||||||
.getApiClient(githubAuth, githubUrl, mode, logger, false, true)
|
.getApiClient(apiDetails, mode, logger, false, true)
|
||||||
.repos.getReleaseByTag({
|
.repos.getReleaseByTag({
|
||||||
owner: repositoryOwner,
|
owner: repositoryOwner,
|
||||||
repo: repositoryName,
|
repo: repositoryName,
|
||||||
|
|
@ -240,8 +239,7 @@ async function toolcacheDownloadTool(
|
||||||
|
|
||||||
export async function setupCodeQL(
|
export async function setupCodeQL(
|
||||||
codeqlURL: string | undefined,
|
codeqlURL: string | undefined,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
toolsDir: string,
|
toolsDir: string,
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
|
|
@ -289,21 +287,16 @@ export async function setupCodeQL(
|
||||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||||
} else {
|
} else {
|
||||||
if (!codeqlURL) {
|
if (!codeqlURL) {
|
||||||
codeqlURL = await getCodeQLBundleDownloadURL(
|
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, logger);
|
||||||
githubAuth,
|
|
||||||
githubUrl,
|
|
||||||
mode,
|
|
||||||
logger
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers: IHeaders = { accept: "application/octet-stream" };
|
const headers: IHeaders = { accept: "application/octet-stream" };
|
||||||
// We only want to provide an authorization header if we are downloading
|
// We only want to provide an authorization header if we are downloading
|
||||||
// from the same GitHub instance the Action is running on.
|
// from the same GitHub instance the Action is running on.
|
||||||
// This avoids leaking Enterprise tokens to dotcom.
|
// This avoids leaking Enterprise tokens to dotcom.
|
||||||
if (codeqlURL.startsWith(`${githubUrl}/`)) {
|
if (codeqlURL.startsWith(`${apiDetails.url}/`)) {
|
||||||
logger.debug("Downloading CodeQL bundle with token.");
|
logger.debug("Downloading CodeQL bundle with token.");
|
||||||
headers.authorization = `token ${githubAuth}`;
|
headers.authorization = `token ${apiDetails.auth}`;
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Downloading CodeQL bundle without token.");
|
logger.debug("Downloading CodeQL bundle without token.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ import * as util from "./util";
|
||||||
|
|
||||||
setupTests(test);
|
setupTests(test);
|
||||||
|
|
||||||
|
const sampleApiDetails = {
|
||||||
|
auth: "token",
|
||||||
|
url: "https://github.example.com",
|
||||||
|
};
|
||||||
|
|
||||||
// Returns the filepath of the newly-created file
|
// Returns the filepath of the newly-created file
|
||||||
function createConfigFile(inputFileContents: string, tmpDir: string): string {
|
function createConfigFile(inputFileContents: string, tmpDir: string): string {
|
||||||
const configFilePath = path.join(tmpDir, "input");
|
const configFilePath = path.join(tmpDir, "input");
|
||||||
|
|
@ -76,8 +81,7 @@ test("load empty config", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -92,8 +96,7 @@ test("load empty config", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
logger
|
logger
|
||||||
)
|
)
|
||||||
|
|
@ -130,8 +133,7 @@ test("loading config saves config", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -157,8 +159,7 @@ test("load input outside of workspace", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -191,8 +192,7 @@ test("load non-local input with invalid repo syntax", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -226,8 +226,7 @@ test("load non-existent input", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -311,8 +310,7 @@ test("load non-empty input", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -373,8 +371,7 @@ test("Default queries are used", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -443,8 +440,7 @@ test("Queries can be specified in config file", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -507,8 +503,7 @@ test("Queries from config file can be overridden in workflow file", async (t) =>
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -569,8 +564,7 @@ test("Queries in workflow file can be used in tandem with the 'disable default q
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -621,8 +615,7 @@ test("Multiple queries can be specified in workflow file, no config file require
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -691,8 +684,7 @@ test("Queries in workflow file can be added to the set of queries without overri
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -754,8 +746,7 @@ test("Invalid queries in workflow file handled correctly", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -817,8 +808,7 @@ test("API client used when reading remote config", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -842,8 +832,7 @@ test("Remote config handles the case where a directory is provided", async (t) =
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -875,8 +864,7 @@ test("Invalid format of remote config handled correctly", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -904,8 +892,7 @@ test("No detected languages", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -930,8 +917,7 @@ test("Unknown languages", async (t) => {
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
@ -977,8 +963,7 @@ function doInvalidInputTest(
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
"token",
|
sampleApiDetails,
|
||||||
"https://github.example.com",
|
|
||||||
"runner",
|
"runner",
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -591,14 +591,13 @@ export function getUnknownLanguagesError(languages: string[]): string {
|
||||||
*/
|
*/
|
||||||
async function getLanguagesInRepo(
|
async function getLanguagesInRepo(
|
||||||
repository: RepositoryNwo,
|
repository: RepositoryNwo,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<Language[]> {
|
): Promise<Language[]> {
|
||||||
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
||||||
const response = await api
|
const response = await api
|
||||||
.getApiClient(githubAuth, githubUrl, mode, logger, true)
|
.getApiClient(apiDetails, mode, logger, true)
|
||||||
.repos.listLanguages({
|
.repos.listLanguages({
|
||||||
owner: repository.owner,
|
owner: repository.owner,
|
||||||
repo: repository.repo,
|
repo: repository.repo,
|
||||||
|
|
@ -633,8 +632,7 @@ async function getLanguagesInRepo(
|
||||||
async function getLanguages(
|
async function getLanguages(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
repository: RepositoryNwo,
|
repository: RepositoryNwo,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<Language[]> {
|
): Promise<Language[]> {
|
||||||
|
|
@ -647,13 +645,7 @@ async function getLanguages(
|
||||||
|
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
// Obtain languages as all languages in the repo that can be analysed
|
// Obtain languages as all languages in the repo that can be analysed
|
||||||
languages = await getLanguagesInRepo(
|
languages = await getLanguagesInRepo(repository, apiDetails, mode, logger);
|
||||||
repository,
|
|
||||||
githubAuth,
|
|
||||||
githubUrl,
|
|
||||||
mode,
|
|
||||||
logger
|
|
||||||
);
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`Automatically detected languages: ${JSON.stringify(languages)}`
|
`Automatically detected languages: ${JSON.stringify(languages)}`
|
||||||
);
|
);
|
||||||
|
|
@ -734,16 +726,14 @@ export async function getDefaultConfig(
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
checkoutPath: string,
|
checkoutPath: string,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<Config> {
|
): Promise<Config> {
|
||||||
const languages = await getLanguages(
|
const languages = await getLanguages(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
repository,
|
repository,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
mode,
|
mode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -757,7 +747,7 @@ export async function getDefaultConfig(
|
||||||
queries,
|
queries,
|
||||||
tempDir,
|
tempDir,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
githubUrl,
|
apiDetails.url,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -786,8 +776,7 @@ async function loadConfig(
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
checkoutPath: string,
|
checkoutPath: string,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<Config> {
|
): Promise<Config> {
|
||||||
|
|
@ -798,13 +787,7 @@ async function loadConfig(
|
||||||
configFile = path.resolve(checkoutPath, configFile);
|
configFile = path.resolve(checkoutPath, configFile);
|
||||||
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
||||||
} else {
|
} else {
|
||||||
parsedYAML = await getRemoteConfig(
|
parsedYAML = await getRemoteConfig(configFile, apiDetails, mode, logger);
|
||||||
configFile,
|
|
||||||
githubAuth,
|
|
||||||
githubUrl,
|
|
||||||
mode,
|
|
||||||
logger
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate that the 'name' property is syntactically correct,
|
// Validate that the 'name' property is syntactically correct,
|
||||||
|
|
@ -821,8 +804,7 @@ async function loadConfig(
|
||||||
const languages = await getLanguages(
|
const languages = await getLanguages(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
repository,
|
repository,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
mode,
|
mode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -854,7 +836,7 @@ async function loadConfig(
|
||||||
queries,
|
queries,
|
||||||
tempDir,
|
tempDir,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
githubUrl,
|
apiDetails.url,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -879,7 +861,7 @@ async function loadConfig(
|
||||||
query[QUERIES_USES_PROPERTY],
|
query[QUERIES_USES_PROPERTY],
|
||||||
tempDir,
|
tempDir,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
githubUrl,
|
apiDetails.url,
|
||||||
logger,
|
logger,
|
||||||
configFile
|
configFile
|
||||||
);
|
);
|
||||||
|
|
@ -961,8 +943,7 @@ export async function initConfig(
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
checkoutPath: string,
|
checkoutPath: string,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<Config> {
|
): Promise<Config> {
|
||||||
|
|
@ -979,8 +960,7 @@ export async function initConfig(
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
mode,
|
mode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -994,8 +974,7 @@ export async function initConfig(
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
mode,
|
mode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -1031,8 +1010,7 @@ function getLocalConfig(configFile: string, checkoutPath: string): UserConfig {
|
||||||
|
|
||||||
async function getRemoteConfig(
|
async function getRemoteConfig(
|
||||||
configFile: string,
|
configFile: string,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<UserConfig> {
|
): Promise<UserConfig> {
|
||||||
|
|
@ -1047,7 +1025,7 @@ async function getRemoteConfig(
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await api
|
const response = await api
|
||||||
.getApiClient(githubAuth, githubUrl, mode, logger, true)
|
.getApiClient(apiDetails, mode, logger, true)
|
||||||
.repos.getContent({
|
.repos.getContent({
|
||||||
owner: pieces.groups.owner,
|
owner: pieces.groups.owner,
|
||||||
repo: pieces.groups.repo,
|
repo: pieces.groups.repo,
|
||||||
|
|
|
||||||
|
|
@ -104,10 +104,14 @@ async function run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const apiDetails = {
|
||||||
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
|
};
|
||||||
|
|
||||||
const initCodeQLResult = await initCodeQL(
|
const initCodeQLResult = await initCodeQL(
|
||||||
actionsUtil.getOptionalInput("tools"),
|
actionsUtil.getOptionalInput("tools"),
|
||||||
actionsUtil.getRequiredInput("token"),
|
apiDetails,
|
||||||
actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
||||||
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||||
"actions",
|
"actions",
|
||||||
|
|
@ -125,8 +129,7 @@ async function run() {
|
||||||
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||||
codeql,
|
codeql,
|
||||||
actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"),
|
actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"),
|
||||||
actionsUtil.getRequiredInput("token"),
|
apiDetails,
|
||||||
actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
"actions",
|
"actions",
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
|
||||||
13
src/init.ts
13
src/init.ts
|
|
@ -5,6 +5,7 @@ import * as toolrunner from "@actions/exec/lib/toolrunner";
|
||||||
import * as safeWhich from "@chrisgavin/safe-which";
|
import * as safeWhich from "@chrisgavin/safe-which";
|
||||||
|
|
||||||
import * as analysisPaths from "./analysis-paths";
|
import * as analysisPaths from "./analysis-paths";
|
||||||
|
import { GitHubApiDetails } from "./api-client";
|
||||||
import { CodeQL, setupCodeQL } from "./codeql";
|
import { CodeQL, setupCodeQL } from "./codeql";
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
|
@ -14,8 +15,7 @@ import * as util from "./util";
|
||||||
|
|
||||||
export async function initCodeQL(
|
export async function initCodeQL(
|
||||||
codeqlURL: string | undefined,
|
codeqlURL: string | undefined,
|
||||||
githubAuth: string,
|
apiDetails: GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
toolsDir: string,
|
toolsDir: string,
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
|
|
@ -24,8 +24,7 @@ export async function initCodeQL(
|
||||||
logger.startGroup("Setup CodeQL tools");
|
logger.startGroup("Setup CodeQL tools");
|
||||||
const { codeql, toolsVersion } = await setupCodeQL(
|
const { codeql, toolsVersion } = await setupCodeQL(
|
||||||
codeqlURL,
|
codeqlURL,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
tempDir,
|
tempDir,
|
||||||
toolsDir,
|
toolsDir,
|
||||||
mode,
|
mode,
|
||||||
|
|
@ -45,8 +44,7 @@ export async function initConfig(
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
checkoutPath: string,
|
checkoutPath: string,
|
||||||
githubAuth: string,
|
apiDetails: GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<configUtils.Config> {
|
): Promise<configUtils.Config> {
|
||||||
|
|
@ -60,8 +58,7 @@ export async function initConfig(
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
mode,
|
mode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,11 @@ program
|
||||||
fs.rmdirSync(tempDir, { recursive: true });
|
fs.rmdirSync(tempDir, { recursive: true });
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
|
|
||||||
|
const apiDetails = {
|
||||||
|
auth: cmd.githubAuth,
|
||||||
|
url: parseGithubUrl(cmd.githubUrl),
|
||||||
|
};
|
||||||
|
|
||||||
let codeql: CodeQL;
|
let codeql: CodeQL;
|
||||||
if (cmd.codeqlPath !== undefined) {
|
if (cmd.codeqlPath !== undefined) {
|
||||||
codeql = getCodeQL(cmd.codeqlPath);
|
codeql = getCodeQL(cmd.codeqlPath);
|
||||||
|
|
@ -153,8 +158,7 @@ program
|
||||||
codeql = (
|
codeql = (
|
||||||
await initCodeQL(
|
await initCodeQL(
|
||||||
undefined,
|
undefined,
|
||||||
cmd.githubAuth,
|
apiDetails,
|
||||||
parseGithubUrl(cmd.githubUrl),
|
|
||||||
tempDir,
|
tempDir,
|
||||||
toolsDir,
|
toolsDir,
|
||||||
"runner",
|
"runner",
|
||||||
|
|
@ -172,8 +176,7 @@ program
|
||||||
toolsDir,
|
toolsDir,
|
||||||
codeql,
|
codeql,
|
||||||
cmd.checkoutPath || process.cwd(),
|
cmd.checkoutPath || process.cwd(),
|
||||||
cmd.githubAuth,
|
apiDetails,
|
||||||
parseGithubUrl(cmd.githubUrl),
|
|
||||||
"runner",
|
"runner",
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -362,6 +365,12 @@ program
|
||||||
"Was the 'init' command run with the same '--temp-dir' argument as this command."
|
"Was the 'init' command run with the same '--temp-dir' argument as this command."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const apiDetails = {
|
||||||
|
auth: cmd.githubAuth,
|
||||||
|
url: parseGithubUrl(cmd.githubUrl),
|
||||||
|
};
|
||||||
|
|
||||||
await runAnalyze(
|
await runAnalyze(
|
||||||
parseRepositoryNwo(cmd.repository),
|
parseRepositoryNwo(cmd.repository),
|
||||||
cmd.commit,
|
cmd.commit,
|
||||||
|
|
@ -371,8 +380,7 @@ program
|
||||||
undefined,
|
undefined,
|
||||||
cmd.checkoutPath || process.cwd(),
|
cmd.checkoutPath || process.cwd(),
|
||||||
undefined,
|
undefined,
|
||||||
cmd.githubAuth,
|
apiDetails,
|
||||||
parseGithubUrl(cmd.githubUrl),
|
|
||||||
cmd.upload,
|
cmd.upload,
|
||||||
"runner",
|
"runner",
|
||||||
outputDir,
|
outputDir,
|
||||||
|
|
@ -427,6 +435,10 @@ program
|
||||||
.option("--debug", "Print more verbose output", false)
|
.option("--debug", "Print more verbose output", false)
|
||||||
.action(async (cmd: UploadArgs) => {
|
.action(async (cmd: UploadArgs) => {
|
||||||
const logger = getRunnerLogger(cmd.debug);
|
const logger = getRunnerLogger(cmd.debug);
|
||||||
|
const apiDetails = {
|
||||||
|
auth: cmd.githubAuth,
|
||||||
|
url: parseGithubUrl(cmd.githubUrl),
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
await upload_lib.upload(
|
await upload_lib.upload(
|
||||||
cmd.sarifFile,
|
cmd.sarifFile,
|
||||||
|
|
@ -438,8 +450,7 @@ program
|
||||||
undefined,
|
undefined,
|
||||||
cmd.checkoutPath || process.cwd(),
|
cmd.checkoutPath || process.cwd(),
|
||||||
undefined,
|
undefined,
|
||||||
cmd.githubAuth,
|
apiDetails,
|
||||||
parseGithubUrl(cmd.githubUrl),
|
|
||||||
"runner",
|
"runner",
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,7 @@ export function combineSarifFiles(sarifFiles: string[]): string {
|
||||||
async function uploadPayload(
|
async function uploadPayload(
|
||||||
payload: any,
|
payload: any,
|
||||||
repositoryNwo: RepositoryNwo,
|
repositoryNwo: RepositoryNwo,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
) {
|
) {
|
||||||
|
|
@ -56,7 +55,7 @@ async function uploadPayload(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = api.getApiClient(githubAuth, githubUrl, mode, logger);
|
const client = api.getApiClient(apiDetails, mode, logger);
|
||||||
|
|
||||||
const reqURL =
|
const reqURL =
|
||||||
mode === "actions"
|
mode === "actions"
|
||||||
|
|
@ -94,8 +93,7 @@ export async function upload(
|
||||||
workflowRunID: number | undefined,
|
workflowRunID: number | undefined,
|
||||||
checkoutPath: string,
|
checkoutPath: string,
|
||||||
environment: string | undefined,
|
environment: string | undefined,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<UploadStatusReport> {
|
): Promise<UploadStatusReport> {
|
||||||
|
|
@ -128,8 +126,7 @@ export async function upload(
|
||||||
workflowRunID,
|
workflowRunID,
|
||||||
checkoutPath,
|
checkoutPath,
|
||||||
environment,
|
environment,
|
||||||
githubAuth,
|
apiDetails,
|
||||||
githubUrl,
|
|
||||||
mode,
|
mode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
|
@ -182,8 +179,7 @@ async function uploadFiles(
|
||||||
workflowRunID: number | undefined,
|
workflowRunID: number | undefined,
|
||||||
checkoutPath: string,
|
checkoutPath: string,
|
||||||
environment: string | undefined,
|
environment: string | undefined,
|
||||||
githubAuth: string,
|
apiDetails: api.GitHubApiDetails,
|
||||||
githubUrl: string,
|
|
||||||
mode: util.Mode,
|
mode: util.Mode,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<UploadStatusReport> {
|
): Promise<UploadStatusReport> {
|
||||||
|
|
@ -250,14 +246,7 @@ async function uploadFiles(
|
||||||
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
||||||
|
|
||||||
// Make the upload
|
// Make the upload
|
||||||
await uploadPayload(
|
await uploadPayload(payload, repositoryNwo, apiDetails, mode, logger);
|
||||||
payload,
|
|
||||||
repositoryNwo,
|
|
||||||
githubAuth,
|
|
||||||
githubUrl,
|
|
||||||
mode,
|
|
||||||
logger
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
raw_upload_size_bytes: rawUploadSizeBytes,
|
raw_upload_size_bytes: rawUploadSizeBytes,
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const apiDetails = {
|
||||||
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
|
};
|
||||||
|
|
||||||
const uploadStats = await upload_lib.upload(
|
const uploadStats = await upload_lib.upload(
|
||||||
actionsUtil.getRequiredInput("sarif_file"),
|
actionsUtil.getRequiredInput("sarif_file"),
|
||||||
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||||
|
|
@ -50,8 +55,7 @@ async function run() {
|
||||||
actionsUtil.getWorkflowRunID(),
|
actionsUtil.getWorkflowRunID(),
|
||||||
actionsUtil.getRequiredInput("checkout_path"),
|
actionsUtil.getRequiredInput("checkout_path"),
|
||||||
actionsUtil.getRequiredInput("matrix"),
|
actionsUtil.getRequiredInput("matrix"),
|
||||||
actionsUtil.getRequiredInput("token"),
|
apiDetails,
|
||||||
actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
"actions",
|
"actions",
|
||||||
getActionsLogger()
|
getActionsLogger()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue