mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 09:35:41 -05:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -11,7 +11,6 @@ import { deepClone } from 'vs/base/common/objects';
|
||||
|
||||
/* __GDPR__FRAGMENT__
|
||||
"IExperiments" : {
|
||||
"deployToAzureQuickLink" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
export interface IExperiments {
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface ITelemetryService {
|
||||
* Sends a telemetry event that has been privacy approved.
|
||||
* Do not call this unless you have been given approval.
|
||||
*/
|
||||
publicLog(eventName: string, data?: ITelemetryData): TPromise<void>;
|
||||
publicLog(eventName: string, data?: ITelemetryData, anonymizeFilePaths?: boolean): TPromise<void>;
|
||||
|
||||
getTelemetryInfo(): TPromise<ITelemetryInfo>;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export class TelemetryService implements ITelemetryService {
|
||||
private _userOptIn: boolean;
|
||||
|
||||
private _disposables: IDisposable[] = [];
|
||||
private _cleanupPatterns: [RegExp, string][] = [];
|
||||
private _cleanupPatterns: RegExp[] = [];
|
||||
|
||||
constructor(
|
||||
config: ITelemetryServiceConfig,
|
||||
@@ -48,18 +48,11 @@ export class TelemetryService implements ITelemetryService {
|
||||
this._piiPaths = config.piiPaths || [];
|
||||
this._userOptIn = typeof config.userOptIn === 'undefined' ? true : config.userOptIn;
|
||||
|
||||
// static cleanup patterns for:
|
||||
// #1 `file:///DANGEROUS/PATH/resources/app/Useful/Information`
|
||||
// #2 // Any other file path that doesn't match the approved form above should be cleaned.
|
||||
// #3 "Error: ENOENT; no such file or directory" is often followed with PII, clean it
|
||||
this._cleanupPatterns.push(
|
||||
[/file:\/\/\/.*?\/resources\/app\//gi, ''],
|
||||
[/file:\/\/\/.*/gi, ''],
|
||||
[/ENOENT: no such file or directory.*?\'([^\']+)\'/gi, 'ENOENT: no such file or directory']
|
||||
);
|
||||
// static cleanup pattern for: `file:///DANGEROUS/PATH/resources/app/Useful/Information`
|
||||
this._cleanupPatterns = [/file:\/\/\/.*?\/resources\/app\//gi];
|
||||
|
||||
for (let piiPath of this._piiPaths) {
|
||||
this._cleanupPatterns.push([new RegExp(escapeRegExpCharacters(piiPath), 'gi'), '']);
|
||||
this._cleanupPatterns.push(new RegExp(escapeRegExpCharacters(piiPath), 'gi'));
|
||||
}
|
||||
|
||||
if (this._configurationService) {
|
||||
@@ -67,7 +60,7 @@ export class TelemetryService implements ITelemetryService {
|
||||
this._configurationService.onDidChangeConfiguration(this._updateUserOptIn, this, this._disposables);
|
||||
/* __GDPR__
|
||||
"optInStatus" : {
|
||||
"optIn" : { "classification": "SystemMetaData", "purpose": "BusinessInsight" }
|
||||
"optIn" : { "classification": "SystemMetaData", "purpose": "BusinessInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.publicLog('optInStatus', { optIn: this._userOptIn });
|
||||
@@ -98,7 +91,7 @@ export class TelemetryService implements ITelemetryService {
|
||||
this._disposables = dispose(this._disposables);
|
||||
}
|
||||
|
||||
publicLog(eventName: string, data?: ITelemetryData): TPromise<any> {
|
||||
publicLog(eventName: string, data?: ITelemetryData, anonymizeFilePaths?: boolean): TPromise<any> {
|
||||
// don't send events when the user is optout
|
||||
if (!this._userOptIn) {
|
||||
return TPromise.as(undefined);
|
||||
@@ -112,7 +105,7 @@ export class TelemetryService implements ITelemetryService {
|
||||
// (last) remove all PII from data
|
||||
data = cloneAndChange(data, value => {
|
||||
if (typeof value === 'string') {
|
||||
return this._cleanupInfo(value);
|
||||
return this._cleanupInfo(value, anonymizeFilePaths);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
@@ -125,15 +118,41 @@ export class TelemetryService implements ITelemetryService {
|
||||
});
|
||||
}
|
||||
|
||||
private _cleanupInfo(stack: string): string {
|
||||
private _cleanupInfo(stack: string, anonymizeFilePaths?: boolean): string {
|
||||
let updatedStack = stack;
|
||||
|
||||
// sanitize with configured cleanup patterns
|
||||
for (let tuple of this._cleanupPatterns) {
|
||||
let [regexp, replaceValue] = tuple;
|
||||
stack = stack.replace(regexp, replaceValue);
|
||||
if (anonymizeFilePaths) {
|
||||
const cleanUpIndexes: [number, number][] = [];
|
||||
for (let regexp of this._cleanupPatterns) {
|
||||
while (true) {
|
||||
const result = regexp.exec(stack);
|
||||
if (!result) {
|
||||
break;
|
||||
}
|
||||
cleanUpIndexes.push([result.index, regexp.lastIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
const nodeModulesRegex = /^[\\\/]?(node_modules|node_modules\.asar)[\\\/]/;
|
||||
const fileRegex = /(file:\/\/)?([a-zA-Z]:(\\\\|\\|\/)|(\\\\|\\|\/))?([\w-\._]+(\\\\|\\|\/))+[\w-\._]*/g;
|
||||
|
||||
while (true) {
|
||||
const result = fileRegex.exec(stack);
|
||||
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)) {
|
||||
updatedStack = updatedStack.slice(0, result.index) + result[0].replace(/./g, 'a') + updatedStack.slice(fileRegex.lastIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
// sanitize with configured cleanup patterns
|
||||
for (let regexp of this._cleanupPatterns) {
|
||||
updatedStack = updatedStack.replace(regexp, '');
|
||||
}
|
||||
return updatedStack;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { guessMimeTypes } from 'vs/base/common/mime';
|
||||
import paths = require('vs/base/common/paths');
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { IKeybindingService, KeybindingSource } from 'vs/platform/keybinding/common/keybinding';
|
||||
@@ -42,7 +42,7 @@ export const NullAppender: ITelemetryAppender = { log: () => null };
|
||||
"URIDescriptor" : {
|
||||
"mimeType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"ext": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"path": { "classification": "CustomerContent", "purpose": "FeatureInsight" }
|
||||
"path": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
export interface URIDescriptor {
|
||||
|
||||
Reference in New Issue
Block a user