Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-96880

Add stricter validation on connection URLs in $externalApi

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Atlas Streams
    • Sprint 61, Sprint 62

      Context

       

      We should allow users to define path, query parameters and fragments in the URL they've statically defined in the connection.

       

      We should add validations that ensure that the URL is valid and that the user does not define urlPath, or parameters in the pipeline which may override the already-defined path, query params, and fragments of the connection's url.

       

      See the BNF linked in RFC3986 for the formal definition of URL syntax.

      https://www.rfc-editor.org/rfc/rfc3986#appendix-A

      Suggested Implementation

       

      We should implement a helper that parses scheme, username, password, hostname, port, path, query and fragments from an input string.

       

      By doing this, making the necessary validations should be relatively straightforward.

       

      as a driveby, we need to make sure to encode the connection URL. See the TODO(SERVER-96880) comment.

      Desired Behavior Examples

      Example 1: conflicting paths

      connectionUrl = https://foo.com/bar?foo=bar

      operator.urlPath = "/foo/bar"

      => we should return an error

       

      Example 2: conflicting params

      connectionUrl = https://foo.com/bar#fragment

      operator.parameters = {foo: "bar"}

      => we should return an error

       

      Example 3: conflicting path

      connectionUrl = https://foo.com#fragment

      operator.urlPath = "/foo/bar"

      => we should return an error

       

      Example 4: append operator params to connection url

      connectionUrl = https://foo.com?foo=bar

      operator.parameters = {bar: "baz"}

      => we should append the parameter and make the request Url https://foo.com?foo=bar&bar=baz 

       

      Example 5: malformed url

      connectionUrl = https://foobar baz

      => we should return an error

       

            Assignee:
            andrew.chen@mongodb.com Andrew Chen
            Reporter:
            andrew.chen@mongodb.com Andrew Chen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: