-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
A content security policy is a great addition to the protections built into Kibana, but it's not effective in older browsers (like IE11) that do not enforce the policy. When CSP strict mode is enabled, right before the Kibana app is bootstrapped, a basic safety check is performed to see if "naked" inline scripts are rejected. If inline scripting is allowed by the browser, then an error message is presented to the user and Kibana never attempts to bootstrap.
- Loading branch information
Showing
6 changed files
with
118 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,70 @@ | ||
window.onload = function () { | ||
var files = [ | ||
'{{dllBundlePath}}/vendors.bundle.dll.js', | ||
'{{regularBundlePath}}/commons.bundle.js', | ||
'{{regularBundlePath}}/{{appId}}.bundle.js' | ||
]; | ||
|
||
var failure = function () { | ||
// make subsequent calls to failure() noop | ||
failure = function () {}; | ||
|
||
var err = document.createElement('h1'); | ||
err.style['color'] = 'white'; | ||
err.style['font-family'] = 'monospace'; | ||
err.style['text-align'] = 'center'; | ||
err.style['background'] = '#F44336'; | ||
err.style['padding'] = '25px'; | ||
err.innerText = document.querySelector('[data-error-message]').dataset.errorMessage; | ||
|
||
document.body.innerHTML = err.outerHTML; | ||
if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) { | ||
var legacyBrowserError = document.getElementById('kbn_legacy_browser_error'); | ||
legacyBrowserError.style.display = 'flex'; | ||
} else { | ||
if (!window.__kbnCspNotEnforced__ && window.console) { | ||
window.console.log("^ A single error about an inline script not firing due to content security policy is expected!"); | ||
} | ||
var loadingMessage = document.getElementById('kbn_loading_message'); | ||
loadingMessage.style.display = 'flex'; | ||
|
||
function loadStyleSheet(path) { | ||
var dom = document.createElement('link'); | ||
window.onload = function () { | ||
var files = [ | ||
'{{dllBundlePath}}/vendors.bundle.dll.js', | ||
'{{regularBundlePath}}/commons.bundle.js', | ||
'{{regularBundlePath}}/{{appId}}.bundle.js' | ||
]; | ||
|
||
dom.addEventListener('error', failure); | ||
dom.setAttribute('rel', 'stylesheet'); | ||
dom.setAttribute('href', path); | ||
document.head.appendChild(dom); | ||
} | ||
var failure = function () { | ||
// make subsequent calls to failure() noop | ||
failure = function () {}; | ||
|
||
function createJavascriptElement(path) { | ||
var dom = document.createElement('script'); | ||
var err = document.createElement('h1'); | ||
err.style['color'] = 'white'; | ||
err.style['font-family'] = 'monospace'; | ||
err.style['text-align'] = 'center'; | ||
err.style['background'] = '#F44336'; | ||
err.style['padding'] = '25px'; | ||
err.innerText = document.querySelector('[data-error-message]').dataset.errorMessage; | ||
|
||
dom.setAttribute('async', ''); | ||
dom.addEventListener('error', failure); | ||
dom.setAttribute('src', file); | ||
dom.addEventListener('load', next); | ||
document.head.appendChild(dom); | ||
} | ||
document.body.innerHTML = err.outerHTML; | ||
} | ||
|
||
function loadStyleSheet(path) { | ||
var dom = document.createElement('link'); | ||
|
||
dom.addEventListener('error', failure); | ||
dom.setAttribute('rel', 'stylesheet'); | ||
dom.setAttribute('href', path); | ||
document.head.appendChild(dom); | ||
} | ||
|
||
function createJavascriptElement(path) { | ||
var dom = document.createElement('script'); | ||
|
||
dom.setAttribute('async', ''); | ||
dom.addEventListener('error', failure); | ||
dom.setAttribute('src', file); | ||
dom.addEventListener('load', next); | ||
document.head.appendChild(dom); | ||
} | ||
|
||
{{#each styleSheetPaths}} | ||
loadStyleSheet('{{this}}'); | ||
{{/each}} | ||
{{#each styleSheetPaths}} | ||
loadStyleSheet('{{this}}'); | ||
{{/each}} | ||
|
||
(function next() { | ||
var file = files.shift(); | ||
if (!file) return; | ||
(function next() { | ||
var file = files.shift(); | ||
if (!file) return; | ||
|
||
var dom = document.createElement('script'); | ||
var dom = document.createElement('script'); | ||
|
||
dom.setAttribute('async', ''); | ||
dom.setAttribute('nonce', window.__webpack_nonce__); | ||
dom.addEventListener('error', failure); | ||
dom.setAttribute('src', file); | ||
dom.addEventListener('load', next); | ||
document.head.appendChild(dom); | ||
}()); | ||
}; | ||
dom.setAttribute('async', ''); | ||
dom.setAttribute('nonce', window.__webpack_nonce__); | ||
dom.addEventListener('error', failure); | ||
dom.setAttribute('src', file); | ||
dom.addEventListener('load', next); | ||
document.head.appendChild(dom); | ||
}()); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters