From 015dcfa051eb1025c75f65263a073bb43a91fccb Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 28 Sep 2021 21:26:36 +0200 Subject: [PATCH] HOTFIX: add domain blacklist --- config/runtime.exs | 8 +++++++- lib/plausible_web/controllers/api/external_controller.ex | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/runtime.exs b/config/runtime.exs index 7cd19c0b6..de9bc145f 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -129,6 +129,11 @@ log_level = |> get_var_from_path_or_env("LOG_LEVEL", "warn") |> String.to_existing_atom() +domain_blacklist = + config_dir + |> get_var_from_path_or_env("DOMAIN_BLACKLIST", "") + |> String.split(",") + is_selfhost = config_dir |> get_var_from_path_or_env("SELFHOST", "true") @@ -174,7 +179,8 @@ config :plausible, site_limit: site_limit, site_limit_exempt: site_limit_exempt, is_selfhost: is_selfhost, - custom_script_name: custom_script_name + custom_script_name: custom_script_name, + domain_blacklist: domain_blacklist config :plausible, :selfhost, disable_authentication: disable_auth, diff --git a/lib/plausible_web/controllers/api/external_controller.ex b/lib/plausible_web/controllers/api/external_controller.ex index 69e13f80a..874090d7d 100644 --- a/lib/plausible_web/controllers/api/external_controller.ex +++ b/lib/plausible_web/controllers/api/external_controller.ex @@ -71,7 +71,7 @@ defmodule PlausibleWeb.Api.ExternalController do ua = parse_user_agent(conn) - if is_bot?(ua) do + if is_bot?(ua) || params["domain"] in Application.get_env(:plausible, :domain_blacklist) do :ok else uri = params["url"] && URI.parse(params["url"])