Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting as json with -f json causes crash. #89

Closed
alex0112 opened this issue May 18, 2021 · 2 comments
Closed

Formatting as json with -f json causes crash. #89

alex0112 opened this issue May 18, 2021 · 2 comments

Comments

@alex0112
Copy link

alex0112 commented May 18, 2021

Description:

Running sobelow with the option to output a JSON report (mix sobelow -f json) produces an exception.

Steps to reproduce:

  • Fresh install of sobelow with $ mix archive.install hex sobelow per README instructions
  • run $ mix sobelow -f json in a project containing a mix.exs file
$  mix sobelow -f json
** (UndefinedFunctionError) function Jason.encode!/2 is undefined (module Jason is not available)
    Jason.encode!(%{findings: %{high_confidence: [], low_confidence: [%{file: "lib/project/foo_bar.ex", line: 42, type: "SomeError", variable: :user_action_type}, %{file: "lib/project/foo_bar.ex", line: 42, type: "AnotherError", variable: :sql}], medium_confidence: []}, sobelow_version: "0.11.1", total_findings: 2}, [pretty: true])
    lib/sobelow.ex:142: Sobelow.print_output/0
    lib/sobelow.ex:120: Sobelow.run/0
    (mix 1.11.4) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.4) lib/mix/cli.ex:84: Mix.CLI.run_task/2

Environment Information:

  • Sobelow Version: v0.11.1 (Tried with both published hex package, and build from master branch on github)
  • Operating System: MacOS Catalina 10.15.7, error also occurs on a Debian based docker image.

Notes:

Digging in to the stack trace a little indicates that Sobelow.print_output/0 makes a call to Sobelow.FindingLog.json/1 which attempts to call Jason.encode!/1 but is unable to find Jason within the scope of the current module. When building the module or running the install command provided by the README, Jason is being installed as a dependency. However, Jason is not being aliased into the FindingLog module definition, which may be causing the issue.

@GriffinMB
Copy link
Collaborator

Hey! Thanks for opening this issue. It looks like I missed a README update - as of 11.0, you should install Sobelow with mix escript.install hex sobelow. The Changelog has some additional details. Let me know if that fixes your issue, and I will update the README now.

@alex0112
Copy link
Author

Installing with mix escript.install got it running again. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants