diff --git a/packages/cli/src/commands/engine.ts b/packages/cli/src/commands/engine.ts index 8c00cd86c2..411fe1ddb7 100644 --- a/packages/cli/src/commands/engine.ts +++ b/packages/cli/src/commands/engine.ts @@ -24,6 +24,7 @@ import { telemetryUtils, getHashedEnv, isUserCancelError, + maskSecret, } from "@microsoft/teamsfx-core"; import { cloneDeep, pick } from "lodash"; import path from "path"; @@ -89,6 +90,9 @@ class CLIEngine { globalOptionValues: {}, argumentValues: [], telemetryProperties: { + [TelemetryProperty.CommandFull]: maskSecret(args.join(" "), { + replace: "***", + }), [TelemetryProperty.CommandName]: foundCommand.fullName, [TelemetryProperty.Component]: TelemetryComponentType, [TelemetryProperty.RunFrom]: tryDetectCICDPlatform(), diff --git a/packages/cli/src/commands/models/m365Sideloading.ts b/packages/cli/src/commands/models/m365Sideloading.ts index ede7aeabbe..1837ff07eb 100644 --- a/packages/cli/src/commands/models/m365Sideloading.ts +++ b/packages/cli/src/commands/models/m365Sideloading.ts @@ -75,7 +75,7 @@ export const m365SideloadingCommand: CLICommand = { }, ], telemetry: { - event: TelemetryEvent.M365Sigeloading, + event: TelemetryEvent.Install, }, defaultInteractiveOption: false, handler: async (ctx) => { diff --git a/packages/cli/src/commands/models/m365Unacquire.ts b/packages/cli/src/commands/models/m365Unacquire.ts index 0c1753a4d5..049c0e800b 100644 --- a/packages/cli/src/commands/models/m365Unacquire.ts +++ b/packages/cli/src/commands/models/m365Unacquire.ts @@ -66,7 +66,7 @@ export const m365UnacquireCommand: CLICommand = { }, ], telemetry: { - event: TelemetryEvent.M365Unacquire, + event: TelemetryEvent.Uninstall, }, defaultInteractiveOption: true, handler: async (ctx) => { diff --git a/packages/cli/src/telemetry/cliTelemetryEvents.ts b/packages/cli/src/telemetry/cliTelemetryEvents.ts index adc4c27824..9031a25e3b 100644 --- a/packages/cli/src/telemetry/cliTelemetryEvents.ts +++ b/packages/cli/src/telemetry/cliTelemetryEvents.ts @@ -13,7 +13,7 @@ export enum TelemetryEvent { AccountLoginStart = "login-start", AccountLogin = "login", AccountLoginAzure = "login-azure", - AccountLoginM365 = "login-m365", + AccountLoginM365 = "login-m", AccountLogout = "logout", @@ -113,9 +113,9 @@ export enum TelemetryEvent { Command = "command", // this event is used to track the usage of each command, including --help command - M365Sigeloading = "m365-sideloading", - M365Unacquire = "m365-unacquire", - M365LaunchInfo = "m365-launch-info", + Install = "install", + Uninstall = "uninstall", + M365LaunchInfo = "mos-launch-info", Doctor = "doctor", @@ -155,14 +155,13 @@ export enum TelemetryProperty { Env = "env", SettingsVersion = "settings-version", NewProjectId = "new-project-id", - IsM365 = "is-m365", - IsCreatingM365 = "is-creating-m365", ProgrammingLanguage = "programming-language", HostType = "host-type", RunFrom = "run-from", - + IsCreatingM365 = "is-creating-office", // command related property + CommandFull = "command-full", CommandName = "command-name", CommandHelp = "command-help", CommandVersion = "command-version", diff --git a/packages/fx-core/src/common/secretmasker/masker.ts b/packages/fx-core/src/common/secretmasker/masker.ts index a6404a845e..6a7995722a 100644 --- a/packages/fx-core/src/common/secretmasker/masker.ts +++ b/packages/fx-core/src/common/secretmasker/masker.ts @@ -37,11 +37,11 @@ class SecretMasker { // If the decision function value is positive, classify as 1 (secret), otherwise 0 (non-secret) return decisionValue > 0 ? 1 : 0; } - maskSecret(text: string, replace = "***"): string { + maskSecret(text: string, replace = "***", whiteList?: string[]): string { const tokens = extractFeatures(text); for (const token of tokens) { if (token.type === "splitter") continue; - if (WHITE_LIST.includes(token.token)) continue; + if (whiteList && whiteList.includes(token.token)) continue; const prediction = this.predict(token.vector!); token.label = prediction; if (prediction === 1) { diff --git a/packages/fx-core/src/common/stringUtils.ts b/packages/fx-core/src/common/stringUtils.ts index c57a53d400..ab29aa5ba8 100644 --- a/packages/fx-core/src/common/stringUtils.ts +++ b/packages/fx-core/src/common/stringUtils.ts @@ -21,7 +21,7 @@ export function maskSecret(inputText?: string, option?: MaskSecretOptions): stri if (!inputText) return ""; const replace = option?.replace || SECRET_REPLACE; let output = maskSecretFromEnv(inputText); - output = secretMasker.maskSecret(output, replace); + output = secretMasker.maskSecret(output, replace, option?.whiteList); return output; } diff --git a/packages/fx-core/tests/common/secretMasker.test.ts b/packages/fx-core/tests/common/secretMasker.test.ts index 4b42fdbb6c..478eebb216 100644 --- a/packages/fx-core/tests/common/secretMasker.test.ts +++ b/packages/fx-core/tests/common/secretMasker.test.ts @@ -28,5 +28,11 @@ describe("secret masker", () => { const output = secretMasker.maskSecret("Successfully ran target precommit for project."); assert.equal(output, "Successfully ran target precommit for project."); }); + it("white list", async () => { + const output = secretMasker.maskSecret("mysql -p password123456", undefined, [ + "password123456", + ]); + assert.equal(output, "mysql -p password123456"); + }); }); });