-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: global-yaml-properties-plugin
Problem
== Inline Script Block
Line: 11
----
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var configForm = document.forms['config']; // This usually targets the job configuration form in Jenkins
var checkbox = document.querySelector('#enableReadOnly');
checkbox.addEventListener('change', function() {
var textarea = document.querySelector('textarea[name="yamlConfiguration"]');
var cm = textarea.nextSibling.CodeMirror;
var isReadOnly = cm.getOption('readOnly');
cm.setOption('readOnly', !isReadOnly);
});
if (configForm) {
configForm.addEventListener('submit', function(event) {
var errorDivs = document.querySelectorAll('div.error');
var hasVisibleErrors = Array.from(errorDivs).some(function(div) {
return div.textContent.trim().toLowerCase().includes("config");
});
if (hasVisibleErrors) {
event.preventDefault();
alert('Form validation failed. Please correct the errors and try again.');
}
});
}
});
</script>
----
Solution
https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks