Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not set url on invalid cookies #2788

Merged
merged 2 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/electron/lib/electron.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ module.exports = {

argv.unshift("--inspect-brk=#{dp}")

else
opts = minimist(argv)
if opts.inspectBrk
argv.unshift("--inspect-brk=5566")

cp.spawn(execPath, argv, {stdio: "inherit"})
.on "close", (code) ->
debug("electron closing with code", code)
Expand Down
11 changes: 6 additions & 5 deletions packages/server/__snapshots__/2_cookies_spec.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ exports['e2e cookies passes 1'] = `
✓ handles expired cookies secure
✓ issue: #224 sets expired cookies between redirects
✓ issue: #1321 failing to set or parse cookie
✓ issue: #2724 does not fail on invalid cookies


8 passing
9 passing


(Results)

┌───────────────────────────────────┐
│ Tests: 8
│ Passing: 8
│ Tests: 9
│ Passing: 9
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
Expand All @@ -61,9 +62,9 @@ exports['e2e cookies passes 1'] = `

Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ cookies_spec.coffee XX:XX 8 8 - - - │
│ ✔ cookies_spec.coffee XX:XX 9 9 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
All specs passed! XX:XX 8 8 - - -
All specs passed! XX:XX 9 9 - - -


`
8 changes: 6 additions & 2 deletions packages/server/lib/request.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ newCookieJar = ->

setCookie: (cookieOrStr, uri, options) ->
## store the original URL this cookie was set on
cookie = j.setCookieSync(cookieOrStr, uri, options)
cookie.url = uri
if cookie = j.setCookieSync(cookieOrStr, uri, options)
Copy link
Contributor

Choose a reason for hiding this comment

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

hehe, have you seen my code in a paranoid style where arguments and results are constantly asserted? this is why

## only set cookie URL if it was created correctly
## since servers may send invalid cookies that fail
## to parse - we may get undefined here
cookie.url = uri

return cookie

getCookieString: (uri) ->
Expand Down
3 changes: 2 additions & 1 deletion packages/server/lib/util/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const nestedObjectsInCurlyBracesRe = /\{(.+?)\}/g
const nestedArraysInSquareBracketsRe = /\[(.+?)\]/g
const everythingAfterFirstEqualRe = /=(.+)/

const whitelist = 'cwd appPath execPath apiKey smokeTest getKey generateKey runProject project spec reporter reporterOptions port env ci record updating ping key logs clearLogs returnPkg version mode headed config exit exitWithCode browser runMode outputPath parallel ciBuildId group'.split(' ')
const whitelist = 'cwd appPath execPath apiKey smokeTest getKey generateKey runProject project spec reporter reporterOptions port env ci record updating ping key logs clearLogs returnPkg version mode headed config exit exitWithCode browser runMode outputPath parallel ciBuildId group inspectBrk'.split(' ')

// returns true if the given string has double quote character "
// only at the last position.
Expand Down Expand Up @@ -171,6 +171,7 @@ module.exports = {
'exit-with-code': 'exitWithCode',
'reporter-options': 'reporterOptions',
'output-path': 'outputPath',
'inspect-brk': 'inspectBrk',
}

//# takes an array of args and converts
Expand Down
7 changes: 6 additions & 1 deletion packages/server/test/e2e/2_cookies_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ onServer = (app) ->
# auth=; Domain=.surveymonkey.com; Max-Age=0; Path=/; expires=Wed, 31-Dec-97 23:59:59 GMT

res.send("<html></html>")

app.get "/expirationExpires", (req, res) ->
res.cookie("shouldExpire", "now", {
expires: moment().subtract(1, "day").toDate()
Expand All @@ -60,6 +60,11 @@ onServer = (app) ->

res.send("<html></html>")

app.get "/invalidCookies", (req, res) ->
res.header("Set-Cookie", "foo=bar; domain=nope.not.this.one")

res.send("<html></html>")

describe "e2e cookies", ->
e2e.setup({
servers: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ describe "cookies", ->

.visit("https://localhost:2323/expirationMaxAge")
.getCookies().should("be.empty")

it "issue: #2724 does not fail on invalid cookies", ->
cy.request('https://localhost:2323/invalidCookies')
3 changes: 3 additions & 0 deletions packages/server/test/support/helpers/e2e.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ module.exports = {
if options.exit?
args.push("--exit", options.exit)

if options.inspectBrk
args.push("--inspect-brk")

return args

start: (ctx, options = {}) ->
Expand Down