From d3c832a93724759180abe47d91392b3c624a99fc Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Thu, 1 Dec 2022 10:57:41 -0600 Subject: [PATCH] fix windows --- .../binary/binary-integrity-check-source.js | 22 ++++++------------- scripts/binary/binary-sources.js | 2 -- scripts/binary/smoke.js | 12 ---------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/scripts/binary/binary-integrity-check-source.js b/scripts/binary/binary-integrity-check-source.js index 5dc05ed44270..2f48e83ec1fe 100644 --- a/scripts/binary/binary-integrity-check-source.js +++ b/scripts/binary/binary-integrity-check-source.js @@ -60,14 +60,6 @@ function validateFs (fs) { } } -function validatePath (path, crypto) { - const pathJoinHash = crypto.createHmac('md5', 'HMAC_SECRET').update(toString.call(path.join)).digest('hex') - - if (pathJoinHash !== 'PATH_JOIN_HASH') { - throw new Error(`Integrity check failed for path.join.toString()`) - } -} - function validateCrypto (crypto) { if (toString.call(crypto.createHmac) !== `CRYPTO_CREATE_HMAC_TO_STRING`) { throw new Error(`Integrity check failed for crypto.createHmac.toString()`) @@ -87,14 +79,12 @@ function integrityCheck (options) { const require = options.require const electron = require('electron') const fs = require('fs') - const path = require('path') const crypto = require('crypto') validateToString() validateElectron(electron) validateFs(fs) validateCrypto(crypto) - validatePath(path, crypto) const appPath = electron.app.getAppPath() @@ -128,30 +118,32 @@ function integrityCheck (options) { }, { functionName: 'Module._extensions.', - fileName: path.join(appPath, 'node_modules', 'bytenode', 'lib', 'index.js'), + // eslint-disable-next-line no-undef + fileName: [appPath, 'node_modules', 'bytenode', 'lib', 'index.js'].join(PATH_SEP), }, { - fileName: path.join(appPath, 'index.js'), + // eslint-disable-next-line no-undef + fileName: [appPath, 'index.js'].join(PATH_SEP), }, ], }) // eslint-disable-next-line no-undef - const mainIndexHash = crypto.createHmac('md5', 'HMAC_SECRET').update(fs.readFileSync(path.join(appPath, 'index.js'), 'utf8')).digest('hex') + const mainIndexHash = crypto.createHmac('md5', 'HMAC_SECRET').update(fs.readFileSync([appPath, 'index.js'].join(PATH_SEP), 'utf8')).digest('hex') if (mainIndexHash !== 'MAIN_INDEX_HASH') { throw new Error(`Integrity check failed for main index.js file`) } // eslint-disable-next-line no-undef - const bytenodeHash = crypto.createHmac('md5', 'HMAC_SECRET').update(fs.readFileSync(path.join(appPath, 'node_modules', 'bytenode', 'lib', 'index.js'), 'utf8')).digest('hex') + const bytenodeHash = crypto.createHmac('md5', 'HMAC_SECRET').update(fs.readFileSync([appPath, 'node_modules', 'bytenode', 'lib', 'index.js'].join(PATH_SEP), 'utf8')).digest('hex') if (bytenodeHash !== 'BYTENODE_HASH') { throw new Error(`Integrity check failed for main bytenode.js file`) } // eslint-disable-next-line no-undef - const indexJscHash = crypto.createHmac('md5', 'HMAC_SECRET').update(fs.readFileSync(path.join(appPath, 'packages', 'server', 'index.jsc'), 'utf8')).digest('hex') + const indexJscHash = crypto.createHmac('md5', 'HMAC_SECRET').update(fs.readFileSync([appPath, 'packages', 'server', 'index.jsc'].join(PATH_SEP), 'utf8')).digest('hex') if (indexJscHash !== 'INDEX_JSC_HASH') { throw new Error(`Integrity check failed for main server index.jsc file`) diff --git a/scripts/binary/binary-sources.js b/scripts/binary/binary-sources.js index 8af858a4ecb2..1550526b0a9f 100644 --- a/scripts/binary/binary-sources.js +++ b/scripts/binary/binary-sources.js @@ -21,14 +21,12 @@ const getIntegrityCheckSource = (baseDirectory) => { const mainIndexHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './index.js'), 'utf8')).digest('hex') const bytenodeHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './node_modules/bytenode/lib/index.js'), 'utf8')).digest('hex') const indexJscHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './packages/server/index.jsc'), 'utf8')).digest('hex') - const pathJoinHash = crypto.createHmac('md5', secret).update(path.join.toString()).digest('hex') return fileSource.split('\n').join(`\n `) .replaceAll('MAIN_INDEX_HASH', mainIndexHash) .replaceAll('BYTENODE_HASH', bytenodeHash) .replaceAll('INDEX_JSC_HASH', indexJscHash) .replaceAll('HMAC_SECRET', secret) - .replaceAll('PATH_JOIN_HASH', pathJoinHash) .replaceAll('CRYPTO_CREATE_HMAC_TO_STRING', escapeString(crypto.createHmac.toString())) .replaceAll('CRYPTO_HMAC_UPDATE_TO_STRING', escapeString(crypto.Hmac.prototype.update.toString())) .replaceAll('CRYPTO_HMAC_DIGEST_TO_STRING', escapeString(crypto.Hmac.prototype.digest.toString())) diff --git a/scripts/binary/smoke.js b/scripts/binary/smoke.js index 8462f5002bf8..75a9d2c71ddd 100644 --- a/scripts/binary/smoke.js +++ b/scripts/binary/smoke.js @@ -202,12 +202,6 @@ const runV8SnapshotProjectTest = function (buildAppExecutable, e2e) { } const runErroringProjectTest = function (buildAppExecutable, e2e, testName, errorMessage) { - if (shouldSkipProjectTest()) { - console.log('skipping project test') - - return Promise.resolve() - } - return new Promise((resolve, reject) => { const env = _.omit(process.env, 'CYPRESS_INTERNAL_ENV') @@ -254,12 +248,6 @@ const runErroringProjectTest = function (buildAppExecutable, e2e, testName, erro } const runIntegrityTest = async function (buildAppExecutable, buildAppDir, e2e) { - if (shouldSkipProjectTest()) { - console.log('skipping failing project test') - - return - } - const testCorruptingFile = async (file, errorMessage) => { const contents = await fs.readFile(file)