From 387356b4d5eab8918fff290d08e1f8033ce6cd51 Mon Sep 17 00:00:00 2001 From: Dan Schultzer <1254724+danschultzer@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:33:10 -0700 Subject: [PATCH 1/2] Upgrade to Elixir 1.15 Inets and SSL need to be loaded in Elixir 1.15 due to code load changes. --- .github/workflows/elixir.yml | 6 ++++-- lib/mix/tasks/sobelow.ex | 5 +++++ test/log_test.exs | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index fc24f33..02d16b1 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -33,6 +33,8 @@ jobs: otp: 25.1 - elixir: '1.14.x' otp: 25.1 + - elixir: '1.15.x' + otp: 26.0 steps: - name: Setup Elixir @@ -54,11 +56,11 @@ jobs: run: mix hex.audit - name: Check Formatting - if: ${{ matrix.elixir == '1.14.x' }} # we only care about formatting for latest version of Elixir + if: ${{ matrix.elixir == '1.15.x' }} # we only care about formatting for latest version of Elixir run: mix format --check-formatted - name: Compiles w/o Warnings - if: ${{ matrix.elixir == '1.14.x' }} # we only care about warnings for latest version of Elixir + if: ${{ matrix.elixir == '1.15.x' }} # we only care about warnings for latest version of Elixir run: mix compile --warnings-as-errors - name: Credo diff --git a/lib/mix/tasks/sobelow.ex b/lib/mix/tasks/sobelow.ex index 3d5ae59..34cf37f 100644 --- a/lib/mix/tasks/sobelow.ex +++ b/lib/mix/tasks/sobelow.ex @@ -169,6 +169,11 @@ defmodule Mix.Tasks.Sobelow do save_config = Keyword.get(opts, :save_config) + if function_exported?(Mix, :ensure_application!, 1) do + Mix.ensure_application!(:ssl) + Mix.ensure_application!(:inets) + end + cond do diff -> run_diff(argv) diff --git a/test/log_test.exs b/test/log_test.exs index 8e6b97a..1afd0f7 100644 --- a/test/log_test.exs +++ b/test/log_test.exs @@ -4,7 +4,7 @@ defmodule SobelowTest.LogTest do # log_json_finding(line_no, filename, fun_name, var, severity, type) test "Log JSON finding with function as function name" do - output = """ + output = Jason.decode!(""" { "findings": { "high_confidence": [ @@ -21,7 +21,7 @@ defmodule SobelowTest.LogTest do "sobelow_version": "1.0.0", "total_findings": 1 } - """ + """) FindingLog.start_link() Fingerprint.start_link() @@ -35,6 +35,6 @@ defmodule SobelowTest.LogTest do Sobelow.log_finding(finding, %Sobelow.Finding{confidence: :high}) - assert FindingLog.json("1.0.0") <> "\n" == output + assert Jason.decode!(FindingLog.json("1.0.0")) == output end end From 38a9ad0821f4eba66ee478d106b8bbedebd0d4c9 Mon Sep 17 00:00:00 2001 From: Holden Oullette <6202965+houllette@users.noreply.github.com> Date: Sun, 6 Aug 2023 10:23:25 -0600 Subject: [PATCH 2/2] added mix format changes --- lib/sobelow.ex | 4 ++-- test/fixtures/utils/config.exs | 2 +- test/log_test.exs | 37 +++++++++++++++++----------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/sobelow.ex b/lib/sobelow.ex index e37da43..deb0e1e 100644 --- a/lib/sobelow.ex +++ b/lib/sobelow.ex @@ -526,7 +526,7 @@ defmodule Sobelow do {timestamp, _} = case :file.read_line(iofile) do - {:ok, 'sobelow-' ++ timestamp} -> to_string(timestamp) |> Integer.parse() + {:ok, ~c"sobelow-" ++ timestamp} -> to_string(timestamp) |> Integer.parse() _ -> file_error() end @@ -546,7 +546,7 @@ defmodule Sobelow do {:ok, _} = Application.ensure_all_started(:inets) {:ok, _} = :inets.start(:httpc, [{:profile, :sobelow}]) - url = 'https://sobelow.io/version' + url = ~c"https://sobelow.io/version" http_options = [ ssl: [ diff --git a/test/fixtures/utils/config.exs b/test/fixtures/utils/config.exs index 41395f7..9e19ac3 100644 --- a/test/fixtures/utils/config.exs +++ b/test/fixtures/utils/config.exs @@ -1,4 +1,4 @@ use Mix.Config config :test, - security_option: 'option' + security_option: ~c"option" diff --git a/test/log_test.exs b/test/log_test.exs index 1afd0f7..bccf651 100644 --- a/test/log_test.exs +++ b/test/log_test.exs @@ -4,24 +4,25 @@ defmodule SobelowTest.LogTest do # log_json_finding(line_no, filename, fun_name, var, severity, type) test "Log JSON finding with function as function name" do - output = Jason.decode!(""" - { - "findings": { - "high_confidence": [ - { - "file": "file.ex", - "line": 1, - "type": "N/A", - "variable": "var" - } - ], - "low_confidence": [], - "medium_confidence": [] - }, - "sobelow_version": "1.0.0", - "total_findings": 1 - } - """) + output = + Jason.decode!(""" + { + "findings": { + "high_confidence": [ + { + "file": "file.ex", + "line": 1, + "type": "N/A", + "variable": "var" + } + ], + "low_confidence": [], + "medium_confidence": [] + }, + "sobelow_version": "1.0.0", + "total_findings": 1 + } + """) FindingLog.start_link() Fingerprint.start_link()