Merge branch 'cbraynor/fix206' into cbraynor/fix201

This commit is contained in:
Chris Raynor 2020-10-01 11:17:59 +01:00
commit 6d01157d11
No known key found for this signature in database
GPG key ID: 579A1FBC36FDA261
84 changed files with 281 additions and 239 deletions

View file

@ -1,8 +1,7 @@
import * as actionsutil from "./actions-util";
import sinon from "sinon";
import test from "ava";
import sinon from "sinon";
import * as actionsutil from "./actions-util";
import { setupTests } from "./testing-utils";
setupTests(test);

View file

@ -1,8 +1,8 @@
import * as api from "./api-client";
import * as core from "@actions/core";
import * as sharedEnv from "./shared-environment";
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import * as api from "./api-client";
import * as sharedEnv from "./shared-environment";
import { GITHUB_DOTCOM_URL, isLocalRun } from "./util";
/**

View file

@ -1,9 +1,8 @@
import * as analysisPaths from "./analysis-paths";
import * as util from "./util";
import test from "ava";
import * as analysisPaths from "./analysis-paths";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);

View file

@ -1,5 +1,4 @@
import * as configUtils from "./config-utils";
import { Logger } from "./logging";
function isInterpretedLanguage(language): boolean {

View file

@ -1,12 +1,11 @@
import * as actionsUtil from "./actions-util";
import * as core from "@actions/core";
import * as util from "./util";
import * as actionsUtil from "./actions-util";
import { AnalysisStatusReport, runAnalyze } from "./analyze";
import { getActionsLogger } from "./logging";
import { getConfig } from "./config-utils";
import { getActionsLogger } from "./logging";
import { parseRepositoryNwo } from "./repository";
import * as util from "./util";
interface FinishStatusReport
extends actionsUtil.StatusReportBase,

View file

@ -1,14 +1,14 @@
import * as fs from "fs";
import * as util from "./util";
import test from "ava";
import { runQueries } from "./analyze";
import { setCodeQL } from "./codeql";
import { Config } from "./config-utils";
import { Language } from "./languages";
import { getRunnerLogger } from "./logging";
import { runQueries } from "./analyze";
import { setCodeQL } from "./codeql";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);

View file

@ -1,16 +1,16 @@
import * as analysisPaths from "./analysis-paths";
import * as configUtils from "./config-utils";
import * as fs from "fs";
import * as path from "path";
import * as analysisPaths from "./analysis-paths";
import { getCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { isScannedLanguage } from "./languages";
import { Logger } from "./logging";
import { RepositoryNwo } from "./repository";
import * as sharedEnv from "./shared-environment";
import * as upload_lib from "./upload-lib";
import * as util from "./util";
import { Logger } from "./logging";
import { RepositoryNwo } from "./repository";
import { getCodeQL } from "./codeql";
import { isScannedLanguage } from "./languages";
export interface QueriesStatusReport {
// Time taken in ms to analyze builtin queries for cpp (or undefined if this language was not analyzed)
analyze_builtin_queries_cpp_duration_ms?: number;

View file

@ -1,11 +1,10 @@
import * as githubUtils from "@actions/github/lib/utils";
import * as path from "path";
import * as retry from "@octokit/plugin-retry";
import * as githubUtils from "@actions/github/lib/utils";
import * as retry from "@octokit/plugin-retry";
import consoleLogLevel from "console-log-level";
import { getRequiredEnvParam, getRequiredInput } from "./actions-util";
import { isLocalRun } from "./util";
export const getApiClient = function (

View file

@ -1,9 +1,8 @@
import * as actionsUtil from "./actions-util";
import * as config_utils from "./config-utils";
import * as core from "@actions/core";
import * as actionsUtil from "./actions-util";
import { determineAutobuildLanguage, runAutobuild } from "./autobuild";
import * as config_utils from "./config-utils";
import { Language } from "./languages";
import { getActionsLogger } from "./logging";

View file

@ -1,9 +1,7 @@
import * as config_utils from "./config-utils";
import { Language, isTracedLanguage } from "./languages";
import { Logger } from "./logging";
import { getCodeQL } from "./codeql";
import * as config_utils from "./config-utils";
import { Language, isTracedLanguage } from "./languages";
import { Logger } from "./logging";
export function determineAutobuildLanguage(
config: config_utils.Config,

View file

@ -1,14 +1,14 @@
import * as path from "path";
import * as toolcache from "@actions/tool-cache";
import test from "ava";
import nock from "nock";
import * as codeql from "./codeql";
import * as defaults from "./defaults.json";
import * as path from "path";
import * as toolcache from "@actions/tool-cache";
import * as util from "./util";
import nock from "nock";
import test from "ava";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);
@ -144,10 +144,16 @@ test("download codeql bundle cache with different version cached (not pinned)",
);
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
const platform =
process.platform === "win32"
? "win64"
: process.platform === "linux"
? "linux64"
: "osx64";
nock("https://github.com")
.get(
`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle.tar.gz`
`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`
)
.replyWithFile(
200,
@ -170,7 +176,7 @@ test("download codeql bundle cache with different version cached (not pinned)",
});
});
test('download codeql bundle cache with pinned different version cached if "latests" tools specied', async (t) => {
test('download codeql bundle cache with pinned different version cached if "latests" tools specified', async (t) => {
await util.withTmpDir(async (tmpDir) => {
nock("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
@ -191,9 +197,16 @@ test('download codeql bundle cache with pinned different version cached if "late
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
const platform =
process.platform === "win32"
? "win64"
: process.platform === "linux"
? "linux64"
: "osx64";
nock("https://github.com")
.get(
`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle.tar.gz`
`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`
)
.replyWithFile(
200,

View file

@ -1,22 +1,23 @@
import * as fs from "fs";
import * as path from "path";
import * as stream from "stream";
import * as globalutil from "util";
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import * as http from "@actions/http-client";
import { IHeaders } from "@actions/http-client/interfaces";
import * as toolcache from "@actions/tool-cache";
import * as semver from "semver";
import { v4 as uuidV4 } from "uuid";
import { getRequiredEnvParam } from "./actions-util";
import * as api from "./api-client";
import * as defaults from "./defaults.json"; // Referenced from codeql-action-sync-tool!
import * as fs from "fs";
import * as globalutil from "util";
import * as http from "@actions/http-client";
import * as path from "path";
import * as semver from "semver";
import * as stream from "stream";
import * as toolcache from "@actions/tool-cache";
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import * as util from "./util";
import { IHeaders } from "@actions/http-client/interfaces";
import { errorMatchers } from "./error-matcher";
import { Language } from "./languages";
import { Logger } from "./logging";
import { errorMatchers } from "./error-matcher";
import { getRequiredEnvParam } from "./actions-util";
import { toolrunnerErrorCatcher } from "./toolrunner-error-catcher";
import { v4 as uuidV4 } from "uuid";
import * as util from "./util";
type Options = Array<string | number | boolean>;
@ -115,9 +116,22 @@ export interface ResolveQueriesOutput {
let cachedCodeQL: CodeQL | undefined = undefined;
const CODEQL_BUNDLE_VERSION = defaults.bundleVersion;
const CODEQL_BUNDLE_NAME = "codeql-bundle.tar.gz";
const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
function getCodeQLBundleName(): string {
let platform: string;
if (process.platform === "win32") {
platform = "win64";
} else if (process.platform === "linux") {
platform = "linux64";
} else if (process.platform === "darwin") {
platform = "osx64";
} else {
return "codeql-bundle.tar.gz";
}
return `codeql-bundle-${platform}.tar.gz`;
}
function getCodeQLActionRepository(mode: util.Mode): string {
if (mode !== "actions") {
return CODEQL_DEFAULT_ACTION_REPOSITORY;
@ -161,6 +175,7 @@ async function getCodeQLBundleDownloadURL(
const uniqueDownloadSources = potentialDownloadSources.filter(
(url, index, self) => index === self.indexOf(url)
);
const codeQLBundleName = getCodeQLBundleName();
for (const downloadSource of uniqueDownloadSources) {
const [apiURL, repository] = downloadSource;
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
@ -180,7 +195,7 @@ async function getCodeQLBundleDownloadURL(
tag: CODEQL_BUNDLE_VERSION,
});
for (const asset of release.data.assets) {
if (asset.name === CODEQL_BUNDLE_NAME) {
if (asset.name === codeQLBundleName) {
logger.info(
`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`
);
@ -193,7 +208,7 @@ async function getCodeQLBundleDownloadURL(
);
}
}
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${CODEQL_BUNDLE_NAME}`;
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
}
// We have to download CodeQL manually because the toolcache doesn't support Accept headers.

View file

@ -1,18 +1,17 @@
import * as api from "./api-client";
import * as configUtils from "./config-utils";
import * as fs from "fs";
import * as github from "@actions/github";
import * as path from "path";
import * as util from "./util";
import sinon from "sinon";
import * as github from "@actions/github";
import test from "ava";
import sinon from "sinon";
import * as api from "./api-client";
import { getCachedCodeQL, setCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { Language } from "./languages";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);

View file

@ -1,12 +1,12 @@
import * as api from "./api-client";
import * as externalQueries from "./external-queries";
import * as fs from "fs";
import * as path from "path";
import * as yaml from "js-yaml";
import * as api from "./api-client";
import { CodeQL, ResolveQueriesOutput } from "./codeql";
import * as externalQueries from "./external-queries";
import { Language, parseLanguage } from "./languages";
import { Logger } from "./logging";
import { RepositoryNwo } from "./repository";

View file

@ -1,13 +1,13 @@
import * as externalQueries from "./external-queries";
import * as fs from "fs";
import * as path from "path";
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import * as util from "./util";
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import test from "ava";
import * as externalQueries from "./external-queries";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);

View file

@ -1,5 +1,6 @@
import * as fs from "fs";
import * as path from "path";
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import { Logger } from "./logging";

View file

@ -1,10 +1,10 @@
import * as ava from "ava";
import * as fingerprints from "./fingerprints";
import * as fs from "fs";
import * as path from "path";
import * as ava from "ava";
import test from "ava";
import * as fingerprints from "./fingerprints";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";

View file

@ -1,10 +1,9 @@
import * as actionsUtil from "./actions-util";
import * as configUtils from "./config-utils";
import * as core from "@actions/core";
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
import * as actionsUtil from "./actions-util";
import { CodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
import { getActionsLogger } from "./logging";
import { parseRepositoryNwo } from "./repository";

View file

@ -1,15 +1,15 @@
import * as analysisPaths from "./analysis-paths";
import * as configUtils from "./config-utils";
import * as fs from "fs";
import * as path from "path";
import * as toolrunnner from "@actions/exec/lib/toolrunner";
import * as util from "./util";
import * as analysisPaths from "./analysis-paths";
import { CodeQL, setupCodeQL } from "./codeql";
import { TracerConfig, getCombinedTracerConfig } from "./tracer-config";
import * as configUtils from "./config-utils";
import { Logger } from "./logging";
import { RepositoryNwo } from "./repository";
import { TracerConfig, getCombinedTracerConfig } from "./tracer-config";
import * as util from "./util";
export async function initCodeQL(
codeqlURL: string | undefined,

View file

@ -6,7 +6,6 @@ import {
isTracedLanguage,
parseLanguage,
} from "./languages";
import { setupTests } from "./testing-utils";
setupTests(test);

View file

@ -1,19 +1,19 @@
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as upload_lib from "./upload-lib";
import { CodeQL, getCodeQL } from "./codeql";
import { Config, getConfig } from "./config-utils";
import { Language, parseLanguage } from "./languages";
import { determineAutobuildLanguage, runAutobuild } from "./autobuild";
import { getAddSnippetsFlag, getMemoryFlag, getThreadsFlag } from "./util";
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
import { Command } from "commander";
import { runAnalyze } from "./analyze";
import { determineAutobuildLanguage, runAutobuild } from "./autobuild";
import { CodeQL, getCodeQL } from "./codeql";
import { Config, getConfig } from "./config-utils";
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
import { Language, parseLanguage } from "./languages";
import { getRunnerLogger } from "./logging";
import { parseRepositoryNwo } from "./repository";
import { runAnalyze } from "./analyze";
import * as upload_lib from "./upload-lib";
import { getAddSnippetsFlag, getMemoryFlag, getThreadsFlag } from "./util";
const program = new Command();
program.version("0.0.1");

View file

@ -1,8 +1,7 @@
import * as CodeQL from "./codeql";
import { TestInterface } from "ava";
import sinon from "sinon";
import { TestInterface } from "ava";
import * as CodeQL from "./codeql";
type TestContext = {
stdoutWrite: any;

View file

@ -1,5 +1,4 @@
import * as exec from "@actions/exec";
import test from "ava";
import { ErrorMatcher } from "./error-matcher";

View file

@ -1,19 +1,18 @@
import * as configUtils from "./config-utils";
import * as fs from "fs";
import * as path from "path";
import * as util from "./util";
import test from "ava";
import { setCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { Language } from "./languages";
import { setupTests } from "./testing-utils";
import {
concatTracerConfigs,
getCombinedTracerConfig,
getTracerConfigForLanguage,
} from "./tracer-config";
import { Language } from "./languages";
import { setCodeQL } from "./codeql";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);

View file

@ -1,11 +1,10 @@
import * as configUtils from "./config-utils";
import * as fs from "fs";
import * as path from "path";
import * as util from "./util";
import { Language, isTracedLanguage } from "./languages";
import { CodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { Language, isTracedLanguage } from "./languages";
import * as util from "./util";
export type TracerConfig = {
spec: string;

View file

@ -1,9 +1,8 @@
import * as uploadLib from "./upload-lib";
import test from "ava";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as uploadLib from "./upload-lib";
setupTests(test);

View file

@ -1,17 +1,17 @@
import * as api from "./api-client";
import * as core from "@actions/core";
import * as fingerprints from "./fingerprints";
import * as fs from "fs";
import * as jsonschema from "jsonschema";
import * as path from "path";
import * as sharedEnv from "./shared-environment";
import * as util from "./util";
import fileUrl from "file-url";
import zlib from "zlib";
import * as core from "@actions/core";
import fileUrl from "file-url";
import * as jsonschema from "jsonschema";
import * as api from "./api-client";
import * as fingerprints from "./fingerprints";
import { Logger } from "./logging";
import { RepositoryNwo } from "./repository";
import * as sharedEnv from "./shared-environment";
import * as util from "./util";
// Takes a list of paths to sarif files and combines them together,
// returning the contents of the combined sarif file.

View file

@ -1,9 +1,9 @@
import * as actionsUtil from "./actions-util";
import * as core from "@actions/core";
import * as upload_lib from "./upload-lib";
import * as actionsUtil from "./actions-util";
import { getActionsLogger } from "./logging";
import { parseRepositoryNwo } from "./repository";
import * as upload_lib from "./upload-lib";
interface UploadSarifStatusReport
extends actionsUtil.StatusReportBase,

View file

@ -1,11 +1,11 @@
import * as fs from "fs";
import * as os from "os";
import * as util from "./util";
import test from "ava";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";
setupTests(test);