From d32cd4dddeca072980595cf031bf7cf836faa3ff Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 9 Jan 2026 18:58:32 +0000 Subject: [PATCH] Include base database OIDs when bundling database --- lib/analyze-action-post.js | 17 +++++++++++++---- lib/analyze-action.js | 21 ++++++++++++++++----- lib/autobuild-action.js | 17 +++++++++++++---- lib/init-action-post.js | 21 ++++++++++++++++----- lib/init-action.js | 17 +++++++++++++---- lib/resolve-environment-action.js | 17 +++++++++++++---- lib/setup-codeql-action.js | 17 +++++++++++++---- lib/upload-lib.js | 17 +++++++++++++---- lib/upload-sarif-action.js | 17 +++++++++++++---- src/codeql.ts | 19 +++++++++++++++++++ src/overlay-database-utils.ts | 5 +---- src/util.ts | 14 +++++++++++++- 12 files changed, 156 insertions(+), 43 deletions(-) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index d784fac35..c35d650a7 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -126165,6 +126165,7 @@ var maximumVersion = "3.20"; var minimumVersion = "3.14"; // src/util.ts +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var GITHUB_DOTCOM_URL = "https://github.com"; var MINIMUM_CGROUP_MEMORY_LIMIT_BYTES = 1024 * 1024; function getExtraOptionsEnvParam() { @@ -126271,6 +126272,9 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} function isInTestMode() { return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true"; } @@ -126933,9 +126937,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path2.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -127601,7 +127602,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -127610,6 +127611,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/analyze-action.js b/lib/analyze-action.js index d5dba40f4..a65204695 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -92764,6 +92764,7 @@ var safeDump = renamed("safeDump", "dump"); // src/util.ts var semver = __toESM(require_semver2()); +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BROKEN_VERSIONS = ["0.0.0-20211207"]; var GITHUB_DOTCOM_URL = "https://github.com"; var DEFAULT_RESERVED_RAM_SCALING_FACTOR = 0.05; @@ -93084,13 +93085,18 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} async function bundleDb(config, language, codeql, dbName) { const databasePath = getCodeQLDatabasePath(config, language); const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`); if (fs.existsSync(databaseBundlePath)) { await fs.promises.rm(databaseBundlePath, { force: true }); } - await codeql.databaseBundle(databasePath, databaseBundlePath, dbName); + await codeql.databaseBundle(databasePath, databaseBundlePath, dbName, [ + BASE_DATABASE_OIDS_FILE_NAME + ]); return databaseBundlePath; } async function delay(milliseconds, opts) { @@ -94305,9 +94311,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path4.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -96644,7 +96647,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -96653,6 +96656,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index f66c78d4c..fe3355830 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -89863,6 +89863,7 @@ var maximumVersion = "3.20"; var minimumVersion = "3.14"; // src/util.ts +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var GITHUB_DOTCOM_URL = "https://github.com"; var MINIMUM_CGROUP_MEMORY_LIMIT_BYTES = 1024 * 1024; function getExtraOptionsEnvParam() { @@ -89994,6 +89995,9 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} function isInTestMode() { return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true"; } @@ -90792,9 +90796,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path2.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -91762,7 +91763,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -91771,6 +91772,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 767cb0865..c518ed16b 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -129063,6 +129063,7 @@ var maximumVersion = "3.20"; var minimumVersion = "3.14"; // src/util.ts +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BROKEN_VERSIONS = ["0.0.0-20211207"]; var GITHUB_DOTCOM_URL = "https://github.com"; var MINIMUM_CGROUP_MEMORY_LIMIT_BYTES = 1024 * 1024; @@ -129208,13 +129209,18 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} async function bundleDb(config, language, codeql, dbName) { const databasePath = getCodeQLDatabasePath(config, language); const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`); if (fs.existsSync(databaseBundlePath)) { await fs.promises.rm(databaseBundlePath, { force: true }); } - await codeql.databaseBundle(databasePath, databaseBundlePath, dbName); + await codeql.databaseBundle(databasePath, databaseBundlePath, dbName, [ + BASE_DATABASE_OIDS_FILE_NAME + ]); return databaseBundlePath; } async function delay(milliseconds, opts) { @@ -130308,9 +130314,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path3.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -132219,7 +132222,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -132228,6 +132231,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/init-action.js b/lib/init-action.js index 785d566e5..d7d63f2d2 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -90081,6 +90081,7 @@ var maximumVersion = "3.20"; var minimumVersion = "3.14"; // src/util.ts +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BROKEN_VERSIONS = ["0.0.0-20211207"]; var GITHUB_DOTCOM_URL = "https://github.com"; var DEFAULT_DEBUG_ARTIFACT_NAME = "debug-artifacts"; @@ -90411,6 +90412,9 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} async function delay(milliseconds, opts) { const { allowProcessExit } = opts || {}; return new Promise((resolve9) => { @@ -91766,9 +91770,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path5.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -94926,7 +94927,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -94935,6 +94936,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index a4cd3bc52..7379429ba 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -89863,6 +89863,7 @@ var maximumVersion = "3.20"; var minimumVersion = "3.14"; // src/util.ts +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var GITHUB_DOTCOM_URL = "https://github.com"; var MINIMUM_CGROUP_MEMORY_LIMIT_BYTES = 1024 * 1024; function getExtraOptionsEnvParam() { @@ -89987,6 +89988,9 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} async function delay(milliseconds, opts) { const { allowProcessExit } = opts || {}; return new Promise((resolve4) => { @@ -90785,9 +90789,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path2.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -91455,7 +91456,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -91464,6 +91465,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index f2de7dd3b..a1a729052 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -89919,6 +89919,7 @@ var maximumVersion = "3.20"; var minimumVersion = "3.14"; // src/util.ts +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BROKEN_VERSIONS = ["0.0.0-20211207"]; var GITHUB_DOTCOM_URL = "https://github.com"; var MINIMUM_CGROUP_MEMORY_LIMIT_BYTES = 1024 * 1024; @@ -90060,6 +90061,9 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} async function delay(milliseconds, opts) { const { allowProcessExit } = opts || {}; return new Promise((resolve4) => { @@ -90694,9 +90698,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path3.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -92764,7 +92765,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -92773,6 +92774,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/upload-lib.js b/lib/upload-lib.js index def4bc215..a3b6e0210 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -92781,6 +92781,7 @@ var safeDump = renamed("safeDump", "dump"); // src/util.ts var semver = __toESM(require_semver2()); +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BROKEN_VERSIONS = ["0.0.0-20211207"]; var GITHUB_DOTCOM_URL = "https://github.com"; var MINIMUM_CGROUP_MEMORY_LIMIT_BYTES = 1024 * 1024; @@ -92900,6 +92901,9 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} async function delay(milliseconds, opts) { const { allowProcessExit } = opts || {}; return new Promise((resolve6) => { @@ -93849,9 +93853,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path3.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -95480,7 +95481,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -95489,6 +95490,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 920cfb823..ab402ebec 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -92755,6 +92755,7 @@ var safeDump = renamed("safeDump", "dump"); // src/util.ts var semver = __toESM(require_semver2()); +var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BROKEN_VERSIONS = ["0.0.0-20211207"]; var GITHUB_DOTCOM_URL = "https://github.com"; var MINIMUM_CGROUP_MEMORY_LIMIT_BYTES = 1024 * 1024; @@ -92881,6 +92882,9 @@ function getCachedCodeQlVersion() { async function codeQlVersionAtLeast(codeql, requiredVersion) { return semver.gte((await codeql.getVersion()).version, requiredVersion); } +function getBaseDatabaseOidsFilePath(config) { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} async function delay(milliseconds, opts) { const { allowProcessExit } = opts || {}; return new Promise((resolve6) => { @@ -93644,9 +93648,6 @@ async function readBaseDatabaseOidsFile(config, logger) { throw e; } } -function getBaseDatabaseOidsFilePath(config) { - return path3.join(config.dbLocation, "base-database-oids.json"); -} async function writeOverlayChangesFile(config, sourceRoot, logger) { const baseFileOids = await readBaseDatabaseOidsFile(config, logger); const overlayFileOids = await getFileOidsUnderPath(sourceRoot); @@ -96004,7 +96005,7 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName) { + async databaseBundle(databasePath, outputFilePath, databaseName, tryAlsoIncludeRelativePaths) { const args = [ "database", "bundle", @@ -96013,6 +96014,14 @@ ${output}` `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]) ]; + if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath + ]) + ); + } await new toolrunner3.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics(databasePath, sarifFile, automationDetailsId) { diff --git a/src/codeql.ts b/src/codeql.ts index 33dd0db98..be46fa047 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -147,11 +147,19 @@ export interface CodeQL { ): Promise; /** * Run 'codeql database bundle'. + * + * @param tryAlsoIncludeRelativePaths Additional paths that should be included in the bundle if possible. + * + * These paths are relative to the database root. + * + * Older versions of the CodeQL CLI do not support including additional paths in the bundle. + * In those cases, this parameter will be ignored. */ databaseBundle( databasePath: string, outputFilePath: string, dbName: string, + tryAlsoIncludeRelativePaths: string[], ): Promise; /** * Run 'codeql database run-queries'. If no `queries` are specified, then the CLI @@ -911,6 +919,7 @@ async function getCodeQLForCmd( databasePath: string, outputFilePath: string, databaseName: string, + tryAlsoIncludeRelativePaths: string[], ): Promise { const args = [ "database", @@ -920,6 +929,16 @@ async function getCodeQLForCmd( `--name=${databaseName}`, ...getExtraOptionsFromEnv(["database", "bundle"]), ]; + if ( + await this.supportsFeature(ToolsFeature.BundleSupportsIncludeOption) + ) { + args.push( + ...tryAlsoIncludeRelativePaths.flatMap((relativePath) => [ + "--include", + relativePath, + ]), + ); + } await new toolrunner.ToolRunner(cmd, args).exec(); }, async databaseExportDiagnostics( diff --git a/src/overlay-database-utils.ts b/src/overlay-database-utils.ts index b0710912c..9312fce5d 100644 --- a/src/overlay-database-utils.ts +++ b/src/overlay-database-utils.ts @@ -17,6 +17,7 @@ import { getCommitOid, getFileOidsUnderPath } from "./git-utils"; import { Logger, withGroupAsync } from "./logging"; import { CleanupLevel, + getBaseDatabaseOidsFilePath, getCodeQLDatabasePath, getErrorMessage, isInTestMode, @@ -98,10 +99,6 @@ async function readBaseDatabaseOidsFile( } } -function getBaseDatabaseOidsFilePath(config: Config): string { - return path.join(config.dbLocation, "base-database-oids.json"); -} - /** * Writes a JSON file containing the source-root-relative paths of files under * `sourceRoot` that have changed (added, removed, or modified) from the overlay diff --git a/src/util.ts b/src/util.ts index ffaa957fa..09e98206f 100644 --- a/src/util.ts +++ b/src/util.ts @@ -16,6 +16,12 @@ import { EnvVar } from "./environment"; import { Language } from "./languages"; import { Logger } from "./logging"; +/** + * The name of the file containing the base database OIDs, as stored in the + * root of the database location. + */ +const BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; + /** * Specifies bundle versions that are known to be broken * and will not be used if found in the toolcache. @@ -728,6 +734,10 @@ export async function codeQlVersionAtLeast( return semver.gte((await codeql.getVersion()).version, requiredVersion); } +export function getBaseDatabaseOidsFilePath(config: Config): string { + return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); +} + // Create a bundle for the given DB, if it doesn't already exist export async function bundleDb( config: Config, @@ -745,7 +755,9 @@ export async function bundleDb( if (fs.existsSync(databaseBundlePath)) { await fs.promises.rm(databaseBundlePath, { force: true }); } - await codeql.databaseBundle(databasePath, databaseBundlePath, dbName); + await codeql.databaseBundle(databasePath, databaseBundlePath, dbName, [ + BASE_DATABASE_OIDS_FILE_NAME, + ]); return databaseBundlePath; }