Skip to content

Commit 4d31fd2

Browse files
committed
[wip] Hash newly added data
Still need to hash the file path. Could try to hash the lock path and use leaf for file name unhashed or set them as properties at the end with some unhashed hardvalue like dir ; hashed. file: hashed
1 parent f874acb commit 4d31fd2

File tree

6 files changed

+42
-10
lines changed

6 files changed

+42
-10
lines changed

vscode-dotnet-runtime-library/src/EventStream/EventStreamEvents.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path';
77
import { IDotnetInstallationContext } from '../Acquisition/IDotnetInstallationContext';
88
import { EventType } from './EventType';
99
import { IEvent } from './IEvent';
10+
import { TelemetryUtilities } from './FileUtilities';
1011

1112
// tslint:disable max-classes-per-file
1213

@@ -19,7 +20,7 @@ export class DotnetAcquisitionStarted extends IEvent {
1920
}
2021

2122
public getProperties() {
22-
return {AcquisitionStartVersion : this.version, extensionId : this.requestingExtensionId};
23+
return {AcquisitionStartVersion : this.version, extensionId : TelemetryUtilities.HashData(this.requestingExtensionId)};
2324
}
2425
}
2526

@@ -32,7 +33,7 @@ export class DotnetRuntimeAcquisitionStarted extends IEvent {
3233
}
3334

3435
public getProperties() {
35-
return {extensionId : this.requestingExtensionId};
36+
return {extensionId : TelemetryUtilities.HashData(this.requestingExtensionId)};
3637
}
3738
}
3839

@@ -45,7 +46,7 @@ export class DotnetSDKAcquisitionStarted extends IEvent {
4546
}
4647

4748
public getProperties() {
48-
return {extensionId : this.requestingExtensionId};
49+
return {extensionId : TelemetryUtilities.HashData(this.requestingExtensionId)};
4950
}
5051
}
5152

@@ -313,7 +314,8 @@ export class DotnetAcquisitionInProgress extends IEvent {
313314
constructor(public readonly version: string, public readonly requestingExtensionId: string | null) { super(); }
314315

315316
public getProperties() {
316-
return {InProgressInstallationVersion : this.version, extensionId : this.requestingExtensionId != null ? this.requestingExtensionId : ''};
317+
return {InProgressInstallationVersion : this.version, extensionId : this.requestingExtensionId != null ?
318+
TelemetryUtilities.HashData(this.requestingExtensionId) : ''};
317319
}
318320
}
319321

@@ -324,7 +326,8 @@ export class DotnetAcquisitionAlreadyInstalled extends IEvent {
324326
constructor(public readonly version: string, public readonly requestingExtensionId: string | null) { super(); }
325327

326328
public getProperties() {
327-
return {AlreadyInstalledVersion : this.version, extensionId : this.requestingExtensionId != null ? this.requestingExtensionId : ''};
329+
return {AlreadyInstalledVersion : this.version, extensionId : this.requestingExtensionId != null ?
330+
TelemetryUtilities.HashData(this.requestingExtensionId) : ''};
328331
}
329332
}
330333

@@ -362,7 +365,7 @@ export class DotnetAcquisitionRequested extends DotnetAcquisitionMessage {
362365

363366
public getProperties() {
364367
return {AcquisitionStartVersion : this.version,
365-
RequestingExtensionId: this.requestingId};
368+
RequestingExtensionId: TelemetryUtilities.HashData(this.requestingId)};
366369
}
367370
}
368371

@@ -376,7 +379,7 @@ export class DotnetAcquisitionStatusRequested extends DotnetAcquisitionMessage {
376379

377380
public getProperties() {
378381
return {AcquisitionStartVersion : this.version,
379-
RequestingExtensionId: this.requestingId};
382+
RequestingExtensionId: TelemetryUtilities.HashData(this.requestingId)};
380383
}
381384
}
382385

vscode-dotnet-runtime-library/src/EventStream/LoggingObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ------------------------------------------------------------------------------------------ */
55
import * as fs from 'fs';
66
import { IEvent } from './IEvent';
7-
import { ILoggingObserver } from './ILoggingObserver';
7+
import { ILoggingObserver } from '../test/ILoggingObserver';
88

99
export class LoggingObserver implements ILoggingObserver {
1010
private log: string[] = [];
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* --------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
* ------------------------------------------------------------------------------------------ */
5+
import * as crypto from 'crypto';
6+
import { TextEncoder } from 'util';
7+
8+
export class TelemetryUtilities
9+
{
10+
public static HashData(dataToHash: string) : string
11+
{
12+
const hasher = crypto.createHash('sha256');
13+
const utf8Bytes = new TextEncoder().encode(dataToHash.toUpperCase());
14+
const hashedData = hasher.update(utf8Bytes).digest('hex').toLowerCase();
15+
return hashedData;
16+
}
17+
}

vscode-dotnet-runtime-library/src/Utils/IIssueContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
55
import { IEventStream } from '../EventStream/EventStream';
6-
import { ILoggingObserver } from '../EventStream/ILoggingObserver';
6+
import { ILoggingObserver } from '../test/ILoggingObserver';
77
import { IWindowDisplayWorker } from '../EventStream/IWindowDisplayWorker';
88
import { ErrorConfiguration } from './ErrorHandler';
99
import { IExtensionConfigurationWorker } from './IExtensionConfigurationWorker';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* --------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
* ------------------------------------------------------------------------------------------ */
5+
import { IEvent } from '../EventStream/IEvent';
6+
import { IEventStreamObserver } from '../EventStream/IEventStreamObserver';
7+
8+
export interface ILoggingObserver extends IEventStreamObserver {
9+
post(event: IEvent): void;
10+
dispose(): void;
11+
getFileLocation(): string;
12+
}

vscode-dotnet-runtime-library/src/test/mocks/MockObjects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { VersionResolver } from '../../Acquisition/VersionResolver';
1212
import { IEventStream } from '../../EventStream/EventStream';
1313
import { DotnetAcquisitionCompleted, TestAcquireCalled } from '../../EventStream/EventStreamEvents';
1414
import { IEvent } from '../../EventStream/IEvent';
15-
import { ILoggingObserver } from '../../EventStream/ILoggingObserver';
15+
import { ILoggingObserver } from '../ILoggingObserver';
1616
import { ITelemetryReporter } from '../../EventStream/TelemetryObserver';
1717
import { IExistingPath, IExtensionConfiguration } from '../../IExtensionContext';
1818
import { IExtensionState } from '../../IExtensionState';

0 commit comments

Comments
 (0)