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

The installNecessaryPlugins REST API needs to return HTTP 400 when plugin name is wrong

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None
    • Jenkins 2.176.2

      This is an Improvement ticket to address the following problem:

      When the plugin name is wrong, the installNecessaryPlugin REST API silently accepts it.

      CRUMB=$(curl $JENKINS_REST_ENDPOINT/crumbIssuer/api/xml?xpath=concat\(//crumbRequestField,%22:%22,//crumb\))
      
      curl -v -L -X POST \
          -d "<jenkins><install plugin=\"extended-read-permission@1.0\" /></jenkins>" \
          -H "Content-Type: text/xml" \
          -H "$CRUMB" \
          "http://localhost:8080/pluginManager/installNecessaryPlugins"

      This returns:

       > POST /pluginManager/installNecessaryPlugins HTTP/1.1
      > Host: localhost:8080
      > User-Agent: curl/7.47.0
      > Accept: */*
      > Content-Type: text/xml
      > Jenkins-Crumb:cfeaec07a1a12decfd5ceff525cd8b01
      > Content-Length: 69
      >
      * upload completely sent off: 69 out of 69 bytes
      < HTTP/1.1 302 Found
      < Date: Sun, 21 Jul 2019 12:53:56 GMT
      < X-Content-Type-Options: nosniff
      < Location: http://localhost:8080/updateCenter
      < Content-Length: 0
      < Server: Jetty(9.4.z-SNAPSHOT)
      <
      * Connection #0 to host localhost left intact
      * Issue another request to this URL: 'http://localhost:8080/updateCenter'
      * Switch from POST to GET
      * Found bundle for host localhost: 0x56026f0db330 [can pipeline]
      * Re-using existing connection! (#0) with host localhost
      * Connected to localhost (127.0.0.1) port 8080 (#0)
      > POST /updateCenter HTTP/1.1
      > Host: localhost:8080
      > User-Agent: curl/7.47.0
      > Accept: */*
      > Content-Type: text/xml
      > Jenkins-Crumb:cfeaec07a1a12decfd5ceff525cd8b01
      >
      < HTTP/1.1 302 Found
      < Date: Sun, 21 Jul 2019 12:53:56 GMT
      < X-Content-Type-Options: nosniff
      < Location: http://localhost:8080/updateCenter/
      < Content-Length: 0
      < Server: Jetty(9.4.z-SNAPSHOT)
      <
      * Connection #0 to host localhost left intact
      * Issue another request to this URL: 'http://localhost:8080/updateCenter/'
      * Found bundle for host localhost: 0x56026f0db330 [can pipeline]
      * Re-using existing connection! (#0) with host localhost
      * Connected to localhost (127.0.0.1) port 8080 (#0)
      > POST /updateCenter/ HTTP/1.1
      > Host: localhost:8080
      > User-Agent: curl/7.47.0
      > Accept: */*
      > Content-Type: text/xml
      > Jenkins-Crumb:cfeaec07a1a12decfd5ceff525cd8b01
      >
      < HTTP/1.1 200 OK
      < Date: Sun, 21 Jul 2019 12:53:56 GMT
      < X-Content-Type-Options: nosniff
      < Content-Type: text/html;charset=utf-8
      < Expires: Thu, 01 Jan 1970 00:00:00 GMT
      < Cache-Control: no-cache,no-store,must-revalidate
      < X-Hudson-Theme: default
      < Referrer-Policy: same-origin
      < Set-Cookie: JSESSIONID.7b3dc8aa=node01vbzel0qvprdl90tcyx4l56f66.node0;Path=/;HttpOnly
      < X-Hudson: 1.395
      < X-Jenkins: 2.176.2
      < X-Jenkins-Session: 8868fc82
      < X-Hudson-CLI-Port: 36861
      < X-Jenkins-CLI-Port: 36861
      < X-Jenkins-CLI2-Port: 36861
      < X-Frame-Options: sameorigin
      < X-Instance-Identity: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqB7RCj4V0Ify29GRMl0wCp7Lj7FLz0QJ8am1DKx3li0ohcKDc4zIVn7bHtxC4OOa+hwaoY2yCNMXlbWelPuhQjhXZO2pSnBX3IacxQU/Q8fvHmYJ/H0p+Wn7ALj7PvWFG/exRBPYVBnn7vXmwViaUbk9P5r+hPz7NRON5l2A6A8OHBiTxcgMxNT+mh5h++JTmM0dwNTkOyoEev8UFAhsVObJPYKdfcLaMs6d8VYVc/meVNxRmlXVAutJKKpMye+YnxgImeU0uMqo45OXmzpjlQsPL/6GG3Z/24/BkqXo6Lqhq3hVYCj1rgo+oOhEAiqoqAgxpUDCJe/6Jx4392GxdwIDAQAB
      < Content-Length: 12343
      < Server: Jetty(9.4.z-SNAPSHOT)
      

      But in the log we see:

      WARNING: No such plugin extended-read-permissions to install
      

      The REST API should return a HTTP code indicating an error. Otherwise, the REST API silently ignores errors and it cannot be automated.

            Unassigned Unassigned
            deepchip Martin d'Anjou
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: