Merge pull request #610 from github/aibaars/refactor-checkout-path
Replace checkoutPath variable with sourceRoot/workspacePath variables
This commit is contained in:
commit
14deaf67e9
18 changed files with 100 additions and 86 deletions
41
lib/config-utils.js
generated
41
lib/config-utils.js
generated
|
|
@ -114,10 +114,10 @@ async function addBuiltinSuiteQueries(languages, codeQL, resultMap, suiteName, c
|
|||
/**
|
||||
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
||||
*/
|
||||
async function addLocalQueries(codeQL, resultMap, localQueryPath, checkoutPath, configFile) {
|
||||
async function addLocalQueries(codeQL, resultMap, localQueryPath, workspacePath, configFile) {
|
||||
// Resolve the local path against the workspace so that when this is
|
||||
// passed to codeql it resolves to exactly the path we expect it to resolve to.
|
||||
let absoluteQueryPath = path.join(checkoutPath, localQueryPath);
|
||||
let absoluteQueryPath = path.join(workspacePath, localQueryPath);
|
||||
// Check the file exists
|
||||
if (!fs.existsSync(absoluteQueryPath)) {
|
||||
throw new Error(getLocalPathDoesNotExist(configFile, localQueryPath));
|
||||
|
|
@ -125,10 +125,11 @@ async function addLocalQueries(codeQL, resultMap, localQueryPath, checkoutPath,
|
|||
// Call this after checking file exists, because it'll fail if file doesn't exist
|
||||
absoluteQueryPath = fs.realpathSync(absoluteQueryPath);
|
||||
// Check the local path doesn't jump outside the repo using '..' or symlinks
|
||||
if (!(absoluteQueryPath + path.sep).startsWith(fs.realpathSync(checkoutPath) + path.sep)) {
|
||||
if (!(absoluteQueryPath + path.sep).startsWith(fs.realpathSync(workspacePath) + path.sep)) {
|
||||
throw new Error(getLocalPathOutsideOfRepository(configFile, localQueryPath));
|
||||
}
|
||||
await runResolveQueries(codeQL, resultMap, [absoluteQueryPath], checkoutPath);
|
||||
const extraSearchPath = workspacePath;
|
||||
await runResolveQueries(codeQL, resultMap, [absoluteQueryPath], extraSearchPath);
|
||||
}
|
||||
/**
|
||||
* Retrieve the set of queries at the referenced remote repo and add them to resultMap.
|
||||
|
|
@ -166,14 +167,14 @@ async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetail
|
|||
* local paths starting with './', or references to remote repos, or
|
||||
* a finite set of hardcoded terms for builtin suites.
|
||||
*/
|
||||
async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir, checkoutPath, apiDetails, logger, configFile) {
|
||||
async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir, workspacePath, apiDetails, logger, configFile) {
|
||||
queryUses = queryUses.trim();
|
||||
if (queryUses === "") {
|
||||
throw new Error(getQueryUsesInvalid(configFile));
|
||||
}
|
||||
// Check for the local path case before we start trying to parse the repository name
|
||||
if (queryUses.startsWith("./")) {
|
||||
await addLocalQueries(codeQL, resultMap, queryUses.slice(2), checkoutPath, configFile);
|
||||
await addLocalQueries(codeQL, resultMap, queryUses.slice(2), workspacePath, configFile);
|
||||
return;
|
||||
}
|
||||
// Check for one of the builtin suites
|
||||
|
|
@ -390,12 +391,12 @@ async function getLanguages(codeQL, languagesInput, repository, apiDetails, logg
|
|||
}
|
||||
return parsedLanguages;
|
||||
}
|
||||
async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap, tempDir, checkoutPath, apiDetails, logger) {
|
||||
async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap, tempDir, workspacePath, apiDetails, logger) {
|
||||
queriesInput = queriesInput.trim();
|
||||
// "+" means "don't override config file" - see shouldAddConfigFileQueries
|
||||
queriesInput = queriesInput.replace(/^\+/, "");
|
||||
for (const query of queriesInput.split(",")) {
|
||||
await parseQueryUses(languages, codeQL, resultMap, query, tempDir, checkoutPath, apiDetails, logger);
|
||||
await parseQueryUses(languages, codeQL, resultMap, query, tempDir, workspacePath, apiDetails, logger);
|
||||
}
|
||||
}
|
||||
// Returns true if either no queries were provided in the workflow.
|
||||
|
|
@ -411,7 +412,7 @@ function shouldAddConfigFileQueries(queriesInput) {
|
|||
/**
|
||||
* Get the default config for when the user has not supplied one.
|
||||
*/
|
||||
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||
var _a;
|
||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
||||
const queries = {};
|
||||
|
|
@ -423,7 +424,7 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||
}
|
||||
await addDefaultQueries(codeQL, languages, queries);
|
||||
if (queriesInput) {
|
||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, workspacePath, apiDetails, logger);
|
||||
}
|
||||
const packs = (_a = parsePacksFromInput(packsInput, languages), (_a !== null && _a !== void 0 ? _a : {}));
|
||||
return {
|
||||
|
|
@ -444,13 +445,13 @@ exports.getDefaultConfig = getDefaultConfig;
|
|||
/**
|
||||
* Load the config from the given file.
|
||||
*/
|
||||
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||
var _a;
|
||||
let parsedYAML;
|
||||
if (isLocal(configFile)) {
|
||||
// Treat the config file as relative to the workspace
|
||||
configFile = path.resolve(checkoutPath, configFile);
|
||||
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
||||
configFile = path.resolve(workspacePath, configFile);
|
||||
parsedYAML = getLocalConfig(configFile, workspacePath);
|
||||
}
|
||||
else {
|
||||
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
||||
|
|
@ -490,7 +491,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||
// unless they're prefixed with "+", in which case they supplement those
|
||||
// in the config file.
|
||||
if (queriesInput) {
|
||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, workspacePath, apiDetails, logger);
|
||||
}
|
||||
if (shouldAddConfigFileQueries(queriesInput) &&
|
||||
QUERIES_PROPERTY in parsedYAML) {
|
||||
|
|
@ -503,7 +504,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||
typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
||||
throw new Error(getQueryUsesInvalid(configFile));
|
||||
}
|
||||
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, checkoutPath, apiDetails, logger, configFile);
|
||||
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, workspacePath, apiDetails, logger, configFile);
|
||||
}
|
||||
}
|
||||
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
||||
|
|
@ -668,16 +669,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
|||
* 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.
|
||||
*/
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||
var _a, _b, _c;
|
||||
let config;
|
||||
// If no config file was provided create an empty one
|
||||
if (!configFile) {
|
||||
logger.debug("No configuration file was provided");
|
||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
||||
}
|
||||
else {
|
||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
||||
}
|
||||
// The list of queries should not be empty for any language. If it is then
|
||||
// it is a user configuration error.
|
||||
|
|
@ -702,9 +703,9 @@ function isLocal(configPath) {
|
|||
}
|
||||
return configPath.indexOf("@") === -1;
|
||||
}
|
||||
function getLocalConfig(configFile, checkoutPath) {
|
||||
function getLocalConfig(configFile, workspacePath) {
|
||||
// Error if the config file is now outside of the workspace
|
||||
if (!(configFile + path.sep).startsWith(checkoutPath + path.sep)) {
|
||||
if (!(configFile + path.sep).startsWith(workspacePath + path.sep)) {
|
||||
throw new Error(getConfigFileOutsideWorkspaceErrorMessage(configFile));
|
||||
}
|
||||
// Error if the file does not exist
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
8
lib/fingerprints.js
generated
8
lib/fingerprints.js
generated
|
|
@ -160,7 +160,7 @@ function locationUpdateCallback(result, location, logger) {
|
|||
// the source file so we can hash it.
|
||||
// If possible returns a absolute file path for the source file,
|
||||
// or if not possible then returns undefined.
|
||||
function resolveUriToFile(location, artifacts, checkoutPath, logger) {
|
||||
function resolveUriToFile(location, artifacts, sourceRoot, logger) {
|
||||
// This may be referencing an artifact
|
||||
if (!location.uri && location.index !== undefined) {
|
||||
if (typeof location.index !== "number" ||
|
||||
|
|
@ -188,7 +188,7 @@ function resolveUriToFile(location, artifacts, checkoutPath, logger) {
|
|||
return undefined;
|
||||
}
|
||||
// Discard any absolute paths that aren't in the src root
|
||||
const srcRootPrefix = `${checkoutPath}/`;
|
||||
const srcRootPrefix = `${sourceRoot}/`;
|
||||
if (uri.startsWith("/") && !uri.startsWith(srcRootPrefix)) {
|
||||
logger.debug(`Ignoring location URI "${uri}" as it is outside of the src root`);
|
||||
return undefined;
|
||||
|
|
@ -213,7 +213,7 @@ function resolveUriToFile(location, artifacts, checkoutPath, logger) {
|
|||
exports.resolveUriToFile = resolveUriToFile;
|
||||
// Compute fingerprints for results in the given sarif file
|
||||
// and return an updated sarif file contents.
|
||||
async function addFingerprints(sarifContents, checkoutPath, logger) {
|
||||
async function addFingerprints(sarifContents, sourceRoot, logger) {
|
||||
var _a, _b, _c, _d, _e;
|
||||
const sarif = JSON.parse(sarifContents);
|
||||
// Gather together results for the same file and construct
|
||||
|
|
@ -233,7 +233,7 @@ async function addFingerprints(sarifContents, checkoutPath, logger) {
|
|||
// Locations without a line number are unlikely to be source files
|
||||
continue;
|
||||
}
|
||||
const filepath = resolveUriToFile(primaryLocation.physicalLocation.artifactLocation, artifacts, checkoutPath, logger);
|
||||
const filepath = resolveUriToFile(primaryLocation.physicalLocation.artifactLocation, artifacts, sourceRoot, logger);
|
||||
if (!filepath) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
8
lib/fingerprints.test.js
generated
8
lib/fingerprints.test.js
generated
|
|
@ -167,8 +167,8 @@ ava_1.default("addFingerprints", async (t) => {
|
|||
input = JSON.stringify(JSON.parse(input));
|
||||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(`${__dirname}/../src/testdata`);
|
||||
t.deepEqual(await fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger(true)), expected);
|
||||
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
|
||||
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, logging_1.getRunnerLogger(true)), expected);
|
||||
});
|
||||
ava_1.default("missingRegions", async (t) => {
|
||||
// Run an end-to-end test on a test file
|
||||
|
|
@ -182,7 +182,7 @@ ava_1.default("missingRegions", async (t) => {
|
|||
input = JSON.stringify(JSON.parse(input));
|
||||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(`${__dirname}/../src/testdata`);
|
||||
t.deepEqual(await fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger(true)), expected);
|
||||
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
|
||||
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, logging_1.getRunnerLogger(true)), expected);
|
||||
});
|
||||
//# sourceMappingURL=fingerprints.test.js.map
|
||||
File diff suppressed because one or more lines are too long
4
lib/init.js
generated
4
lib/init.js
generated
|
|
@ -24,9 +24,9 @@ async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant,
|
|||
return { codeql, toolsVersion };
|
||||
}
|
||||
exports.initCodeQL = initCodeQL;
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||
logger.startGroup("Load language configuration");
|
||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
||||
analysisPaths.printPathFiltersWarning(config, logger);
|
||||
logger.endGroup();
|
||||
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,gEA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,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAC7C,CAAC,IAAI,EAAE,CAAC;SACV;QACD,MAAM,MAAM,GAAG,0BAA0B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE;gBAChE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAtCD,8CAsCC"}
|
||||
12
lib/runner.js
generated
12
lib/runner.js
generated
|
|
@ -129,8 +129,10 @@ program
|
|||
else {
|
||||
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, gitHubVersion.type, logger)).codeql;
|
||||
}
|
||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||
const tracerConfig = await init_1.runInit(codeql, config, checkoutPath);
|
||||
const workspacePath = checkoutPath;
|
||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, workspacePath, gitHubVersion, apiDetails, logger);
|
||||
const sourceRoot = checkoutPath;
|
||||
const tracerConfig = await init_1.runInit(codeql, config, sourceRoot);
|
||||
if (tracerConfig === undefined) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -251,7 +253,8 @@ program
|
|||
logger.info("Not uploading results");
|
||||
return;
|
||||
}
|
||||
await upload_lib.uploadFromRunner(outputDir, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, cmd.checkoutPath || process.cwd(), config.gitHubVersion, apiDetails, logger);
|
||||
const sourceRoot = cmd.checkoutPath || process.cwd();
|
||||
await upload_lib.uploadFromRunner(outputDir, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, sourceRoot, config.gitHubVersion, apiDetails, logger);
|
||||
}
|
||||
catch (e) {
|
||||
logger.error("Analyze failed");
|
||||
|
|
@ -281,7 +284,8 @@ program
|
|||
};
|
||||
try {
|
||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||
await upload_lib.uploadFromRunner(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger);
|
||||
const sourceRoot = cmd.checkoutPath || process.cwd();
|
||||
await upload_lib.uploadFromRunner(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, sourceRoot, gitHubVersion, apiDetails, logger);
|
||||
}
|
||||
catch (e) {
|
||||
logger.error("Upload failed");
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
10
lib/upload-lib.js
generated
10
lib/upload-lib.js
generated
|
|
@ -122,8 +122,8 @@ exports.uploadFromActions = uploadFromActions;
|
|||
// Uploads a single sarif file or a directory of sarif files
|
||||
// depending on what the path happens to refer to.
|
||||
// Returns true iff the upload occurred and succeeded
|
||||
async function uploadFromRunner(sarifPath, repositoryNwo, commitOid, ref, category, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), repositoryNwo, commitOid, ref, undefined, category, undefined, undefined, checkoutPath, undefined, gitHubVersion, apiDetails, logger);
|
||||
async function uploadFromRunner(sarifPath, repositoryNwo, commitOid, ref, category, sourceRoot, gitHubVersion, apiDetails, logger) {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), repositoryNwo, commitOid, ref, undefined, category, undefined, undefined, sourceRoot, undefined, gitHubVersion, apiDetails, logger);
|
||||
}
|
||||
exports.uploadFromRunner = uploadFromRunner;
|
||||
function getSarifFilePaths(sarifPath) {
|
||||
|
|
@ -227,7 +227,7 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
|
|||
exports.buildPayload = buildPayload;
|
||||
// Uploads the given set of sarif files.
|
||||
// Returns true iff the upload occurred and succeeded
|
||||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, checkoutPath, environment, gitHubVersion, apiDetails, logger) {
|
||||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, sourceRoot, environment, gitHubVersion, apiDetails, logger) {
|
||||
logger.startGroup("Uploading results");
|
||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||
if (util.isActions()) {
|
||||
|
|
@ -243,10 +243,10 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
|||
validateSarifFileSchema(file, logger);
|
||||
}
|
||||
let sarifPayload = combineSarifFiles(sarifFiles);
|
||||
sarifPayload = await fingerprints.addFingerprints(sarifPayload, checkoutPath, logger);
|
||||
sarifPayload = await fingerprints.addFingerprints(sarifPayload, sourceRoot, logger);
|
||||
sarifPayload = populateRunAutomationDetails(sarifPayload, category, analysisKey, environment);
|
||||
const zippedSarif = zlib_1.default.gzipSync(sarifPayload).toString("base64");
|
||||
const checkoutURI = file_url_1.default(checkoutPath);
|
||||
const checkoutURI = file_url_1.default(sourceRoot);
|
||||
const toolNames = util.getToolNames(sarifPayload);
|
||||
const payload = buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, workflowRunID, checkoutURI, environment, toolNames, gitHubVersion);
|
||||
// Log some useful debug info about the info
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -276,12 +276,12 @@ async function addLocalQueries(
|
|||
codeQL: CodeQL,
|
||||
resultMap: Queries,
|
||||
localQueryPath: string,
|
||||
checkoutPath: string,
|
||||
workspacePath: string,
|
||||
configFile?: string
|
||||
) {
|
||||
// Resolve the local path against the workspace so that when this is
|
||||
// passed to codeql it resolves to exactly the path we expect it to resolve to.
|
||||
let absoluteQueryPath = path.join(checkoutPath, localQueryPath);
|
||||
let absoluteQueryPath = path.join(workspacePath, localQueryPath);
|
||||
|
||||
// Check the file exists
|
||||
if (!fs.existsSync(absoluteQueryPath)) {
|
||||
|
|
@ -294,7 +294,7 @@ async function addLocalQueries(
|
|||
// Check the local path doesn't jump outside the repo using '..' or symlinks
|
||||
if (
|
||||
!(absoluteQueryPath + path.sep).startsWith(
|
||||
fs.realpathSync(checkoutPath) + path.sep
|
||||
fs.realpathSync(workspacePath) + path.sep
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
|
|
@ -302,7 +302,14 @@ async function addLocalQueries(
|
|||
);
|
||||
}
|
||||
|
||||
await runResolveQueries(codeQL, resultMap, [absoluteQueryPath], checkoutPath);
|
||||
const extraSearchPath = workspacePath;
|
||||
|
||||
await runResolveQueries(
|
||||
codeQL,
|
||||
resultMap,
|
||||
[absoluteQueryPath],
|
||||
extraSearchPath
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -368,7 +375,7 @@ async function parseQueryUses(
|
|||
resultMap: Queries,
|
||||
queryUses: string,
|
||||
tempDir: string,
|
||||
checkoutPath: string,
|
||||
workspacePath: string,
|
||||
apiDetails: api.GitHubApiExternalRepoDetails,
|
||||
logger: Logger,
|
||||
configFile?: string
|
||||
|
|
@ -384,7 +391,7 @@ async function parseQueryUses(
|
|||
codeQL,
|
||||
resultMap,
|
||||
queryUses.slice(2),
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
configFile
|
||||
);
|
||||
return;
|
||||
|
|
@ -764,7 +771,7 @@ async function addQueriesFromWorkflow(
|
|||
languages: string[],
|
||||
resultMap: Queries,
|
||||
tempDir: string,
|
||||
checkoutPath: string,
|
||||
workspacePath: string,
|
||||
apiDetails: api.GitHubApiExternalRepoDetails,
|
||||
logger: Logger
|
||||
) {
|
||||
|
|
@ -779,7 +786,7 @@ async function addQueriesFromWorkflow(
|
|||
resultMap,
|
||||
query,
|
||||
tempDir,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
apiDetails,
|
||||
logger
|
||||
);
|
||||
|
|
@ -810,7 +817,7 @@ export async function getDefaultConfig(
|
|||
tempDir: string,
|
||||
toolCacheDir: string,
|
||||
codeQL: CodeQL,
|
||||
checkoutPath: string,
|
||||
workspacePath: string,
|
||||
gitHubVersion: GitHubVersion,
|
||||
apiDetails: api.GitHubApiCombinedDetails,
|
||||
logger: Logger
|
||||
|
|
@ -837,7 +844,7 @@ export async function getDefaultConfig(
|
|||
languages,
|
||||
queries,
|
||||
tempDir,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
apiDetails,
|
||||
logger
|
||||
);
|
||||
|
|
@ -873,7 +880,7 @@ async function loadConfig(
|
|||
tempDir: string,
|
||||
toolCacheDir: string,
|
||||
codeQL: CodeQL,
|
||||
checkoutPath: string,
|
||||
workspacePath: string,
|
||||
gitHubVersion: GitHubVersion,
|
||||
apiDetails: api.GitHubApiCombinedDetails,
|
||||
logger: Logger
|
||||
|
|
@ -882,8 +889,8 @@ async function loadConfig(
|
|||
|
||||
if (isLocal(configFile)) {
|
||||
// Treat the config file as relative to the workspace
|
||||
configFile = path.resolve(checkoutPath, configFile);
|
||||
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
||||
configFile = path.resolve(workspacePath, configFile);
|
||||
parsedYAML = getLocalConfig(configFile, workspacePath);
|
||||
} else {
|
||||
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
||||
}
|
||||
|
|
@ -939,7 +946,7 @@ async function loadConfig(
|
|||
languages,
|
||||
queries,
|
||||
tempDir,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
apiDetails,
|
||||
logger
|
||||
);
|
||||
|
|
@ -965,7 +972,7 @@ async function loadConfig(
|
|||
queries,
|
||||
query[QUERIES_USES_PROPERTY],
|
||||
tempDir,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
apiDetails,
|
||||
logger,
|
||||
configFile
|
||||
|
|
@ -1198,7 +1205,7 @@ export async function initConfig(
|
|||
tempDir: string,
|
||||
toolCacheDir: string,
|
||||
codeQL: CodeQL,
|
||||
checkoutPath: string,
|
||||
workspacePath: string,
|
||||
gitHubVersion: GitHubVersion,
|
||||
apiDetails: api.GitHubApiCombinedDetails,
|
||||
logger: Logger
|
||||
|
|
@ -1217,7 +1224,7 @@ export async function initConfig(
|
|||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQL,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
|
|
@ -1233,7 +1240,7 @@ export async function initConfig(
|
|||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQL,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
|
|
@ -1268,9 +1275,9 @@ function isLocal(configPath: string): boolean {
|
|||
return configPath.indexOf("@") === -1;
|
||||
}
|
||||
|
||||
function getLocalConfig(configFile: string, checkoutPath: string): UserConfig {
|
||||
function getLocalConfig(configFile: string, workspacePath: string): UserConfig {
|
||||
// Error if the config file is now outside of the workspace
|
||||
if (!(configFile + path.sep).startsWith(checkoutPath + path.sep)) {
|
||||
if (!(configFile + path.sep).startsWith(workspacePath + path.sep)) {
|
||||
throw new Error(getConfigFileOutsideWorkspaceErrorMessage(configFile));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,12 +201,12 @@ test("addFingerprints", async (t) => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(`${__dirname}/../src/testdata`);
|
||||
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
|
||||
|
||||
t.deepEqual(
|
||||
await fingerprints.addFingerprints(
|
||||
input,
|
||||
checkoutPath,
|
||||
sourceRoot,
|
||||
getRunnerLogger(true)
|
||||
),
|
||||
expected
|
||||
|
|
@ -227,12 +227,12 @@ test("missingRegions", async (t) => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(`${__dirname}/../src/testdata`);
|
||||
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
|
||||
|
||||
t.deepEqual(
|
||||
await fingerprints.addFingerprints(
|
||||
input,
|
||||
checkoutPath,
|
||||
sourceRoot,
|
||||
getRunnerLogger(true)
|
||||
),
|
||||
expected
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ function locationUpdateCallback(
|
|||
export function resolveUriToFile(
|
||||
location: any,
|
||||
artifacts: any[],
|
||||
checkoutPath: string,
|
||||
sourceRoot: string,
|
||||
logger: Logger
|
||||
): string | undefined {
|
||||
// This may be referencing an artifact
|
||||
|
|
@ -214,7 +214,7 @@ export function resolveUriToFile(
|
|||
}
|
||||
|
||||
// Discard any absolute paths that aren't in the src root
|
||||
const srcRootPrefix = `${checkoutPath}/`;
|
||||
const srcRootPrefix = `${sourceRoot}/`;
|
||||
if (uri.startsWith("/") && !uri.startsWith(srcRootPrefix)) {
|
||||
logger.debug(
|
||||
`Ignoring location URI "${uri}" as it is outside of the src root`
|
||||
|
|
@ -247,7 +247,7 @@ export function resolveUriToFile(
|
|||
// and return an updated sarif file contents.
|
||||
export async function addFingerprints(
|
||||
sarifContents: string,
|
||||
checkoutPath: string,
|
||||
sourceRoot: string,
|
||||
logger: Logger
|
||||
): Promise<string> {
|
||||
const sarif = JSON.parse(sarifContents);
|
||||
|
|
@ -279,7 +279,7 @@ export async function addFingerprints(
|
|||
const filepath = resolveUriToFile(
|
||||
primaryLocation.physicalLocation.artifactLocation,
|
||||
artifacts,
|
||||
checkoutPath,
|
||||
sourceRoot,
|
||||
logger
|
||||
);
|
||||
if (!filepath) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export async function initConfig(
|
|||
tempDir: string,
|
||||
toolCacheDir: string,
|
||||
codeQL: CodeQL,
|
||||
checkoutPath: string,
|
||||
workspacePath: string,
|
||||
gitHubVersion: util.GitHubVersion,
|
||||
apiDetails: GitHubApiCombinedDetails,
|
||||
logger: Logger
|
||||
|
|
@ -61,7 +61,7 @@ export async function initConfig(
|
|||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQL,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ program
|
|||
)
|
||||
).codeql;
|
||||
}
|
||||
|
||||
const workspacePath = checkoutPath;
|
||||
const config = await initConfig(
|
||||
cmd.languages,
|
||||
cmd.queries,
|
||||
|
|
@ -219,13 +219,14 @@ program
|
|||
tempDir,
|
||||
toolsDir,
|
||||
codeql,
|
||||
checkoutPath,
|
||||
workspacePath,
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
);
|
||||
|
||||
const tracerConfig = await runInit(codeql, config, checkoutPath);
|
||||
const sourceRoot = checkoutPath;
|
||||
const tracerConfig = await runInit(codeql, config, sourceRoot);
|
||||
if (tracerConfig === undefined) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -448,14 +449,14 @@ program
|
|||
logger.info("Not uploading results");
|
||||
return;
|
||||
}
|
||||
|
||||
const sourceRoot = cmd.checkoutPath || process.cwd();
|
||||
await upload_lib.uploadFromRunner(
|
||||
outputDir,
|
||||
parseRepositoryNwo(cmd.repository),
|
||||
cmd.commit,
|
||||
parseRef(cmd.ref),
|
||||
cmd.category,
|
||||
cmd.checkoutPath || process.cwd(),
|
||||
sourceRoot,
|
||||
config.gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
|
|
@ -526,13 +527,14 @@ program
|
|||
};
|
||||
try {
|
||||
const gitHubVersion = await getGitHubVersion(apiDetails);
|
||||
const sourceRoot = cmd.checkoutPath || process.cwd();
|
||||
await upload_lib.uploadFromRunner(
|
||||
cmd.sarifFile,
|
||||
parseRepositoryNwo(cmd.repository),
|
||||
cmd.commit,
|
||||
parseRef(cmd.ref),
|
||||
cmd.category,
|
||||
cmd.checkoutPath || process.cwd(),
|
||||
sourceRoot,
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ export async function uploadFromRunner(
|
|||
commitOid: string,
|
||||
ref: string,
|
||||
category: string | undefined,
|
||||
checkoutPath: string,
|
||||
sourceRoot: string,
|
||||
gitHubVersion: util.GitHubVersion,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
logger: Logger
|
||||
|
|
@ -188,7 +188,7 @@ export async function uploadFromRunner(
|
|||
category,
|
||||
undefined,
|
||||
undefined,
|
||||
checkoutPath,
|
||||
sourceRoot,
|
||||
undefined,
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
|
|
@ -330,7 +330,7 @@ async function uploadFiles(
|
|||
category: string | undefined,
|
||||
analysisName: string | undefined,
|
||||
workflowRunID: number | undefined,
|
||||
checkoutPath: string,
|
||||
sourceRoot: string,
|
||||
environment: string | undefined,
|
||||
gitHubVersion: util.GitHubVersion,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
|
|
@ -358,7 +358,7 @@ async function uploadFiles(
|
|||
let sarifPayload = combineSarifFiles(sarifFiles);
|
||||
sarifPayload = await fingerprints.addFingerprints(
|
||||
sarifPayload,
|
||||
checkoutPath,
|
||||
sourceRoot,
|
||||
logger
|
||||
);
|
||||
sarifPayload = populateRunAutomationDetails(
|
||||
|
|
@ -369,7 +369,7 @@ async function uploadFiles(
|
|||
);
|
||||
|
||||
const zippedSarif = zlib.gzipSync(sarifPayload).toString("base64");
|
||||
const checkoutURI = fileUrl(checkoutPath);
|
||||
const checkoutURI = fileUrl(sourceRoot);
|
||||
|
||||
const toolNames = util.getToolNames(sarifPayload);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue