nccgroup / sobelow

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

(FunctionClauseError) no function clause matching in List.last/1 #79

Closed marlies90 closed 3 years ago

marlies90 commented 3 years ago

I'm trying to run mix sobelow but it always returns (FunctionClauseError) no function clause matching in List.last/1.

The following arguments were given to List.last/1:

    # 1
    nil

Attempted function clauses (showing 3 out of 3):

    def last([])
    def last([head])
    def last([_ | tail])

(elixir 1.10.3) lib/list.ex:294: List.last/1
lib/sobelow/config.ex:148: Sobelow.Config.extract_configs/3
(elixir 1.10.3) lib/macro.ex:430: anonymous fn/4 in Macro.do_traverse_args/4
(elixir 1.10.3) lib/enum.ex:1520: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir 1.10.3) lib/macro.ex:396: Macro.do_traverse/4
(elixir 1.10.3) lib/enum.ex:1520: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir 1.10.3) lib/macro.ex:396: Macro.do_traverse/4
(elixir 1.10.3) lib/enum.ex:1520: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3

I've installed the latest version by including it in the deps and am running phoenix 1.5.6. It's failing on my machine and in our gitlab pipeline.

Let me know if any more info is needed, I'd love to hear from you!

GriffinMB commented 3 years ago

Thanks for opening this issue, I should be able to push a fix tonight!

GriffinMB commented 3 years ago

I've pushed a fix for this! It looks like you've got an empty config somewhere that was throwing off Sobelow's parser. I've added a test case for it here: https://github.com/nccgroup/sobelow/blob/master/test/fixtures/utils/nil_config.exs

Please give this a try, and let me know if it solves your issue. You can install it from github with mix archive.install github nccgroup/sobelow. Once you confirm the fix, I will publish this to hex.

Thanks again! Griffin

marlies90 commented 3 years ago

So fast! I tried it out and now it is working indeed, thank you so much! 🎉

GriffinMB commented 3 years ago

This is now live on hex with version 0.10.6. Thanks again for opening this issue!