Skip to content

Commit 4707994

Browse files
committed
Don't include diagnostics if FF is off
1 parent 98b8e51 commit 4707994

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/init-action-post-helper.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test.serial("generateFailedSarif picks up unwritten diagnostics", async (t) =>
5656
const sarifFile = path.join(tmpDir, "failed.sarif");
5757
const result = await initActionPostHelper.generateFailedSarif(
5858
logger,
59-
createFeatures([]),
59+
createFeatures([Feature.ExportDiagnosticsEnabled]),
6060
createTestConfig({
6161
tempDir: tmpDir,
6262
// Explicitly undefined to ensure we get the "no database" path.

‎src/init-action-post-helper.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,22 @@ export async function generateFailedSarif(
204204
}
205205

206206
// If there is no database or the feature flag is off, we run 'export diagnostics'
207-
if (
208-
databasePath === undefined ||
209-
!(await features.getValue(Feature.ExportDiagnosticsEnabled, codeql))
210-
) {
207+
const exportDiagnosticsEnabled = await features.getValue(
208+
Feature.ExportDiagnosticsEnabled,
209+
codeql,
210+
);
211+
if (databasePath === undefined || !exportDiagnosticsEnabled) {
211212
// If we don't have a database path, then we may have diagnostics that were written to a
212213
// temporary location. Get the path that they would have been written to and check whether
213214
// it exists. If so, pass it on to the CLI. The CLI will not complain if we give it a
214215
// path that doesn't exist, so we are just being extra defensive here.
216+
// We also don't pass the path to the CLI if `exportDiagnosticsEnabled` is not enabled, to preserve
217+
// its intended behaviour of controlling whether diagnostics are included in the SARIF or not.
215218
let diagnosticDir: string | undefined = getTempDiagnosticPath(
216219
config.tempDir,
217220
);
218221

219-
if (!fs.existsSync(diagnosticDir)) {
222+
if (!exportDiagnosticsEnabled || !fs.existsSync(diagnosticDir)) {
220223
diagnosticDir = undefined;
221224
}
222225

0 commit comments

Comments
 (0)