Skip to content

Commit

Permalink
secure cookie error crash (cypress-io#2685)
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mann committed Nov 1, 2018
1 parent b651925 commit 2333d04
Show file tree
Hide file tree
Showing 245 changed files with 5,052 additions and 2,962 deletions.
59 changes: 59 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,67 @@
"extends": [
"plugin:cypress-dev/general"
],
"rules": {
"no-multiple-empty-lines": ["error", { "max": 1 } ],
"no-else-return": [ "error", { "allowElseIf": false } ],
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
"no-unneeded-ternary": ["error"],
"array-bracket-newline": ["error", "consistent"],
"arrow-body-style": ["error", "always"],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": "return"
},
{
"blankLine": "always",
"prev": [
"const",
"let",
"var",
"if",
"while",
"export",
"cjs-export",
"import",
"cjs-import"
],
"next": "*"
},
{
"blankLine": "any",
"prev": [
"const",
"let",
"var",
"import",
"cjs-import"
],
"next": [
"const",
"let",
"var",
"import",
"cjs-import"
]
}
]
},
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"legacyDecorators": true
}
},
"overrides": {
"files": ["**/*.jsx"],
"rules": {
"arrow-body-style": "off",
}
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ dist
dist-*
build
.history
.vscode
.publish
_test-output
cypress.zip
tmp/
.nyc_output
.vscode/settings.json

# from extension
Cached Theme.pak
Expand Down
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
},
{
"type": "node",
"request": "launch",
"name": "test: active",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"test-debug-package",
],
"args": [
"${file}"
],
"port": 5566,
"console": "integratedTerminal"
},
{
"type": "node",
"request": "attach",
"name": "electron",
"port": 5567,
},
]
}
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "decaffeinate-bulk file",
"type": "shell",
"command": "npm run decaffeinate-bulk -- --file ${file} convert",
"problemMatcher": []
},
{
"label": "decaffeinate-bulk dir",
"type": "shell",
"command": "npm run decaffeinate-bulk -- --dir ${fileDirname} convert",
"problemMatcher": []
},
{
"label": "decaffeinate",
"type": "shell",
"command": "npm run decaffeinate -- ${file}"
},
{
"label": "jscodeshift",
"type": "shell",
"command": "npm run jscodeshift -- ${file}"
}
]
}
56 changes: 56 additions & 0 deletions .vscode/terminals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"autorun": false,
"terminals": [
{
"name": "cypress open",
"focus": true,
"onlySingle": true,
"execute": true,
"command": "npm run cypress:open"
},
{
"name": "cypress run",
"focus": true,
"onlySingle": true,
"execute": false,
"command": "npm run cypress:run -- --project ../project"
},
{
"name": "packages/server test-watch",
"focus": true,
"onlySingle": true,
"execute": false,
"cwd": "[workspaceFolder]/packages/server",
"command": "npm run test-watch -- [file]"
},
{
"name": "packages/server test-e2e",
"focus": true,
"onlySingle": true,
"execute": false,
"cwd": "[workspaceFolder]/packages/server",
"command": "npm run test-e2e -- --spec name"
},
{
"name": "packages/runner watch",
"focus": true,
"onlySingle": true,
"cwd": "[workspaceFolder]/packages/runner",
"command": "npm run watch"
},
{
"name": "packages/driver cypress open",
"focus": true,
"onlySingle": true,
"cwd": "[workspaceFolder]/packages/driver",
"command": "npm run cypress:open"
},
{
"name": "packages/desktop-gui cypress open",
"focus": true,
"onlySingle": true,
"cwd": "[workspaceFolder]/packages/desktop-gui",
"command": "npm run cypress:open"
}
]
}
17 changes: 17 additions & 0 deletions bulk-decaffeinate.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const path = require('path')

module.exports = {
decaffeinateArgs: [
'--use-cs2',
'--loose',
],
jscodeshiftScripts: [
path.resolve('node_modules', 'js-codemod', 'transforms', 'arrow-function.js'),
path.resolve('node_modules', 'js-codemod', 'transforms', 'arrow-function-arguments.js'),
path.resolve('node_modules', 'js-codemod', 'transforms', 'no-vars.js'),
path.resolve('node_modules', 'jscodemods', 'transforms', 'fix-class-assign-construct.js'),
path.resolve('node_modules', 'jscodemods', 'decaffeinate', 'fix-multi-assign-class-export.js'),
path.resolve('node_modules', 'jscodemods', 'decaffeinate', 'fix-implicit-return-assignment.js'),
path.resolve('node_modules', 'jscodemods', 'decaffeinate', 'fix-existential-conditional-assignment.js'),
],
}
8 changes: 8 additions & 0 deletions cli/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const cache = require('./tasks/cache')
// we want to print help for the current command and exit with an error
function unknownOption (flag, type = 'option') {
if (this._allowUnknownOption) return

logger.error()
logger.error(` error: unknown ${type}:`, flag)
logger.error()
Expand Down Expand Up @@ -87,6 +88,7 @@ function includesVersion (args) {

function showVersions () {
debug('printing Cypress version')

return require('./exec/versions')
.getVersions()
.then((versions = {}) => {
Expand Down Expand Up @@ -187,6 +189,7 @@ module.exports = {
const defaultOpts = { force: true, welcomeMessage: false }
const parsedOpts = parseOpts(opts)
const options = _.extend(parsedOpts, defaultOpts)

require('./tasks/verify')
.start(options)
.catch(util.logErrorExit1)
Expand All @@ -203,6 +206,7 @@ module.exports = {
if (opts.command || !_.includes(['list', 'path', 'clear'], opts)) {
unknownOption.call(this, `cache ${opts}`, 'sub-command')
}

cache[opts]()
})

Expand All @@ -219,10 +223,12 @@ module.exports = {
// Deprecated Catches

const firstCommand = args[2]

if (!_.includes(knownCommands, firstCommand)) {
debug('unknown command %s', firstCommand)
logger.error('Unknown command', `"${firstCommand}"`)
program.outputHelp()

return util.exit(1)
}

Expand All @@ -233,7 +239,9 @@ module.exports = {
// so we have to manually catch '-v, --version'
return showVersions()
}

debug('program parsing arguments')

return program.parse(args)
},
}
Expand Down
2 changes: 2 additions & 0 deletions cli/lib/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const util = require('./util')
const cypressModuleApi = {
open (options = {}) {
options = util.normalizeModuleOptions(options)

return open.start(options)
},

Expand All @@ -31,6 +32,7 @@ const cypressModuleApi = {
message: 'Could not find Cypress test run results',
}
}

return output
})
})
Expand Down
51 changes: 32 additions & 19 deletions cli/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,33 @@ const failedUnzip = {
`,
}

const missingApp = (binaryDir) => ({
description: `No version of Cypress is installed in: ${chalk.cyan(binaryDir)}`,
solution: stripIndent`
const missingApp = (binaryDir) => {
return {
description: `No version of Cypress is installed in: ${chalk.cyan(binaryDir)}`,
solution: stripIndent`
\nPlease reinstall Cypress by running: ${chalk.cyan('cypress install')}
`,
})
}
}

const binaryNotExecutable = (executable) => ({
description: `Cypress cannot run because the binary does not have executable permissions: ${executable}`,
solution: stripIndent`\n
const binaryNotExecutable = (executable) => {
return {
description: `Cypress cannot run because the binary does not have executable permissions: ${executable}`,
solution: stripIndent`\n
Reasons this may happen:
- node was installed as 'root' or with 'sudo'
- the cypress npm package as 'root' or with 'sudo'
Please check that you have the appropriate user permissions.
`,
})

}
}

const notInstalledCI = (executable) => ({
description: 'The cypress npm package is installed, but the Cypress binary is missing.',
solution: stripIndent`\n
const notInstalledCI = (executable) => {
return {
description: 'The cypress npm package is installed, but the Cypress binary is missing.',
solution: stripIndent`\n
We expected the binary to be installed here: ${chalk.cyan(executable)}
Reasons it may be missing:
Expand All @@ -61,7 +65,8 @@ const notInstalledCI = (executable) => ({
${chalk.blue('https://on.cypress.io/not-installed-ci-error')}
`,
})
}
}

const nonZeroExitCodeXvfb = {
description: 'XVFB exited with a non zero exit code.',
Expand Down Expand Up @@ -146,6 +151,7 @@ const removed = {
const CYPRESS_RUN_BINARY = {
notValid: (value) => {
const properFormat = `**/${state.getPlatformExecutable()}`

return {
description: `Could not run binary set by environment variable CYPRESS_RUN_BINARY=${value}`,
solution: `Ensure the environment variable is a path to the Cypress binary, matching ${properFormat}`,
Expand All @@ -155,15 +161,19 @@ const CYPRESS_RUN_BINARY = {

function getPlatformInfo () {
return util.getOsVersionAsync()
.then((version) => stripIndent`
.then((version) => {
return stripIndent`
Platform: ${os.platform()} (${version})
Cypress Version: ${util.pkgVersion()}
`)
`
})
}

function addPlatformInformation (info) {
return getPlatformInfo()
.then((platform) => merge(info, { platform }))
.then((platform) => {
return merge(info, { platform })
})
}

function formErrorText (info, msg) {
Expand Down Expand Up @@ -216,13 +226,16 @@ function formErrorText (info, msg) {

const raise = (text) => {
const err = new Error(text)

err.known = true
throw err
}

const throwFormErrorText = (info) => (msg) => {
return formErrorText(info, msg)
.then(raise)
const throwFormErrorText = (info) => {
return (msg) => {
return formErrorText(info, msg)
.then(raise)
}
}

module.exports = {
Expand Down
Loading

0 comments on commit 2333d04

Please sign in to comment.