nccgroup / sobelow

Security-focused static analysis for the Phoenix Framework
Apache License 2.0
1.67k stars 92 forks source link

Protocol.UndefinedError with format json #64

Closed lleger closed 4 years ago

lleger commented 4 years ago

When running Sobelow in a Phoenix 1.5 umbrella app, I ran into the following error:

$ mix sobelow --root apps/myapp_web --format json
** (Protocol.UndefinedError) protocol String.Chars not implemented for {:., [line: 5], [{:socket, [line: 5], nil}, :assigns]} of type Tuple
    (elixir 1.10.2) lib/string/chars.ex:3: String.Chars.impl_for!/1
    (elixir 1.10.2) lib/string/chars.ex:22: String.Chars.to_string/1
    lib/sobelow/finding_log.ex:58: anonymous fn/2 in Sobelow.FindingLog.format_json/2
    (elixir 1.10.2) lib/enum.ex:1400: anonymous fn/3 in Enum.map/2
    (stdlib 3.12.1) maps.erl:232: :maps.fold_1/3
    (elixir 1.10.2) lib/enum.ex:2127: Enum.map/2
    lib/sobelow/finding_log.ex:58: Sobelow.FindingLog.format_json/2
    (elixir 1.10.2) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2

This was in a LiveView module, so that may be related.

GriffinMB commented 4 years ago

To clarify: This is an issue with the JSON output option specifically, correct?

lleger commented 4 years ago

@GriffinMB Correct. When not passing the format option it runs fine.

GriffinMB commented 4 years ago

Great, thank you! I’ll have a fix released on Hex in the next few days.

GriffinMB commented 4 years ago

I've pushed an update to master that should address this issue! Try it out and let me know if it fixes your problem, and I will publish the update.

Thanks!

lleger commented 4 years ago

@GriffinMB Confirmed that that works! Thanks. 💜

GriffinMB commented 4 years ago

This is live! Thanks again for creating the issue :)