Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-74233

[JiraTestResultReporter] Extract inline script block and event handlers in org/jenkinsci/plugins/JiraTestResultReporter/JiraTestDataPublisher/config.jelly

XMLWordPrintable

    • 243.v742d96717a_5e

      Problems

      == Inline Script Block
      Line: 70
      ----
      <script>
              /*
              Ugly hack part 1. See JiraTestDataPublisherDescriptor.validateFieldConfigs for part2.
              Since Jenkins does not offer a way to send the hetero-list for validation, I'm constructing
              the whole form and sending it.
              */
              function validateFieldConfings() {
                  var errorDiv = document.getElementById('JiraIssueConfigErrors');
                  spinner = document.getElementById('jiraSpinner');
                  spinner.style.display = "inline"
                  var form = document.getElementsByName("config")[0];
                  buildFormTree(form);
                  var jsonElement = null;
                  for( var i=0; i != form.elements.length; i++ ) {
                      var e = form.elements[i];
                      if(e.name == "json") {
                          jsonElement = e;
                          break;
                      }
                  }
      
                  var descriptor = <st:bind value="${descriptor}"/>
                  var socketTimeout = setTimeout( function() {
                      spinner.style.display = "none"
                      errorDiv.innerHTML = "Validation Failed: Socket Timeout. The issue was probably created, but the server did not respond in a timely manner. Please try again.";
                      }, 30000);
                  descriptor.validateFieldConfigs(jsonElement.value, function(rsp) {
                      clearTimeout(socketTimeout);
                      spinner.style.display = "none"
                      applyErrorMessage(errorDiv, rsp);
                  });
              }
      
      
              function hideshow(which){
                  if (!document.getElementById)
                      return
                  if (which.style.display=="block")
                      which.style.display="none"
                  else
                      which.style.display="block"
              }
      
          </script>
      ----
      
      == Inline Event Handler
      Line: 42
      ----
      <button id="validateJiraIssueConfig" type="button" onClick="validateFieldConfings()">
      ----
      
      == Inline Event Handler
      Line: 44
      ----
      <l:icon class="icon-help icon-sm" style="cursor:pointer" onclick="hideshow(document.getElementById('helpValidateJiraIssueConfig'))"/>
      ----
      

      Solutions

      https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks
      https://www.jenkins.io/doc/developer/security/csp/#inline-event-handlers

            yafenkin Yaroslav Afenkin
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: