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

[bmc-rpd] Extract inline script blocks and event handler in com/bmc/rpd/jenkins/plugin/bmcrpd/configuration/RPDPluginConfiguration/config.jelly

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Minor Minor
    • bmc-rpd-plugin

      Problems

      == Inline Script Block
      Line: 3
      ----
      <script type='text/javascript'>
              function deselectCheckbox(el){
                  for (i = 0; i &lt; document.getElementsByName("rpd.defaultProfile").length; i++) {
                      document.getElementsByName("rpd.defaultProfile")[i].checked=false;
                  }
                  el.checked=true;
              }
          </script>
      ----
      
      == Inline Script Block
      Line: 37
      ----
      <script type='text/javascript'>
                      setInterval(function(){
                              var fields = [];
                              YAHOO.util.Dom.getElementsByClassName('rpd-config-field', "input").forEach(function(e){
                                  var trouble = false;
                                  if(e.value == null || e.value == ''){
                                          e.targetElement = findFollowingTR(e, "validation-error-area").firstChild.nextSibling;
                                          e.targetElement.innerHTML = "&lt;div class=error&gt; Field cannot be empty &lt;/div&gt;";
                                          trouble = true;
                                  }
                                  else{
                                      if(e.name == "rpd.serverProfileName" ){
                                          if((fields.indexOf(e.value) >= 0 || fields.indexOf(e.defaultValue) >= 0)){
                                              e.targetElement = findFollowingTR(e, "validation-error-area").firstChild.nextSibling;
                                              e.targetElement.innerHTML = "&lt;div class=error&gt; Duplicates are not allowed &lt;/div&gt;";
                                              trouble = true;
                                          }
                                      }
                                  }
                                  if(!trouble){
                                      e.targetElement = findFollowingTR(e, "validation-error-area").firstChild.nextSibling.innerHTML = '';
                                  }
                                  fields.push(e.value);
                              });
                      }, 2000);
                  </script>
      ----
      
      == Inline Event Handler
      Line: 16
      ----
      <f:checkbox name="rpd.defaultProfile"  value="${serverProfile.defaultProfile}" checked="${serverProfile.isDefaultProfile()}" onclick="deselectCheckbox(this)"/>
      ----
      

      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: