Skip to content

Commit

Permalink
Remove usage of hash.js (microsoft#24504)
Browse files Browse the repository at this point in the history
Component Governance
  • Loading branch information
karthiknadig authored Dec 9, 2024
1 parent b342559 commit 63c3780
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 6 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,6 @@
"arch": "^2.1.0",
"fs-extra": "^11.2.0",
"glob": "^7.2.0",
"hash.js": "^1.1.7",
"iconv-lite": "^0.6.3",
"inversify": "^6.0.2",
"jsonc-parser": "^3.0.0",
Expand Down
7 changes: 3 additions & 4 deletions src/client/telemetry/importTracker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable class-methods-use-this */
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

Expand All @@ -7,6 +8,7 @@ import { inject, injectable } from 'inversify';
import * as path from 'path';
import { clearTimeout, setTimeout } from 'timers';
import { TextDocument } from 'vscode';
import { createHash } from 'crypto';
import { sendTelemetryEvent } from '.';
import { IExtensionSingleActivationService } from '../activation/types';
import { IDocumentManager } from '../common/application/types';
Expand Down Expand Up @@ -53,9 +55,6 @@ export class ImportTracker implements IExtensionSingleActivationService {

private static sentMatches: Set<string> = new Set<string>();

// eslint-disable-next-line global-require
private hashFn = require('hash.js').sha256;

constructor(
@inject(IDocumentManager) private documentManager: IDocumentManager,
@inject(IDisposableRegistry) private disposables: IDisposableRegistry,
Expand Down Expand Up @@ -120,7 +119,7 @@ export class ImportTracker implements IExtensionSingleActivationService {
ImportTracker.sentMatches.add(packageName);
// Hash the package name so that we will never accidentally see a
// user's private package name.
const hash = this.hashFn().update(packageName).digest('hex');
const hash = createHash('sha256').update(packageName).digest('hex');
sendTelemetryEvent(EventName.HASHED_PACKAGE_NAME, undefined, { hashedName: hash });
}

Expand Down

0 comments on commit 63c3780

Please sign in to comment.