Skip to content

HttpClient: a route's x-method_name can overwrite the client's own attributes #23

Closed

Description

@thorwhalen

Found by the adversarial review of #22, and also present before it.

HttpClient.register_method does setattr(self, func.__name__, ...) with a name taken from the spec (x-method_name). A spec, possibly fetched from a server, can therefore name a route openapi_spec, binary_loads, session, handle_request or ensure_login and replace that attribute of the client. For example, a route named openapi_spec makes api_pkg_files crash with 'function' object has no attribute 'get'.

Suggested fix: refuse, or prefix, route names that collide with HttpClient attributes or start with _. Better still, keep the routes in a separate namespace (e.g. client.routes), with attribute access kept as sugar for names that do not collide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions