Skip to content

Conversation

@daniel-beck
Copy link
Member

@daniel-beck daniel-beck commented Nov 25, 2025

This allows loading admin-specified JS and CSS URLs from anywhere by allowing the specific configured URLs for the respective kind of element.

Resolves #280.

Testing done

Interactively played with it, URLs loaded, log output and header values are as expected.

A known limitation of this is is that any transitive inclusions in the specified files would not be allowed, as well as any other *-src required to work. Examples:

  • The included JS cannot do eval, that would still require 'unsafe-eval'.
  • The included CSS cannot do url(…) for a bunch of CSS directives (unless they point back to 'self' I guess).

There's always CSP plugin to allow your directives through configuration. And of course, writing a custom theme plugin is also doable. But this should take care of the folks who have fairly modest theming needs.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@daniel-beck daniel-beck changed the title Make JS URLs work with CSP Make JS and CSS URLs work with CSP Dec 5, 2025
@daniel-beck daniel-beck changed the title Make JS and CSS URLs work with CSP Make JS and CSS URLs work when Jenkins 2.539+ enforce CSP protections Dec 5, 2025
@daniel-beck daniel-beck marked this pull request as ready for review December 5, 2025 19:25
@daniel-beck daniel-beck requested a review from a team as a code owner December 5, 2025 19:25
@daniel-beck
Copy link
Member Author

Another limitation is that if the resource files are hosted in /userContent, this will not work with Resource Root URL enabled (since the URLs serving the content are on a different domain). jenkinsci/jenkins#26164 tracks this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make JsUrlThemeElement and CssUrlThemeElement work with CSP in Jenkins 2.539+

2 participants