From 5c583bbb19e1ad139d93d0dbded840e606d4be4e Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Tue, 17 Feb 2026 13:38:09 +0000 Subject: [PATCH] Include diagnostics in bundle --- lib/analyze-action-post.js | 8 ++++++-- lib/analyze-action.js | 15 +++++++++++---- lib/autobuild-action.js | 8 ++++++-- lib/init-action-post.js | 14 ++++++++++---- lib/init-action.js | 14 +++++++++----- lib/resolve-environment-action.js | 8 ++++++-- lib/setup-codeql-action.js | 8 ++++++-- lib/upload-lib.js | 8 ++++++-- lib/upload-sarif-action.js | 8 ++++++-- src/codeql.ts | 10 +++++++++- src/database-upload.ts | 4 +++- src/debug-artifacts.ts | 1 + src/util.ts | 2 ++ 13 files changed, 81 insertions(+), 27 deletions(-) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index 093b3385f..3ce175850 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -162177,14 +162177,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 538062b23..3006d65f3 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -106084,7 +106084,7 @@ async function codeQlVersionAtLeast(codeql, requiredVersion) { function getBaseDatabaseOidsFilePath(config) { return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); } -async function bundleDb(config, language, codeql, dbName) { +async function bundleDb(config, language, codeql, dbName, { includeDiagnostics }) { const databasePath = getCodeQLDatabasePath(config, language); const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`); if (fs.existsSync(databaseBundlePath)) { @@ -106103,6 +106103,7 @@ async function bundleDb(config, language, codeql, dbName) { databasePath, databaseBundlePath, dbName, + includeDiagnostics, additionalFiles ); return databaseBundlePath; @@ -109870,14 +109871,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( @@ -110786,7 +110791,9 @@ async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetai for (const language of config.languages) { let bundledDbSize = void 0; try { - const bundledDb = await bundleDb(config, language, codeql, language); + const bundledDb = await bundleDb(config, language, codeql, language, { + includeDiagnostics: false + }); bundledDbSize = fs13.statSync(bundledDb).size; const bundledDbReadStream = fs13.createReadStream(bundledDb); const commitOid = await getCommitOid( diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index bce77f9f5..393400ab2 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -104898,14 +104898,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 2e48ce09d..8b792f4b2 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -163662,7 +163662,7 @@ async function codeQlVersionAtLeast(codeql, requiredVersion) { function getBaseDatabaseOidsFilePath(config) { return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME); } -async function bundleDb(config, language, codeql, dbName) { +async function bundleDb(config, language, codeql, dbName, { includeDiagnostics }) { const databasePath = getCodeQLDatabasePath(config, language); const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`); if (fs.existsSync(databaseBundlePath)) { @@ -163681,6 +163681,7 @@ async function bundleDb(config, language, codeql, dbName) { databasePath, databaseBundlePath, dbName, + includeDiagnostics, additionalFiles ); return databaseBundlePath; @@ -166993,14 +166994,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( @@ -167758,7 +167763,8 @@ async function createDatabaseBundleCli(codeql, config, language) { config, language, codeql, - `${config.debugDatabaseName}-${language}` + `${config.debugDatabaseName}-${language}`, + { includeDiagnostics: true } ); return databaseBundlePath; } diff --git a/lib/init-action.js b/lib/init-action.js index 959d10cb7..f0bd83b85 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -105715,8 +105715,8 @@ async function shouldSkipOverlayAnalysis(codeql, languages, diskUsage, logger) { return false; } if (status.attemptedToBuildOverlayBaseDatabase && !status.builtOverlayBaseDatabase) { - logger.info( - "Cached overlay status indicates that building an overlay base database was unsuccessful, so will skip overlay analysis." + logger.debug( + "Cached overlay status indicates that building an overlay base database was unsuccessful." ); return true; } @@ -106178,7 +106178,7 @@ async function getOverlayDatabaseMode(codeql, features, languages, sourceRoot, b ); if (diskUsage && await features.getValue("overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */) && await shouldSkipOverlayAnalysis(codeql, languages, diskUsage, logger)) { logger.info( - `Setting overlay database mode to ${"none" /* None */} because overlay analysis previously failed with this combination of languages, disk space, and CodeQL version. Consider running CodeQL analysis on a larger runner.` + `Setting overlay database mode to ${"none" /* None */} because overlay analysis previously failed with this combination of languages, disk space, and CodeQL version.` ); overlayDatabaseMode = "none" /* None */; skippedDueToCachedStatus = true; @@ -108334,14 +108334,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index 423ae3ce1..cd3b07adb 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -104575,14 +104575,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index c53c4bd2d..1473aa333 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -105985,14 +105985,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 05cf4487d..fd0cb5ea1 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -108733,14 +108733,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index c2e3e500c..6d2749c5c 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -109284,14 +109284,18 @@ ${output}` await runCli(cmd, codeqlArgs); } }, - async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) { + async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) { + const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]) + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs + }) ]; if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) { args.push( diff --git a/src/codeql.ts b/src/codeql.ts index 5a344e86a..0a97d6b2c 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -160,6 +160,7 @@ export interface CodeQL { databasePath: string, outputFilePath: string, dbName: string, + includeDiagnostics: boolean, alsoIncludeRelativePaths: string[], ): Promise; /** @@ -912,15 +913,22 @@ async function getCodeQLForCmd( databasePath: string, outputFilePath: string, databaseName: string, + includeDiagnostics: boolean, alsoIncludeRelativePaths: string[], ): Promise { + const includeDiagnosticsArgs = includeDiagnostics + ? ["--include-diagnostics"] + : []; const args = [ "database", "bundle", databasePath, `--output=${outputFilePath}`, `--name=${databaseName}`, - ...getExtraOptionsFromEnv(["database", "bundle"]), + ...includeDiagnosticsArgs, + ...getExtraOptionsFromEnv(["database", "bundle"], { + ignoringOptions: includeDiagnosticsArgs, + }), ]; if ( await this.supportsFeature(ToolsFeature.BundleSupportsIncludeOption) diff --git a/src/database-upload.ts b/src/database-upload.ts index 317681f64..41546697f 100644 --- a/src/database-upload.ts +++ b/src/database-upload.ts @@ -101,7 +101,9 @@ export async function cleanupAndUploadDatabases( // Although we are uploading arbitrary file contents to the API, it's worth // noting that it's the API's job to validate that the contents is acceptable. // This API method is available to anyone with write access to the repo. - const bundledDb = await bundleDb(config, language, codeql, language); + const bundledDb = await bundleDb(config, language, codeql, language, { + includeDiagnostics: false, + }); bundledDbSize = fs.statSync(bundledDb).size; const bundledDbReadStream = fs.createReadStream(bundledDb); const commitOid = await gitUtils.getCommitOid( diff --git a/src/debug-artifacts.ts b/src/debug-artifacts.ts index 769c5447c..aea5af01f 100644 --- a/src/debug-artifacts.ts +++ b/src/debug-artifacts.ts @@ -429,6 +429,7 @@ async function createDatabaseBundleCli( language, codeql, `${config.debugDatabaseName}-${language}`, + { includeDiagnostics: true }, ); return databaseBundlePath; } diff --git a/src/util.ts b/src/util.ts index 5d52b4d0a..3bcbb350b 100644 --- a/src/util.ts +++ b/src/util.ts @@ -744,6 +744,7 @@ export async function bundleDb( language: Language, codeql: CodeQL, dbName: string, + { includeDiagnostics }: { includeDiagnostics: boolean }, ) { const databasePath = getCodeQLDatabasePath(config, language); const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`); @@ -774,6 +775,7 @@ export async function bundleDb( databasePath, databaseBundlePath, dbName, + includeDiagnostics, additionalFiles, ); return databaseBundlePath;