Skip to content

MISP.HTTP.handle_response/1 raises Protocol.UndefinedError on HTTP connection #1

@NullOranje

Description

@NullOranje

If there is a connection error when connecting to MISP, the current result raises an Protocol.UndefinedError which consumes the underlying cause. For example, when connecting to a MISP server with a self-signed certificate, the following error is observed.

Interactive Elixir (1.11.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> import MISP
MISP
iex(2)> MISP.Event.get(1)
** (Protocol.UndefinedError) protocol String.Chars not implemented for {:options, {:sslv3, {:versions, [:"tlsv1.2", :"tlsv1.1", :tlsv1, :sslv3]}}} of type Tuple. This protocol is implemented for the following type(s): Float, DateTime, Time, List, Version.Requirement, Atom, Integer, Version, Date, BitString, NaiveDateTime, URI
    (elixir 1.11.2) lib/string/chars.ex:3: String.Chars.impl_for!/1
    (elixir 1.11.2) lib/string/chars.ex:22: String.Chars.to_string/1
    (mispex 0.1.8) lib/http.ex:87: MISP.HTTP.handle_response/1
    (mispex 0.1.8) lib/http.ex:31: MISP.HTTP.get/2

This can be fixed by using HTTPoison.Error.message/1 to safely wrap the error instead of reaching into the struct directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions