qatools-runner 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +12 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -19,7 +19,7 @@ import fs from 'node:fs'
19
19
  import os from 'node:os'
20
20
  import path from 'node:path'
21
21
 
22
- const VERSION = '0.1.0'
22
+ const VERSION = '0.1.1'
23
23
 
24
24
  /* ── options ── */
25
25
  const argv = process.argv.slice(2)
@@ -236,8 +236,17 @@ const server = http.createServer(async (req, res) => {
236
236
  /open?code=… sets a same-site cookie, then the files load normally. */
237
237
  if (req.method === 'GET' && url.pathname === '/open') {
238
238
  if (!codeOk(url.searchParams.get('code'))) { res.writeHead(401, { 'content-type': 'text/plain' }).end('Wrong pairing code'); return }
239
- const to = url.searchParams.get('to') === 'shot' ? `/files/${url.searchParams.get('p') ?? ''}` : '/report/index.html'
240
- res.writeHead(302, { 'set-cookie': `qatools_runner=${CODE}; Path=/; HttpOnly; SameSite=Strict`, location: to }).end()
239
+ const p = url.searchParams.get('p') ?? ''
240
+ const to = url.searchParams.get('to') === 'shot' && /^(test-results|playwright-report)\/[\w./ -]+$/.test(p) && !p.includes('..')
241
+ ? `/files/${p.split('/').map(encodeURIComponent).join('/')}` : '/report/index.html'
242
+ /* Not a 302: the click started on qatools.dev, and browsers do not send a
243
+ SameSite=Strict cookie on a redirect that another site started. This page
244
+ sets the cookie, then moves on from OUR origin, so the cookie is sent. */
245
+ res.writeHead(200, {
246
+ 'set-cookie': `qatools_runner=${CODE}; Path=/; HttpOnly; SameSite=Strict`,
247
+ 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store', 'referrer-policy': 'no-referrer',
248
+ }).end(`<!doctype html><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=${to}"><title>Opening…</title>` +
249
+ `<p style="font:14px system-ui;padding:24px">Opening… <a href="${to}">continue</a></p><script>location.replace(${JSON.stringify(to)})</script>`)
241
250
  return
242
251
  }
243
252
  if (req.method === 'GET' && (url.pathname.startsWith('/report/') || url.pathname.startsWith('/files/'))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qatools-runner",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Run the Playwright tests you write in the QATools Playwright Online IDE in a real browser on your own computer.",
5
5
  "license": "MIT",
6
6
  "type": "module",