BackstopJS icon indicating copy to clipboard operation
BackstopJS copied to clipboard

Jenkins "HTML report" page is blank

Open janmashat opened this issue 5 years ago • 5 comments

Following the "Publish HTML reports" instructions detailed here: https://github.com/garris/BackstopJS/tree/master/examples/Jenkins

The resulting page in Jenkins is empty: Screenshot 2020-04-03 at 11 24 30

I'm assuming this is due to the javascript in the BackstopJS page conflicting with the built-in Jenkins javascript, or other script execution being blocked.

janmashat avatar Apr 03 '20 10:04 janmashat

It's because of CORS issues (because the backstop report uses inline styles) which are prohibited on your jenkins. I have the same problem.

hubidu avatar May 08 '20 14:05 hubidu

This can help:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

More information: https://stackoverflow.com/a/46197356/11217161 https://www.jenkins.io/doc/book/security/configuring-content-security-policy/

websolutions-hamburg avatar Jun 11 '22 18:06 websolutions-hamburg

That is not really a good solution to clear the CSP. Why not fix the generated report to move the inline styles to a css file + load that and put the inline JavaScript to a js file and load that too, that way it should be CSP compatible if at least 'self' is set?

tkrah avatar Jan 15 '24 13:01 tkrah

This is all CSP — no CORS issues.

tl;dr — this came up for me the other day, and I'm working out a solution (and pull-request).

I think the quick fix is to relax headers coming from Jenkins for frame-src, script-src, and style-src. Or remove them entirely and set them via <meta http-equiv> tag in the (customized) report.

The long-term solution requires some refactoring of the BackstopJS reporting application. nonce, hash, and moving everything to a custom loader are all possibilities.

I had a feeling this would come up at some point. Wow — CSP is 20 years old?

Another issue a lot of folks will begin running into — injected CSS/JS via onBeforeScript and onReadyScript on a server/page with strong "'self'" policies will fail. Migrating any application or site to more secure CSP will break once-working BackstopJS tests.

@tkrah thanks for reviving this issue.

If anyone comes across this and has use-cases to share, please do.

dgrebb avatar Jan 15 '24 18:01 dgrebb

FWIW — there's some good history in this thread: Page with CSP breaks puppeteer

dgrebb avatar Jan 15 '24 18:01 dgrebb