mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
Switch to using sha256 for checksums (fixes CodeQL warning) (#201977)
* Switch to using sha256 for checksums (fixes CodeQL warning) * Fix unit test
This commit is contained in:
@@ -184,7 +184,7 @@ function computeChecksum(filename) {
|
||||
const contents = fs.readFileSync(filename);
|
||||
|
||||
const hash = crypto
|
||||
.createHash('md5')
|
||||
.createHash('sha256')
|
||||
.update(contents)
|
||||
.digest('base64')
|
||||
.replace(/=+$/, '');
|
||||
|
||||
@@ -18,7 +18,7 @@ export class ChecksumService implements IChecksumService {
|
||||
async checksum(resource: URI): Promise<string> {
|
||||
const stream = (await this.fileService.readFileStream(resource)).value;
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
const hash = createHash('md5');
|
||||
const hash = createHash('sha256');
|
||||
|
||||
listenStream(stream, {
|
||||
onData: data => hash.update(data.buffer),
|
||||
|
||||
@@ -35,7 +35,7 @@ suite('Checksum Service', () => {
|
||||
const checksumService = new ChecksumService(fileService);
|
||||
|
||||
const checksum = await checksumService.checksum(URI.file(FileAccess.asFileUri('vs/platform/checksum/test/node/fixtures/lorem.txt').fsPath));
|
||||
assert.ok(checksum === '8mi5KF8kcb817zmlal1kZA' || checksum === 'DnUKbJ1bHPPNZoHgHV25sg'); // depends on line endings git config
|
||||
assert.ok(checksum === 'd/9bMU0ydNCmc/hg8ItWeiLT/ePnf7gyPRQVGpd6tRI' || checksum === 'eJeeTIS0dzi8MZY+nHhjPBVtNbmGqxfVvgEOB4sqVIc'); // depends on line endings git config
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
Reference in New Issue
Block a user