Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v5.0-release' into test-retries
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb committed Jul 17, 2020
2 parents fabced7 + 09c72e3 commit 8b3ba9c
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 212 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"mocha-multi-reporters": "1.1.7",
"mock-fs": "4.9.0",
"parse-github-repo-url": "1.4.1",
"patch-package": "6.2.0",
"patch-package": "6.2.2",
"percy": "0.26.9",
"plist": "2.1.0",
"pluralize": "8.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/server/lib/plugins/child/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require('graceful-fs').gracefulify(require('fs'))

require('../../util/suppress_unauthorized_warning').suppress()

const ipc = require('../util').wrapIpc(process)
const { file: pluginsFile, projectRoot } = require('minimist')(process.argv.slice(2))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
const _ = require('lodash')

const originalEmitWarning = process.emitWarning

Expand All @@ -9,22 +9,32 @@ let suppressed = false
* we work on proper SSL verification.
* https://github.com/cypress-io/cypress/issues/5248
*/
export function suppress () {
const suppress = () => {
if (suppressed) {
return
}

suppressed = true

process.emitWarning = (warning, ...args) => {
process.emitWarning = (warning, type, code, ...args) => {
if (_.isString(warning) && _.includes(warning, 'NODE_TLS_REJECT_UNAUTHORIZED')) {
// node will only emit the warning once
// https://github.com/nodejs/node/blob/82f89ec8c1554964f5029fab1cf0f4fad1fa55a8/lib/_tls_wrap.js#L1378-L1384
process.emitWarning = originalEmitWarning

return
}

return originalEmitWarning.call(process, warning, ...args)
// silence Buffer allocation warning since there are no
// security problems due to the way Cypress works
if (code === 'DEP0005') {
// https://github.com/nodejs/node/blob/master/lib/buffer.js#L176-L192

return
}

return originalEmitWarning.call(process, warning, type, code, ...args)
}
}

module.exports = {
suppress,
}
6 changes: 1 addition & 5 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@
"productName": "Cypress",
"workspaces": {
"nohoist": [
"foxdriver",
"**/@cypress/browserify-preprocessor",
"@cypress/browserify-preprocessor/**",
"**/browserify",
"browserify/**"
"foxdriver"
]
},
"optionalDependencies": {
Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions packages/server/patches/inline-source-map+0.6.2.patch

This file was deleted.

22 changes: 20 additions & 2 deletions packages/server/test/unit/suppress_unauthorized_warning_spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import execa from 'execa'
import '../spec_helper'
import { expect } from 'chai'
import execa from 'execa'
import proxyquire from 'proxyquire'

const ERROR_MESSAGE = 'Setting the NODE_TLS_REJECT_UNAUTHORIZED'

const TLS_CONNECT = `require('tls').connect().on('error', ()=>{});`
const SUPPRESS_WARNING = `require('@packages/ts/register'); require('${__dirname}/../../lib/util/suppress_unauthorized_warning').suppress();`
const SUPPRESS_WARNING = `require('${__dirname}/../../lib/util/suppress_unauthorized_warning').suppress();`

describe('lib/util/suppress_unauthorized_warning', function () {
it('tls.connect emits warning if NODE_TLS_REJECT_UNAUTHORIZED=0 and not suppressed', function () {
Expand All @@ -29,4 +31,20 @@ describe('lib/util/suppress_unauthorized_warning', function () {
expect(stderr).to.not.contain(ERROR_MESSAGE)
})
})

it('does not emit buffer deprecation warnings', () => {
const emitWarning = sinon.spy(process, 'emitWarning')

// force typescript to always be non-requireable
const { suppress } = proxyquire('../../lib/util/suppress_unauthorized_warning', {})

suppress()

// eslint-disable-next-line no-buffer-constructor
new Buffer(0)
// eslint-disable-next-line no-buffer-constructor
new Buffer('asdf')

expect(emitWarning).not.to.be.called
})
})
Loading

0 comments on commit 8b3ba9c

Please sign in to comment.