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

[build-requester] Extract inline script blocks and event handlers in com/redhat/jenkins/plugins/buildrequester/BuildRequesterAction/index.jelly

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Minor Minor
    • _unsorted

      Problems

      == Inline Script Block
      Line: 9
      ----
      <script type="text/javascript">
                      function scmRevisionSelectChange(elem) {
                          var selectedText = elem.options[elem.selectedIndex].innerText;
                          var otherInput = document.getElementById('scmRevision-other');
      
                          if (selectedText == "Other:") {
                              otherInput.style.display = "";
                          } else {
                              otherInput.style.display = "none";
                          }
                      }
      
                      function otherScmRevisionValue(elem) {
                          var select = document.getElementById('scmRevision-other-select');
                          var otherOption = select.options[select.selectedIndex];
                          otherOption.value = elem.value;
                      }
                  </script>
      ----
      
      == Inline Script Block
      Line: 28
      ----
      <script type="text/javascript">
                      var keycloak = Keycloak("keycloakSettings");
                      keycloak.init({ onLoad: 'login-required' })
                          .success(function (authenticated) {
                              console.log('Login Successful');
                              document.getElementById('oauth-input').value = keycloak.token;
                              document.getElementById('error-login').remove();
                          }).error(function () {
                              console.log('Login Failed');
                              window.location = "fail?message=Keycloak Login Failed to Initialize";
                          });
                  </script>
      ----
      
      == Inline Event Handler
      Line: 61
      ----
      <select id="scmRevision-other-select" class="setting-input" name="scmRevision" onchange="scmRevisionSelectChange(this)">
      ----
      
      == Inline Event Handler
      Line: 67
      ----
      <input id="scmRevision-other" class="setting-input" type="text" value="" onchange="otherScmRevisionValue(this)"
                                     style="display: none; margin-top: 10px;"/>
      ----
      

      Solutions

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

          [JENKINS-74705] [build-requester] Extract inline script blocks and event handlers in com/redhat/jenkins/plugins/buildrequester/BuildRequesterAction/index.jelly

          Basil Crow created issue -
          Basil Crow made changes -
          Description Original: h4. Problems

          {noformat}
          == Inline Event Handler
          Line: 61
          ----
          <select id="scmRevision-other-select" class="setting-input" name="scmRevision" onchange="scmRevisionSelectChange(this)">
          ----

          == Inline Event Handler
          Line: 67
          ----
          <input id="scmRevision-other" class="setting-input" type="text" value="" onchange="otherScmRevisionValue(this)"
                                         style="display: none; margin-top: 10px;"/>
          ----

          == Inline Script Block
          Line: 9
          ----
          <script type="text/javascript">
                          function scmRevisionSelectChange(elem) {
                              var selectedText = elem.options[elem.selectedIndex].innerText;
                              var otherInput = document.getElementById('scmRevision-other');

                              if (selectedText == "Other:") {
                                  otherInput.style.display = "";
                              } else {
                                  otherInput.style.display = "none";
                              }
                          }

                          function otherScmRevisionValue(elem) {
                              var select = document.getElementById('scmRevision-other-select');
                              var otherOption = select.options[select.selectedIndex];
                              otherOption.value = elem.value;
                          }
                      </script>
          ----

          == Inline Script Block
          Line: 28
          ----
          <script type="text/javascript">
                          var keycloak = Keycloak("keycloakSettings");
                          keycloak.init({ onLoad: 'login-required' })
                              .success(function (authenticated) {
                                  console.log('Login Successful');
                                  document.getElementById('oauth-input').value = keycloak.token;
                                  document.getElementById('error-login').remove();
                              }).error(function () {
                                  console.log('Login Failed');
                                  window.location = "fail?message=Keycloak Login Failed to Initialize";
                              });
                      </script>
          ----

          == Inline Event Handler
          Line: 61
          ----
          <select id="scmRevision-other-select" class="setting-input" name="scmRevision" onchange="scmRevisionSelectChange(this)">
          ----

          == Inline Event Handler
          Line: 67
          ----
          <input id="scmRevision-other" class="setting-input" type="text" value="" onchange="otherScmRevisionValue(this)"
                                         style="display: none; margin-top: 10px;"/>
          ----

          == Inline Script Block
          Line: 9
          ----
          <script type="text/javascript">
                          function scmRevisionSelectChange(elem) {
                              var selectedText = elem.options[elem.selectedIndex].innerText;
                              var otherInput = document.getElementById('scmRevision-other');

                              if (selectedText == "Other:") {
                                  otherInput.style.display = "";
                              } else {
                                  otherInput.style.display = "none";
                              }
                          }

                          function otherScmRevisionValue(elem) {
                              var select = document.getElementById('scmRevision-other-select');
                              var otherOption = select.options[select.selectedIndex];
                              otherOption.value = elem.value;
                          }
                      </script>
          ----

          == Inline Script Block
          Line: 28
          ----
          <script type="text/javascript">
                          var keycloak = Keycloak("keycloakSettings");
                          keycloak.init({ onLoad: 'login-required' })
                              .success(function (authenticated) {
                                  console.log('Login Successful');
                                  document.getElementById('oauth-input').value = keycloak.token;
                                  document.getElementById('error-login').remove();
                              }).error(function () {
                                  console.log('Login Failed');
                                  window.location = "fail?message=Keycloak Login Failed to Initialize";
                              });
                      </script>
          ----
          {noformat}

          h4. Solutions

          [https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks]
          [https://www.jenkins.io/doc/developer/security/csp/#inline-event-handlers]
          New: h4. Problems

          {noformat}
          == Inline Script Block
          Line: 9
          ----
          <script type="text/javascript">
                          function scmRevisionSelectChange(elem) {
                              var selectedText = elem.options[elem.selectedIndex].innerText;
                              var otherInput = document.getElementById('scmRevision-other');

                              if (selectedText == "Other:") {
                                  otherInput.style.display = "";
                              } else {
                                  otherInput.style.display = "none";
                              }
                          }

                          function otherScmRevisionValue(elem) {
                              var select = document.getElementById('scmRevision-other-select');
                              var otherOption = select.options[select.selectedIndex];
                              otherOption.value = elem.value;
                          }
                      </script>
          ----

          == Inline Script Block
          Line: 28
          ----
          <script type="text/javascript">
                          var keycloak = Keycloak("keycloakSettings");
                          keycloak.init({ onLoad: 'login-required' })
                              .success(function (authenticated) {
                                  console.log('Login Successful');
                                  document.getElementById('oauth-input').value = keycloak.token;
                                  document.getElementById('error-login').remove();
                              }).error(function () {
                                  console.log('Login Failed');
                                  window.location = "fail?message=Keycloak Login Failed to Initialize";
                              });
                      </script>
          ----

          == Inline Event Handler
          Line: 61
          ----
          <select id="scmRevision-other-select" class="setting-input" name="scmRevision" onchange="scmRevisionSelectChange(this)">
          ----

          == Inline Event Handler
          Line: 67
          ----
          <input id="scmRevision-other" class="setting-input" type="text" value="" onchange="otherScmRevisionValue(this)"
                                         style="display: none; margin-top: 10px;"/>
          ----
          {noformat}

          h4. 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: