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

[reqtify] Extract inline script blocks and event handler in io/jenkins/plugins/ReportGenerationPipelineStep/config.jelly

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Minor Minor
    • reqtify-plugin

      Problems

      == Inline Script Block
      Line: 13
      ----
      <script>
                  var i = setInterval(function() { 
                      var isPending = document.getElementById("reports").hasClassName("select-ajax-pending");
                      if(!isPending) { clearInterval(i); showReqtifyError(); }
                  }, 1000);                    
            </script>
      ----
      
      == Inline Script Block
      Line: 23
      ----
      <script>
                  var i = setInterval(function() { 
                      var isPending = document.getElementById("templates").hasClassName("select-ajax-pending");
                      if(!isPending) { clearInterval(i); showReqtifyError(); }
                  }, 1000);                    
            </script>
      ----
      
      == Inline Script Block
      Line: 35
      ----
      <script>
               var url = window.location.pathname;
               var currentJob = url.match(new RegExp("job/(.*?)/"))[1];
               function getReportParameterValues() {
                  var e = document.getElementById("reports");
                  var functionName = e.options[e.selectedIndex].value;
                  backend.renderReportParamUI(functionName,currentJob, function(htmlList){
                      document.querySelectorAll(".report-param").forEach(el => el.remove());
                      var myJSON = JSON.stringify(htmlList);
                      var res = JSON.parse(myJSON);     
                      var paramValues = JSON.parse(res.responseJSON);
                      var tr = document.getElementById("reports").parentElement.parentElement;
                      paramValues.forEach((html) => {
                        tr.insertAdjacentHTML('afterend', html);
                      });    
                      showReqtifyError();
                  });
                }
              
                setTimeout(function() { 
                      backend.getSavedReport(currentJob, function(reportName){
                      if(reportName.responseJSON !== "") {
                          backend.renderReportParamUI(reportName.responseJSON,currentJob, function(htmlList){
                              document.querySelectorAll(".report-param").forEach(el => el.remove());
                              var myJSON = JSON.stringify(htmlList);
                              var res = JSON.parse(myJSON);     
                              var paramValues = JSON.parse(res.responseJSON);
                              var tr = document.getElementById("reports").parentElement.parentElement;
                              paramValues.forEach((html) => {
                                tr.insertAdjacentHTML('afterend', html);
                              });
                              showReqtifyError();
                          });                    
                      }
                });     
              }, 1000);
                
                function showReqtifyError() {
                  backend.getReqtifyError(function(reqtifyError){
                      if(reqtifyError === undefined || reqtifyError === null) {
                          document.getElementById('reqtifyErrorDiv').style.display = 'none';   
                      } else {
                          document.getElementById('reqtifyErrorDiv').style.display = 'block';
                          document.getElementById('reqtifyErrorSpan').innerHTML = reqtifyError.responseJSON;   
                      }            
                  });        
                }                
        </script>
      ----
      
      == Inline Event Handler
      Line: 12
      ----
      <f:select id="reports" onchange="getReportParameterValues()" />
      ----
      

      Solutions

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

            Unassigned Unassigned
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: