Search code examples
jenkinsjenkins-pipelineextentreportsextent

publish html plugin: violates the following Content Security Policy directive


Hi I'm using jenkins and i have generate report in the end of automation run, after the run the jenkins generate publish html directory to the job folder that I can see the current log report, but I got some error

ExtentScreenshot.html:1 The source list for Content Security Policy directive 'script-src' contains an invalid source: ''allow-scripts''. It will be ignored. ExtentScreenshot.html:22 Refused to load the stylesheet 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline' ".

ExtentScreenshot.html:23 Refused to load the stylesheet 'https://cdn.rawgit.com/anshooarora/extentreports/45123d736a03aca0abc5c4fcf1e746fef49736fd/cdn/extent.css' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline' ".

ExtentScreenshot.html:1 Refused to load the script 'https://cdn.rawgit.com/anshooarora/extentreports/6032d73243ba4fe4fb8769eb9c315d4fdf16fe68/cdn/extent.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'allow-scripts'".

ExtentScreenshot.html:695 Uncaught ReferenceError: $ is not defined at ExtentScreenshot.html:695 ExtentScreenshot.html:699 Uncaught ReferenceError: $ is not defined at ExtentScreenshot.html:699 ExtentScreenshot.html:1 Refused to load the stylesheet 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline' ".

ExtentScreenshot.html:1 Refused to load the stylesheet 'https://cdn.rawgit.com/anshooarora/extentreports/45123d736a03aca0abc5c4fcf1e746fef49736fd/cdn/extent.css' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline' ".

as I use in others reports in my jenkins I have to change the jenkins.xml file in the line

-Xrs -Xmx1048m -XX:MaxPermSize=512m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle "-Dhudson.model.DirectoryBrowserSupport.CSP= img-src 'self'; style-src 'self' 'unsafe-inline' ;script-src 'self' 'unsafe-inline' 'allow-scripts' " -jar "%BASE%\jenkins.war" --httpPort=2020 --webroot="%BASE%\war"--accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file="%BASE%/logs/access.log"

what should be the current configuration in jenkins to allow my view the report ?


Solution

  • You can disable CSP at all by setting Dhudson.model.DirectoryBrowserSupport.CSP= to empty string.
    See Configuring Content Security Policy, CSP directives