File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // This module overrides "Hogan" that instantsearch.js uses
2+ // Hogan uses `new Function`,
3+ // so we can't use it with our content security policy.
4+ // Turns out, we use all our own templates anyway,
5+ // so we just have to shim out Hogan so it doesn't error!
6+
7+ export default {
8+ compile ( template ) {
9+ return {
10+ render ( data ) {
11+ return ''
12+ }
13+ }
14+ }
15+ }
Original file line number Diff line number Diff line change @@ -30,9 +30,7 @@ module.exports = contentSecurityPolicy({
3030 ] ,
3131 scriptSrc : [
3232 "'self'" ,
33- 'data:' ,
34- "'unsafe-eval'" , // exception for Algolia instantsearch
35- "'unsafe-inline'"
33+ 'data:'
3634 ] ,
3735 frameSrc : [ // exceptions for GraphQL Explorer
3836 'https://graphql-explorer.githubapp.com' , // production env
Original file line number Diff line number Diff line change @@ -53,8 +53,6 @@ describe('server', () => {
5353 expect ( csp . get ( 'img-src' ) . includes ( 'octodex.github.com' ) ) . toBe ( true )
5454
5555 expect ( csp . get ( 'script-src' ) . includes ( "'self'" ) ) . toBe ( true )
56- expect ( csp . get ( 'script-src' ) . includes ( "'unsafe-eval'" ) ) . toBe ( true ) // exception for Algolia instantsearch
57- expect ( csp . get ( 'script-src' ) . includes ( "'unsafe-inline'" ) ) . toBe ( true )
5856
5957 expect ( csp . get ( 'style-src' ) . includes ( "'self'" ) ) . toBe ( true )
6058 expect ( csp . get ( 'style-src' ) . includes ( "'unsafe-inline'" ) ) . toBe ( true )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
44const { EnvironmentPlugin } = require ( 'webpack' )
55
66module . exports = {
7+ devtool : 'source-map' , // this prevents webpack from using eval
78 entry : './javascripts/index.js' ,
89 output : {
910 filename : 'index.js' ,
@@ -70,5 +71,12 @@ module.exports = {
7071 ]
7172 } ) ,
7273 new EnvironmentPlugin ( [ 'NODE_ENV' ] )
73- ]
74+ ] ,
75+ resolve : {
76+ alias : {
77+ // Hogan uses `new Function` which breaks content security policy
78+ // Turns out, we aren't even using it anyways!
79+ 'hogan.js' : path . resolve ( __dirname , 'javascripts/fake-hogan.js' )
80+ }
81+ }
7482}
You can’t perform that action at this time.
0 commit comments