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

fix: set default for missing cspScriptSrcHashes #5474

Closed
wants to merge 1 commit into from

Conversation

zoellner
Copy link

@zoellner zoellner commented Apr 5, 2019

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Minor change setting a default to cspScriptSrcHashes if it is not set. Prevents bug when using CSP in SPA mode in local development

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@zoellner zoellner changed the title set default for missing cspScriptSrcHashes fix: set default for missing cspScriptSrcHashes Apr 5, 2019
@codecov-io
Copy link

codecov-io commented Apr 5, 2019

Codecov Report

Merging #5474 into dev will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #5474   +/-   ##
=======================================
  Coverage   96.13%   96.13%           
=======================================
  Files          74       74           
  Lines        2562     2562           
  Branches      652      653    +1     
=======================================
  Hits         2463     2463           
  Misses         83       83           
  Partials       16       16
Impacted Files Coverage Δ
packages/server/src/middleware/nuxt.js 97.36% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9d2deb...082a4b7. Read the comment docs.

@@ -122,7 +122,7 @@ const defaultPushAssets = (preloadFiles, shouldPush, publicPath, options) => {
return links
}

const getCspString = ({ cspScriptSrcHashes, allowedSources, policies, isDev }) => {
const getCspString = ({ cspScriptSrcHashes = [], allowedSources, policies, isDev }) => {
Copy link
Member

Choose a reason for hiding this comment

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

This function should not be called in this case at all. I'll add some change

Copy link

Choose a reason for hiding this comment

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

Wouldn't there be a case where hashes were not defined, but other CSP policies is defined?
especially when #5387 is in, a simple unsafe-inline would cause cspScriptSrcHashes to be empty

Copy link
Member

Choose a reason for hiding this comment

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

@williamchong007 we are checking cspScriptSrcHashes to be defined before calling getCspString. The default value of cspScriptSrcHashes is an empty array from renderer.js. (So still leads to calling this function)

pi0 pushed a commit that referenced this pull request Apr 7, 2019
…navailable (#5474)

Co-Authored-By: Andreas Zoellner <andreaszoellner@gmail.com>
@pi0
Copy link
Member

pi0 commented Apr 7, 2019

Fixed in 2ca08a6

@pi0 pi0 closed this Apr 7, 2019
This was referenced Apr 12, 2019
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants