Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buggy error cleaning #164175

Merged
merged 2 commits into from Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vs/platform/telemetry/common/telemetryService.ts
Expand Up @@ -53,8 +53,8 @@ export class TelemetryService implements ITelemetryService {
this._piiPaths = config.piiPaths || [];
this._sendErrorTelemetry = !!config.sendErrorTelemetry;

// static cleanup pattern for: `file:///DANGEROUS/PATH/resources/app/Useful/Information`
this._cleanupPatterns = [/file:\/\/\/.*?\/resources\/app\//gi];
// static cleanup pattern for: `vscode-file:///DANGEROUS/PATH/resources/app/Useful/Information`
this._cleanupPatterns = [/(vscode-)?file:\/\/\/.*?\/resources\/app\//gi];

for (const piiPath of this._piiPaths) {
this._cleanupPatterns.push(new RegExp(escapeRegExpCharacters(piiPath), 'gi'));
Expand Down
8 changes: 6 additions & 2 deletions src/vs/platform/telemetry/common/telemetryUtils.ts
Expand Up @@ -310,8 +310,12 @@ function anonymizeFilePaths(stack: string, cleanupPatterns: RegExp[]): string {
if (!result) {
break;
}
// Anoynimize user file paths that do not need to be retained or cleaned up.
if (!nodeModulesRegex.test(result[0]) && cleanUpIndexes.every(([x, y]) => result.index < x || result.index >= y)) {

// Check to see if the any cleanupIndexes partially overlap with this match
const overlappingRange = cleanUpIndexes.some(([start, end]) => result.index < end && start < fileRegex.lastIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inclusive comparison needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this end up keeping the beginning of the paths?


// anoynimize user file paths that do not need to be retained or cleaned up.
if (!nodeModulesRegex.test(result[0]) && !overlappingRange) {
updatedStack += stack.substring(lastIndex, result.index) + '<REDACTED: user-file-path>';
lastIndex = fileRegex.lastIndex;
}
Expand Down
Expand Up @@ -75,7 +75,7 @@ export class TelemetryService extends Disposable implements ITelemetryService {
}

publicLogError2<E extends ClassifiedEvent<OmitMetadata<T>> = never, T extends IGDPRProperty = never>(eventName: string, data?: StrictPropertyCheck<T, E>) {
return this.publicLog(eventName, data as ITelemetryData);
return this.publicLogError(eventName, data as ITelemetryData);
}


Expand Down