Skip to content

Commit

Permalink
fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthemanuel committed Dec 1, 2022
1 parent 401fbdc commit d3c832a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
22 changes: 7 additions & 15 deletions scripts/binary/binary-integrity-check-source.js
Expand Up @@ -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()`)
Expand All @@ -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()

Expand Down Expand Up @@ -128,30 +118,32 @@ function integrityCheck (options) {
},
{
functionName: 'Module._extensions.<computed>',
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`)
Expand Down
2 changes: 0 additions & 2 deletions scripts/binary/binary-sources.js
Expand Up @@ -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()))
Expand Down
12 changes: 0 additions & 12 deletions scripts/binary/smoke.js
Expand Up @@ -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')

Expand Down Expand Up @@ -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)

Expand Down

3 comments on commit d3c832a

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d3c832a Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.3.0/linux-x64/ryanm/fix/v8-improvements-d3c832a93724759180abe47d91392b3c624a99fc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d3c832a Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.3.0/linux-arm64/ryanm/fix/v8-improvements-d3c832a93724759180abe47d91392b3c624a99fc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d3c832a Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.3.0/darwin-arm64/ryanm/fix/v8-improvements-d3c832a93724759180abe47d91392b3c624a99fc/cypress.tgz

Please sign in to comment.