Skip to content

Commit 3f68d85

Browse files
Respect end-tracing script instead of deleting one variable
1 parent cefec5b commit 3f68d85

File tree

6 files changed

+60
-8
lines changed

6 files changed

+60
-8
lines changed

lib/analyze.js

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

lib/analyze.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tracer-config.js

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tracer-config.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ import * as toolrunner from "@actions/exec/lib/toolrunner";
55
import * as yaml from "js-yaml";
66

77
import * as analysisPaths from "./analysis-paths";
8-
import { CODEQL_VERSION_COUNTS_LINES, getCodeQL } from "./codeql";
8+
import {
9+
CODEQL_VERSION_COUNTS_LINES,
10+
CODEQL_VERSION_NEW_TRACING,
11+
getCodeQL,
12+
} from "./codeql";
913
import * as configUtils from "./config-utils";
1014
import { countLoc } from "./count-loc";
1115
import { isScannedLanguage, Language } from "./languages";
1216
import { Logger } from "./logging";
1317
import * as sharedEnv from "./shared-environment";
18+
import { endTracingForCluster } from "./tracer-config";
1419
import * as util from "./util";
1520

1621
export class CodeQLAnalysisError extends Error {
@@ -409,8 +414,14 @@ export async function runFinalize(
409414
config: configUtils.Config,
410415
logger: Logger
411416
) {
412-
// Delete the tracer config env var to avoid tracing ourselves
413-
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
417+
const codeql = await getCodeQL(config.codeQLCmd);
418+
if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
419+
// Delete variables as specified by the end-tracing script
420+
await endTracingForCluster(config);
421+
} else {
422+
// Delete the tracer config env var to avoid tracing ourselves
423+
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
424+
}
414425

415426
fs.mkdirSync(outputDir, { recursive: true });
416427

src/tracer-config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@ const CRITICAL_TRACER_VARS = new Set([
2020
"SEMMLE_JAVA_TOOL_OPTIONS",
2121
]);
2222

23+
export async function endTracingForCluster(
24+
config: configUtils.Config
25+
): Promise<void> {
26+
const endTracingEnvVariables: Map<string, string | undefined> = JSON.parse(
27+
fs.readFileSync(
28+
path.resolve(
29+
config.dbLocation,
30+
"temp/tracingEnvironment/end-tracing.json"
31+
),
32+
"utf8"
33+
)
34+
);
35+
for (const [key, value] of Object.entries(endTracingEnvVariables)) {
36+
if (value !== undefined) {
37+
process.env[key] = value;
38+
} else {
39+
delete process.env[key];
40+
}
41+
}
42+
}
43+
2344
export async function getTracerConfigForCluster(
2445
config: configUtils.Config
2546
): Promise<TracerConfig> {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy