File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,8 +129,15 @@ func (c TemplateContext) CspScriptNonce() (ret string) {
129129
130130func (c TemplateContext ) HeadMetaContentSecurityPolicy () template.HTML {
131131 return template .HTML (`<meta http-equiv="Content-Security-Policy" content="` +
132- `default-src *` + // allow all by default (the same as old releases with no CSP)
132+ // allow all by default (the same as old releases with no CSP)
133+ // "data:" is used to load the manifest in head (maybe also need to be refactored in the future)
134+ // maybe some images are also loaded by "data:", need to investigate
135+ `default-src * data:;` +
136+
137+ // enforce nonce for all scripts, disallow inline scripts
133138 `script-src * 'nonce-` + c .CspScriptNonce () + `';` +
134- `style-src * 'unsafe-inline';` + // it seems that Vue needs it, need to investigate
139+
140+ // it seems that Vue needs the unsafe-inline, need to investigate
141+ `style-src * 'unsafe-inline';` +
135142 `">` )
136143}
Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ async function initRepoPullRequestMergeForm(box: HTMLElement) {
6969}
7070
7171function executeScripts ( elem : HTMLElement ) {
72- const scriptNonce = document . querySelector ( 'head script[nonce]' ) ! . getAttribute ( 'nonce' ) ! ;
72+ // find any existing nonce value from the current page and apply it to the new script
73+ const scriptNonce = document . querySelector ( 'script[nonce]' ) ! . getAttribute ( 'nonce' ) ! ;
7374 for ( const oldScript of elem . querySelectorAll ( 'script' ) ) {
7475 // TODO: that's the only way to load the data for the merge form. In the future
7576 // we need to completely decouple the page data and embedded script
You can’t perform that action at this time.
0 commit comments