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

Add security headers to dev server #1609

Merged
merged 4 commits into from
Aug 25, 2023
Merged

Add security headers to dev server #1609

merged 4 commits into from
Aug 25, 2023

Conversation

lukaw3d
Copy link
Member

@lukaw3d lukaw3d commented Aug 23, 2023

No description provided.

@lukaw3d lukaw3d requested a review from buberdds August 23, 2023 20:01
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 23, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: c907220
Status: ✅  Deploy successful!
Preview URL: https://4035f8d6.oasis-wallet.pages.dev
Branch Preview URL: https://lw-dev-e2e.oasis-wallet.pages.dev

View logs

@github-actions
Copy link

github-actions bot commented Aug 23, 2023

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 12 0 0.07s
✅ JAVASCRIPT eslint 2 0 0 4.36s
✅ JSON eslint-plugin-jsonc 1 0 0 0.85s
✅ JSON jsonlint 1 0 0.28s
✅ JSON npm-package-json-lint yes no 0.72s
✅ JSON prettier 1 0 0 0.35s
✅ JSON v8r 1 0 4.06s
⚠️ MARKDOWN markdownlint 1 0 1 0.72s
✅ MARKDOWN markdown-table-formatter 1 0 0 0.26s
✅ REPOSITORY checkov yes no 38.4s
✅ REPOSITORY git_diff yes no 0.0s
✅ REPOSITORY grype yes no 15.4s
✅ REPOSITORY trivy-sbom yes no 2.74s
✅ REPOSITORY trufflehog yes no 139.23s
✅ TSX eslint 1 0 0 4.8s
✅ TYPESCRIPT eslint 6 0 0 5.21s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@lukaw3d lukaw3d force-pushed the lw/dev-e2e branch 2 times, most recently from d6c8ea9 to cc58ea9 Compare August 24, 2023 12:28
@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

Merging #1609 (4475e23) into master (4e7f83e) will decrease coverage by 0.14%.
The diff coverage is 33.33%.

❗ Current head 4475e23 differs from pull request most recent head c907220. Consider uploading reports for the commit c907220 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1609      +/-   ##
==========================================
- Coverage   83.01%   82.87%   -0.14%     
==========================================
  Files         157      157              
  Lines        4073     4075       +2     
  Branches      730      730              
==========================================
- Hits         3381     3377       -4     
- Misses        692      698       +6     
Flag Coverage Δ
cypress 51.19% <33.33%> (-0.04%) ⬇️
jest 77.87% <0.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/app/pages/E2EPage/index.tsx 48.14% <33.33%> (-1.86%) ⬇️

... and 2 files with indirect coverage changes

const hmrWebsocket = `
ws://localhost:2222
`
const reactErrorOverlay = `
'sha256-RV6I4HWPb71LvA27WVD3cEz8GsJrHlfcM/2X2Q5gV00='
Copy link
Contributor

Choose a reason for hiding this comment

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

What generates this value? Is it going to be the same across react versions?

Copy link
Member Author

Choose a reason for hiding this comment

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

It depends on part of the built version of react-error-overlay library (added by parcel). b6fd0c5 is supposed to make sure we notice if we have to change it after random dependency updates

I'll add this to make it more explicitly connected

expect((await page.request.head('/')).headers()['content-security-policy']).toContain(reactErrorOverlay)

Copy link
Member Author

Choose a reason for hiding this comment

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

and I'm relying on browser to print the hash. I can't reproduce it

const fs = require('fs')
const crypto = require('crypto')

const file = fs.readFileSync('./node_modules/react-error-overlay/lib/index.js', 'utf-8')
const script = file.slice(
  file.indexOf('/*! For license'),
  file.indexOf('iframeReady()}]);') + 'iframeReady()}]);'.length,
)
console.log(`${script.slice(0, 20)}...${script.slice(-20)}`)
console.log(crypto.createHash('sha256').update(script).digest('base64'))
// c1+FzHlBWznidUzzL/gYMDO8mS0XL4lAvO5NaizuNZs=
// expected RV6I4HWPb71LvA27WVD3cEz8GsJrHlfcM/2X2Q5gV00=

Copy link
Member Author

Choose a reason for hiding this comment

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

Update: this would work. But it's still terribly ugly:

const fs = require('fs')
const crypto = require('crypto')
const vm = require('vm')

const file = fs.readFileSync('./node_modules/react-error-overlay/lib/index.js', 'utf-8')

const strScript = file.slice(
  file.indexOf("'/*! For license"),
  file.indexOf("iframeReady()}]);'") + "iframeReady()}]);'".length,
)
const script = vm.runInNewContext(strScript)

console.log(`${script.slice(0, 20)}...${script.slice(-20)}`)
console.log(crypto.createHash('sha256').update(script).digest('base64'))

@lukaw3d lukaw3d enabled auto-merge August 25, 2023 18:08
@lukaw3d lukaw3d merged commit 519f2ca into master Aug 25, 2023
@lukaw3d lukaw3d deleted the lw/dev-e2e branch August 25, 2023 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants