Skip to content

Commit 318e01f

Browse files
authored
fix: filter telemetry with ip address in trace and data2 (#1693)
* fix: filter telemetry with ip address in trace and data2 * fix: update code * fix: update data2 to data3
1 parent 38cf20b commit 318e01f

6 files changed

Lines changed: 20 additions & 10 deletions

File tree

extension/src/Extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class Extension {
307307
const selection = await this.showRestartWindow();
308308
sendInfo("", {
309309
kind: "wrapperPropertiesChangedReloadRequest",
310-
data2: selection === OPT_RESTART ? "true" : "false",
310+
data3: selection === OPT_RESTART ? "true" : "false",
311311
});
312312
if (selection === OPT_RESTART) {
313313
await this.restartServer();
@@ -345,7 +345,7 @@ export class Extension {
345345
const selection = await this.showRestartWindow();
346346
sendInfo("", {
347347
kind: "javaHomeChangedReloadRequest",
348-
data2: selection === OPT_RESTART ? "true" : "false",
348+
data3: selection === OPT_RESTART ? "true" : "false",
349349
});
350350
if (selection === OPT_RESTART) {
351351
await this.restartServer();

extension/src/bs/BuildServerController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ export class BuildServerController implements Disposable {
7575
kind: "bsp-error",
7676
operationName: jsonObj.operationName,
7777
rootCauseMessage,
78-
trace,
78+
traceLog: jsonObj[trace],
7979
});
8080
} else {
8181
sendInfo("", {
8282
kind: kind,
83-
data2: JSON.stringify(rest),
83+
data3: JSON.stringify(rest),
8484
...(schemaVersion && { schemaVersion: schemaVersion }),
8585
});
8686
}
@@ -150,7 +150,7 @@ export class BuildServerController implements Disposable {
150150
machineStatus.hasProjectAtWorkspaceRoot = (await this.hasProjectAtWorkspaceRoot()).toString();
151151
sendInfo("", {
152152
kind: "machineStatus",
153-
data2: JSON.stringify(machineStatus),
153+
data3: JSON.stringify(machineStatus),
154154
});
155155
}
156156

extension/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import * as vscode from "vscode";
22
import { initializeFromJsonFile, instrumentOperation } from "vscode-extension-telemetry-wrapper";
3-
43
import { Api } from "./api";
54
import { Extension } from "./Extension";
5+
import { TelemetryFilter } from "./util/telemetryFilter";
66

77
let extension: Extension;
88

99
export async function activate(context: vscode.ExtensionContext): Promise<Api> {
10-
await initializeFromJsonFile(context.asAbsolutePath("./package.json"));
10+
await initializeFromJsonFile(context.asAbsolutePath("./package.json"), {
11+
replacementOptions: [TelemetryFilter.hideUrlOption],
12+
});
1113
return instrumentOperation("activation", activateExtension)(context);
1214
}
1315

extension/src/logger/Logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class Logger {
5656
this.log(error, LogVerbosity.ERROR);
5757
sendInfo("", {
5858
kind: "gradleTaskServerError",
59-
data2: error,
59+
data3: error,
6060
});
6161
}
6262

extension/src/server/GradleServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class GradleServer {
127127
);
128128
sendInfo("", {
129129
kind: "serverProcessExitRestart",
130-
data2: selection === OPT_RESTART ? "true" : "false",
130+
data3: selection === OPT_RESTART ? "true" : "false",
131131
});
132132
if (selection === OPT_RESTART) {
133133
await commands.executeCommand("workbench.action.restartExtensionHost");
@@ -169,7 +169,7 @@ export class GradleServer {
169169
private async handleServerStartError(code: number | null): Promise<void> {
170170
sendInfo("", {
171171
kind: "serverProcessExit",
172-
data2: code ? code.toString() : "",
172+
data3: code ? code.toString() : "",
173173
});
174174
await this.showRestartMessage();
175175
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ReplacementOption } from "@vscode/extension-telemetry";
2+
3+
export class TelemetryFilter {
4+
public static hideUrlOption: ReplacementOption = {
5+
lookup: /https?:\/\/[^:\s]+:[^@\s]+@[^\s]+/g, // match URLs with embedded credentials
6+
replacementString: "<REDACTED: sensitive-url>",
7+
};
8+
}

0 commit comments

Comments
 (0)