smpallen99 / ex_admin

ExAdmin is an auto administration package for Elixir and the Phoenix Framework
MIT License
1.2k stars 276 forks source link

resource creation argument error #454

Closed DylanAndrews closed 5 years ago

DylanAndrews commented 5 years ago

Versions

Issue I have followed all of the setup steps and successfully gotten to a place where I can see the options to list/add/edit/and delete my created resource, but when I click create I see the following error on the server.

[error] #PID<0.436.0> running Blog.Endpoint (cowboy_protocol) terminated
Server: localhost:4000 (http)
Request: GET /admin/posts/new
** (exit) an exception was raised:
    ** (ArgumentError) argument error
        :erlang.bit_size(:safe)
        (ex_admin) lib/ex_admin/themes/admin_lte2/form.ex:179: anonymous fn/2 in ExAdmin.Theme.AdminLte2.Form.form_box/3
        (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
        (ex_admin) lib/ex_admin/themes/admin_lte2/form.ex:176: ExAdmin.Theme.AdminLte2.Form.form_box/3
        (ex_admin) lib/ex_admin/form.ex:587: anonymous fn/6 in ExAdmin.Form.build_main_block/4
        (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
        (ex_admin) lib/ex_admin/form.ex:585: ExAdmin.Form.build_main_block/4
        (ex_admin) lib/ex_admin/themes/admin_lte2/form.ex:31: ExAdmin.Theme.AdminLte2.Form.build_form/6
        (ex_admin) web/controllers/admin_resource_controller.ex:70: ExAdmin.AdminResourceController.new/3
        (ex_admin) web/controllers/admin_resource_controller.ex:1: ExAdmin.AdminResourceController.action/2
        (ex_admin) web/controllers/admin_resource_controller.ex:1: ExAdmin.AdminResourceController.phoenix_controller_pipeline/2
        (blog) lib/blog/endpoint.ex:1: Blog.Endpoint.instrument/4
        (phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
        (blog) lib/blog/endpoint.ex:1: Blog.Endpoint.plug_builder_call/2
        (blog) lib/plug/debugger.ex:122: Blog.Endpoint."call (overridable 3)"/2
        (blog) lib/blog/endpoint.ex:1: Blog.Endpoint.call/2
        (plug_cowboy) lib/plug/cowboy/handler.ex:18: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /Users/DylanAndrews/Documents/personal_dev_projects/phoenix-personal-blog/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

The error looks like this in the browser.

screen shot 2018-10-28 at 11 19 12 am

I have redone the setup a few times to make sure I have done everything that is needed. Any help would be most appreciated. Thanks.

happysalada commented 5 years ago

check your dependencies. If I'm not wrong, do you have xain dep set to 0.6.2 ? 0.6.1 has been retired for security reasons, but upgrading breaks everything.

DylanAndrews commented 5 years ago

@happysalada Thanks so much for the quick response! xain dep looks like 0.6.2. "xain": {:hex, :xain, "0.6.2", "c43e3f30dc500ee4ed1146e1d6ec2440652d8e7b076f23dd5599fc251b0d84b2", [:mix], [{:phoenix_html, "~> 2.12", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm"},

Here is the whole mix.lock file in case it helps.

%{
  "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [], [], "hexpm"},
  "cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
  "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [], [], "hexpm"},
  "csvlixir": {:hex, :csvlixir, "1.0.0", "e9fd30abfca2d312390060e86bb7ec52487c813824dcccad45bb13e85ecad6b1", [:mix], [], "hexpm"},
  "db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
  "decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [], [], "hexpm"},
  "ecto": {:hex, :ecto, "2.2.11", "4bb8f11718b72ba97a2696f65d247a379e739a0ecabf6a13ad1face79844791c", [], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
  "ex_admin": {:git, "https://github.com/smpallen99/ex_admin.git", "2048340de6600ca11cd6a8ffbfb8bc30f786144b", []},
  "ex_queb": {:hex, :ex_queb, "1.0.1", "833f773179fb8971b1a58b67874209f50d087024ca0771e8f9a283c9214ec4b9", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}], "hexpm"},
  "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm"},
  "file_system": {:hex, :file_system, "0.2.6", "fd4dc3af89b9ab1dc8ccbcc214a0e60c41f34be251d9307920748a14bf41f1d3", [], [], "hexpm"},
  "gettext": {:hex, :gettext, "0.16.0", "4a7e90408cef5f1bf57c5a39e2db8c372a906031cc9b1466e963101cb927dafc", [], [], "hexpm"},
  "inflex": {:hex, :inflex, "1.10.0", "8366a7696e70e1813aca102e61274addf85d99f4a072b2f9c7984054ea1b9d29", [:mix], [], "hexpm"},
  "mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [], [], "hexpm"},
  "phoenix": {:hex, :phoenix, "1.3.4", "aaa1b55e5523083a877bcbe9886d9ee180bf2c8754905323493c2ac325903dc5", [], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
  "phoenix_ecto": {:hex, :phoenix_ecto, "3.5.0", "f72ec302589988698c096da7e8647e917fa2bb2f861c0c3739fc9d95708bacec", [], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
  "phoenix_html": {:hex, :phoenix_html, "2.12.0", "1fb3c2e48b4b66d75564d8d63df6d53655469216d6b553e7e14ced2b46f97622", [], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
  "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.1.7", "425fff579085f7eacaf009e71940be07338c8d8b78d16e307c50c7d82a381497", [], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2 or ~> 1.3 or ~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"},
  "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [], [], "hexpm"},
  "plug": {:hex, :plug, "1.7.0", "cd8c8de89bd9de55eba1c918bf0e7f319737e109b6014875104af025a623e16e", [], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
  "plug_cowboy": {:hex, :plug_cowboy, "1.0.0", "2e2a7d3409746d335f451218b8bb0858301c3de6d668c3052716c909936eb57a", [], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
  "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [], [], "hexpm"},
  "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [], [], "hexpm"},
  "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [], [], "hexpm"},
  "postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"},
  "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [], [], "hexpm"},
  "scrivener": {:hex, :scrivener, "2.5.0", "e1f78c62b6806d91cc9c4778deef1ea4e80aa9fadfce2c16831afe0468cc8a2c", [:mix], [], "hexpm"},
  "scrivener_ecto": {:hex, :scrivener_ecto, "1.3.0", "69698428e22810ac8a47abc12d1df5b2f5d8f6b36dc5d5bfe6dd93fde857c576", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.11.0 or ~> 0.12.0 or ~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:scrivener, "~> 2.4", [hex: :scrivener, repo: "hexpm", optional: false]}], "hexpm"},
  "xain": {:hex, :xain, "0.6.2", "c43e3f30dc500ee4ed1146e1d6ec2440652d8e7b076f23dd5599fc251b0d84b2", [:mix], [{:phoenix_html, "~> 2.12", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm"},
}

If this issue is the xain version, would you recommend I set it to 0.6.1 or do something else?

Thanks again.

happysalada commented 5 years ago

yes set it back to 0.6.1 and you should be fine.

Note that there is a security flaw with 0.6.1 in that it's vulnerable to injecting javascript in the route. (if somebody adds arbitrary javascript in the url it will be executed). If you're admin is behind a protected route (reserved for admins for example) then I would say you just need to trust your admins. If the admin dashboard is available to everybody, you might want to be careful (unfortunately there is no solution for now)

DylanAndrews commented 5 years ago

Awesome. Worked like a charm. Thanks again for the help, and I'll definitely keep all of that in mind.