diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index 2e876c86c..914dab238 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -128166,10 +128166,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -128190,7 +128186,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -128201,7 +128197,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/analyze-action.js b/lib/analyze-action.js index c496c4aca..86bafba5f 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -92337,10 +92337,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -92361,7 +92357,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -92372,7 +92368,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 62f1100d6..970840e3a 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -87340,10 +87340,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -87364,7 +87360,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -87375,7 +87371,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 71f6e4772..68eec4613 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -133275,10 +133275,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -133299,7 +133295,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -133310,7 +133306,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/init-action.js b/lib/init-action.js index f24f6c2f2..a506447d9 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -91249,10 +91249,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -91273,7 +91269,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -91284,7 +91280,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index 83a920843..3ea89969c 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -86972,10 +86972,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -86996,7 +86992,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -87007,7 +87003,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 74be78daf..addfda665 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -88723,10 +88723,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -88747,7 +88743,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -88758,7 +88754,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 16d1d4e48..cccd12f29 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -91336,10 +91336,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -91360,7 +91356,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -91371,7 +91367,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 4e2f843bb..e03fd069f 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -92007,10 +92007,6 @@ async function getCodeQLForCmd(cmd, checkVersion) { if (qlconfigFile !== void 0) { extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - "forceOverwrite" /* ForceOverwrite */ - ) ? "--force-overwrite" : "--overwrite"; const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === "overlay" /* Overlay */) { const overlayChangesFile = await writeOverlayChangesFile( @@ -92031,7 +92027,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { [ "database", "init", - ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag], + ...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"], "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -92042,7 +92038,14 @@ async function getCodeQLForCmd(cmd, checkVersion) { // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions] + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions + ] }) ], { stdin: externalRepositoryToken } diff --git a/src/codeql.test.ts b/src/codeql.test.ts index 77fce4d3b..dea4cf04a 100644 --- a/src/codeql.test.ts +++ b/src/codeql.test.ts @@ -1072,7 +1072,7 @@ test.serial( ); test.serial( - "Avoids duplicating --overwrite flag if specified in CODEQL_ACTION_EXTRA_OPTIONS", + "Avoids duplicating --force-overwrite flag if specified in CODEQL_ACTION_EXTRA_OPTIONS", async (t) => { const runnerConstructorStub = stubToolRunnerConstructor(); const codeqlObject = await stubCodeql(); @@ -1080,7 +1080,7 @@ test.serial( sinon.stub(io, "which").resolves(""); process.env["CODEQL_ACTION_EXTRA_OPTIONS"] = - '{ "database": { "init": ["--overwrite"] } }'; + '{ "database": { "init": ["--force-overwrite"] } }'; await codeqlObject.databaseInitCluster( stubConfig, @@ -1093,9 +1093,9 @@ test.serial( t.true(runnerConstructorStub.calledOnce); const args = runnerConstructorStub.firstCall.args[1] as string[]; t.is( - args.filter((option: string) => option === "--overwrite").length, + args.filter((option: string) => option === "--force-overwrite").length, 1, - "--overwrite should only be passed once", + "--force-overwrite should only be passed once", ); // Clean up diff --git a/src/codeql.ts b/src/codeql.ts index 38383c35b..72fea765c 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -592,13 +592,6 @@ async function getCodeQLForCmd( extraArgs.push(`--qlconfig-file=${qlconfigFile}`); } - const overwriteFlag = isSupportedToolsFeature( - await this.getVersion(), - ToolsFeature.ForceOverwrite, - ) - ? "--force-overwrite" - : "--overwrite"; - const overlayDatabaseMode = config.overlayDatabaseMode; if (overlayDatabaseMode === OverlayDatabaseMode.Overlay) { const overlayChangesFile = await writeOverlayChangesFile( @@ -625,7 +618,7 @@ async function getCodeQLForCmd( "init", ...(overlayDatabaseMode === OverlayDatabaseMode.Overlay ? [] - : [overwriteFlag]), + : ["--force-overwrite"]), "--db-cluster", config.dbLocation, `--source-root=${sourceRoot}`, @@ -636,7 +629,14 @@ async function getCodeQLForCmd( // Some user configs specify `--no-calculate-baseline` as an additional // argument to `codeql database init`. Therefore ignore the baseline file // options here to avoid specifying the same argument twice and erroring. - ignoringOptions: ["--overwrite", ...baselineFilesOptions], + // + // Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if + // the user has configured `--overwrite`. + ignoringOptions: [ + "--force-overwrite", + "--overwrite", + ...baselineFilesOptions, + ], }), ], { stdin: externalRepositoryToken }, diff --git a/src/tools-features.test.ts b/src/tools-features.test.ts index 2192ea7a4..825b9c1eb 100644 --- a/src/tools-features.test.ts +++ b/src/tools-features.test.ts @@ -6,9 +6,13 @@ import { ToolsFeature, isSupportedToolsFeature } from "./tools-features"; test("isSupportedToolsFeature", async (t) => { const versionInfo = makeVersionInfo("1.0.0"); - t.false(isSupportedToolsFeature(versionInfo, ToolsFeature.ForceOverwrite)); + t.false( + isSupportedToolsFeature(versionInfo, ToolsFeature.BundleSupportsOverlay), + ); - versionInfo.features = { forceOverwrite: true }; + versionInfo.features = { bundleSupportsOverlay: true }; - t.true(isSupportedToolsFeature(versionInfo, ToolsFeature.ForceOverwrite)); + t.true( + isSupportedToolsFeature(versionInfo, ToolsFeature.BundleSupportsOverlay), + ); }); diff --git a/src/tools-features.ts b/src/tools-features.ts index bba64de23..6a88c4faa 100644 --- a/src/tools-features.ts +++ b/src/tools-features.ts @@ -7,7 +7,6 @@ export enum ToolsFeature { BundleSupportsIncludeOption = "bundleSupportsIncludeOption", BundleSupportsOverlay = "bundleSupportsOverlay", DatabaseInterpretResultsSupportsSarifRunProperty = "databaseInterpretResultsSupportsSarifRunProperty", - ForceOverwrite = "forceOverwrite", IndirectTracingSupportsStaticBinaries = "indirectTracingSupportsStaticBinaries", SuppressesMissingFileBaselineWarning = "suppressesMissingFileBaselineWarning", }