fix: add castore dep and sanitize sync error messages
Add castore as a direct dependency to provide CA certificates in environments where the OS trust store is not available (Dokku staging). Stop leaking raw system errors (like CA trust store details) to the UI by logging the full error server-side and showing a generic user-friendly message instead.
This commit is contained in:
parent
3b0487fd75
commit
3b97e437f2
7 changed files with 15 additions and 7 deletions
|
|
@ -209,7 +209,10 @@ defmodule Towerops.Gaiia.Sync do
|
|||
|
||||
defp humanize_sync_error(%Req.TransportError{reason: :econnrefused}), do: "Connection refused — unable to reach Gaiia"
|
||||
|
||||
defp humanize_sync_error(%Req.TransportError{reason: reason}), do: "Connection error: #{reason}"
|
||||
defp humanize_sync_error(%Req.TransportError{reason: reason}) do
|
||||
Logger.warning("Gaiia sync transport error: #{inspect(reason)}")
|
||||
"Connection error — unable to establish a secure connection to Gaiia"
|
||||
end
|
||||
|
||||
defp humanize_sync_error(reason) when is_binary(reason), do: reason
|
||||
|
||||
|
|
@ -224,6 +227,6 @@ defmodule Towerops.Gaiia.Sync do
|
|||
|
||||
defp humanize_sync_error(reason) do
|
||||
Logger.warning("Gaiia sync failed with unexpected error: #{inspect(reason)}")
|
||||
"An unexpected error occurred during sync: #{inspect(reason)}"
|
||||
"An unexpected error occurred during sync"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -235,7 +235,10 @@ defmodule Towerops.NetBox.Sync do
|
|||
|
||||
defp humanize_sync_error(%Req.TransportError{reason: :econnrefused}), do: "Connection refused — unable to reach NetBox"
|
||||
|
||||
defp humanize_sync_error(%Req.TransportError{reason: reason}), do: "Connection error: #{reason}"
|
||||
defp humanize_sync_error(%Req.TransportError{reason: reason}) do
|
||||
Logger.warning("NetBox sync transport error: #{inspect(reason)}")
|
||||
"Connection error — unable to establish a secure connection to NetBox"
|
||||
end
|
||||
|
||||
defp humanize_sync_error(reason) when is_binary(reason), do: reason
|
||||
|
||||
|
|
@ -243,6 +246,6 @@ defmodule Towerops.NetBox.Sync do
|
|||
|
||||
defp humanize_sync_error(reason) do
|
||||
Logger.warning("NetBox sync failed with unexpected error: #{inspect(reason)}")
|
||||
"An unexpected error occurred during sync: #{inspect(reason)}"
|
||||
"An unexpected error occurred during sync"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -78,6 +78,6 @@ defmodule Towerops.Sonar.Sync do
|
|||
|
||||
defp humanize_sync_error(reason) do
|
||||
Logger.warning("Sonar sync failed with unexpected error: #{inspect(reason)}")
|
||||
"An unexpected error occurred during sync: #{inspect(reason)}"
|
||||
"An unexpected error occurred during sync"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -71,6 +71,6 @@ defmodule Towerops.Splynx.Sync do
|
|||
|
||||
defp humanize_sync_error(reason) do
|
||||
Logger.warning("Splynx sync failed with unexpected error: #{inspect(reason)}")
|
||||
"An unexpected error occurred during sync: #{inspect(reason)}"
|
||||
"An unexpected error occurred during sync"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -74,6 +74,6 @@ defmodule Towerops.Visp.Sync do
|
|||
|
||||
defp humanize_sync_error(reason) do
|
||||
Logger.warning("VISP sync failed with unexpected error: #{inspect(reason)}")
|
||||
"An unexpected error occurred during sync: #{inspect(reason)}"
|
||||
"An unexpected error occurred during sync"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
1
mix.exs
1
mix.exs
|
|
@ -62,6 +62,7 @@ defmodule Towerops.MixProject do
|
|||
{:cbor, "~> 1.0"},
|
||||
{:protobuf, "~> 0.12"},
|
||||
{:req, "~> 0.5"},
|
||||
{:castore, "~> 1.0"},
|
||||
{:sweet_xml, "~> 0.7"},
|
||||
{:yaml_elixir, "~> 2.9"},
|
||||
{:telemetry_metrics, "~> 1.0"},
|
||||
|
|
|
|||
1
mix.lock
1
mix.lock
|
|
@ -4,6 +4,7 @@
|
|||
"argon2_elixir": {:hex, :argon2_elixir, "4.1.3", "4f28318286f89453364d7fbb53e03d4563fd7ed2438a60237eba5e426e97785f", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "7c295b8d8e0eaf6f43641698f962526cdf87c6feb7d14bd21e599271b510608c"},
|
||||
"bandit": {:hex, :bandit, "1.10.3", "1e5d168fa79ec8de2860d1b4d878d97d4fbbe2fdbe7b0a7d9315a4359d1d4bb9", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.18", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "99a52d909c48db65ca598e1962797659e3c0f1d06e825a50c3d75b74a5e2db18"},
|
||||
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
|
||||
"castore": {:hex, :castore, "1.0.17", "4f9770d2d45fbd91dcf6bd404cf64e7e58fed04fadda0923dc32acca0badffa2", [:mix], [], "hexpm", "12d24b9d80b910dd3953e165636d68f147a31db945d2dcb9365e441f8b5351e5"},
|
||||
"cbor": {:hex, :cbor, "1.0.1", "39511158e8ea5a57c1fcb9639aaa7efde67129678fee49ebbda780f6f24959b0", [:mix], [], "hexpm", "5431acbe7a7908f17f6a9cd43311002836a34a8ab01876918d8cfb709cd8b6a2"},
|
||||
"cc_precompiler": {:hex, :cc_precompiler, "0.1.11", "8c844d0b9fb98a3edea067f94f616b3f6b29b959b6b3bf25fee94ffe34364768", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3427232caf0835f94680e5bcf082408a70b48ad68a5f5c0b02a3bea9f3a075b9"},
|
||||
"certifi": {:hex, :certifi, "2.15.0", "0e6e882fcdaaa0a5a9f2b3db55b1394dba07e8d6d9bcad08318fb604c6839712", [:rebar3], [], "hexpm", "b147ed22ce71d72eafdad94f055165c1c182f61a2ff49df28bcc71d1d5b94a60"},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue