nccgroup / sobelow

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

** (FunctionClauseError) no function clause matching in Sobelow.Utils.binarize_app_name/2 #48

Closed 0x234 closed 5 years ago

0x234 commented 5 years ago

Installation via mix archive.install hex sobelow

From the root of the project: mix sobelow

** (FunctionClauseError) no function clause matching in Sobelow.Utils.binarize_app_name/2

    The following arguments were given to Sobelow.Utils.binarize_app_name/2:

        # 1
        []

        # 2
        {:defmodule, [line: 1], [{:__aliases__, [line: 1], [:OMG, :Umbrella, :MixProject]}, [do: {:__block__, [], [{:use, [line: 2], [{:__aliases__, [line: 2], [:Mix, :Project]}]}, {:def, [line: 4], [{:umbrella_version, [line: 4], nil}, [do: "0.2.0"]]}, {:def, [line: 6], [{:project, [line: 6], nil}, [do: [apps_path: "apps", start_permanent: {:==, [line: 9], [{{:., [line: 9], [{:__aliases__, [line: 9], [:Mix]}, :env]}, [line: 9], []}, :prod]}, deps: {:deps, [line: 10], []}, preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.html": :test, "coveralls.circle": :test, dialyzer: :test], dialyzer: {:dialyzer, [line: 18], []}, test_coverage: [tool: {:__aliases__, [line: 19], [:ExCoveralls]}], aliases: {:aliases, [line: 20], []}, source_url: "https://github.com/omisego/elixir-omg"]]]}, {:defp, [line: 26], [{:deps, [line: 26], nil}, [do: [{:{}, [line: 28], [:distillery, "~> 2.0", [runtime: false]]}, {:{}, [line: 29], [:dialyxir, "~> 1.0.0-rc.6", [only: [:dev, :test], runtime: false]]}, {:{}, [line: 30], [:credo, "~> 1.0.5", [only: [:dev, :test], runtime: false]]}, {:{}, [line: 31], [:excoveralls, "~> 0.11.1", [only: [:test], runtime: false]]}, {:{}, [line: 32], [:licensir, "~> 0.2.0", [only: :dev, runtime: false]]}, {:ex_unit_fixtures, [git: "https://github.com/omisego/ex_unit_fixtures.git", branch: "feature/require_files_not_load", only: [:test]]}, {:{}, [line: 37], [:ex_doc, "~> 0.20.2", [only: :dev, runtime: false]]}, {:statix, "~> 1.1"}, {:appsignal, "~> 1.9"}, {:sentry, "~> 7.0"}, {:libsecp256k1, [git: "https://github.com/InoMurko/libsecp256k1.git", ref: "83d4c91b7b5ad79fdd3c020be8c57ff6e2212780", override: true]}]]]}, {:defp, [line: 48], [{:aliases, [line: 48], nil}, [do: [test: ["test --no-start"], coveralls: ["coveralls --no-start"], "coveralls.html": ["coveralls.html --no-start"], "coveralls.detail": ["coveralls.detail --no-start"], "coveralls.post": ["coveralls.post --no-start"], "ecto.setup": ["ecto.create", "ecto.migrate", "run apps/omg_watcher/priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"]]]]}, {:defp, [line: 60], [{:dialyzer, [line: 60], nil}, [do: [flags: [:specdiffs, :error_handling, :race_conditions, :underspecs, :unknown, :unmatched_returns], ignore_warnings: "dialyzer.ignore-warnings", list_unused_filters: true, plt_add_apps: {:plt_apps, [line: 65], []}]]]}, {:defp, [line: 69], [{:plt_apps, [line: 69], nil}, [do: [:briefly, :cowboy, :distillery, :ex_unit, :exexec, :fake_server, :iex, :jason, :mix, :plug, :propcheck, :proper, :ranch, :sentry, :vmstats, :statix]]]}]}]]}

    Attempted function clauses (showing 3 out of 3):

        defp binarize_app_name(app_name, _) when is_binary(app_name)
        defp binarize_app_name(app_name, _) when is_atom(app_name)
        defp binarize_app_name({:@, _, [{module_attribute, _, _}]}, ast)

    lib/sobelow/utils.ex:70: Sobelow.Utils.binarize_app_name/2
    lib/sobelow.ex:31: Sobelow.run/0
    (mix) lib/mix/task.ex:316: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2
GriffinMB commented 5 years ago

Hey @jbunce, thanks for opening this issue! The problem here is that you are attempting to scan an umbrella application as a whole. For now, you'll need to scan each Phoenix application individually. Something like mix sobelow -r apps/APP_NAME.

That said, Sobelow shouldn't be throwing such an unhelpful error message. I've pushed an update to master that will appropriately advise users on how to proceed! If you want to try out the master branch, you can install with mix archive.install github nccgroup/sobelow.

Thanks again for opening this issue!