-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Add CSP-compliant variant of undocumented validateButton script feature #20345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CSP-compliant variant of undocumented validateButton script feature #20345
Conversation
timja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be better for this to be removed, but if it works good for now
|
/label ready-for-merge This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback. Thanks! |
|
(linked #18688 to close on merge) |
FWIW I've changed both plugins' PRs to not use either iteration of this feature. This way no new Jenkins core dependency is required for them either. So the only remaining known use of this feature would be in core. |
…re (jenkinsci#20345) * Add CSP-compliant variant of undocumented validateButton script feature * Prettier / eslint * Use Function.prototype.apply() as hopefulle HTMLUnit compatible alternative --------- Co-authored-by: Daniel Beck <[email protected]>
Fixes #18688
With CSP protection enabled (https://plugins.jenkins.io/csp/ or #11269), so that
script-srcdoes not allow'unsafe-inline', it is not possible to regenerate a legacy API token. In new instances, this token has been disabled by default for many years.The reason is a seemingly undocumented feature of
f:validateButton: If you provide an inline script in thescriptHTTP response header to the validationmethod, that script is executed:jenkins/war/src/main/webapp/scripts/hudson-behavior.js
Lines 2639 to 2644 in 110014c
There seem to be just two plugins (
gitlab-pluginandgitee) and this core functionality using this feature.This PR adds a new, equally undocumented feature: Set the
X-Jenkins-ValidateButton-CallbackHTTP response header to a JSON object with the Stringcallbackand the listargumentsto have a global function of that name be invoked with those arguments.Testing done
Manually generated a token while CSP plugin was installed and "Report Only" was unchecked, it worked as if there was no CSP enforcement.
Proposed changelog entries
X-Jenkins-ValidateButton-Callback(a JSON object withcallbackandargumentskeys) as a replacement for the CSP-incompatiblescriptHTTP response header forf:validateButton.Proposed changelog category
/label
Proposed upgrade guidelines
N/A
Submitter checklist
@Restrictedor have@since TODOJavadocs, as appropriate.@Deprecated(since = "TODO")or@Deprecated(forRemoval = true, since = "TODO"), if applicable.evalto ease future introduction of Content Security Policy (CSP) directives (see documentation).Desired reviewers
@mention
Before the changes are marked as
ready-for-merge:Maintainer checklist
upgrade-guide-neededlabel is set and there is a Proposed upgrade guidelines section in the pull request title (see example).lts-candidateto be considered (see query).