chore: address codeql warnings (#201776)

This commit is contained in:
Robo 2024-01-05 18:03:05 +09:00 committed by GitHub
parent c563e053ba
commit cbbef4dc01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View file

@ -34,6 +34,7 @@ function getElectronVersion() {
return { electronVersion, msBuildId };
}
function getSha(filename) {
// CodeQL [SM04514] Hash logic cannot be changed due to external dependency, also the code is only used during build.
const hash = (0, crypto_1.createHash)('sha1');
// Read file 1 MB at a time
const fd = fs.openSync(filename, 'r');

View file

@ -45,6 +45,7 @@ function getElectronVersion(): Record<string, string> {
}
function getSha(filename: fs.PathLike): string {
// CodeQL [SM04514] Hash logic cannot be changed due to external dependency, also the code is only used during build.
const hash = createHash('sha1');
// Read file 1 MB at a time
const fd = fs.openSync(filename, 'r');

View file

@ -785,11 +785,12 @@ export function createRandomIPCHandle(): string {
}
export function createStaticIPCHandle(directoryPath: string, type: string, version: string): string {
const scope = createHash('md5').update(directoryPath).digest('hex');
const scope = createHash('sha256').update(directoryPath).digest('hex');
const scopeForSocket = scope.substr(0, 8);
// Windows: use named pipe
if (process.platform === 'win32') {
return `\\\\.\\pipe\\${scope}-${version}-${type}-sock`;
return `\\\\.\\pipe\\${scopeForSocket}-${version}-${type}-sock`;
}
// Mac & Unix: Use socket file
@ -799,7 +800,6 @@ export function createStaticIPCHandle(directoryPath: string, type: string, versi
const versionForSocket = version.substr(0, 4);
const typeForSocket = type.substr(0, 6);
const scopeForSocket = scope.substr(0, 8);
let result: string;
if (process.platform !== 'darwin' && XDG_RUNTIME_DIR && !process.env['VSCODE_PORTABLE']) {