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

Fix dns domain validation #410

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/core/lib/core/schema/dns_domain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule Core.Schema.DnsDomain do
|> cast_assoc(:access_policy)
|> foreign_key_constraint(:creator_id)
|> foreign_key_constraint(:account_id)
|> validate_format(:name, regex(domain), message: "must be a dns complaint domain ending with #{domain}")
|> validate_format(:name, regex(domain), message: "must be a dns complaint domain one level below #{domain}")
|> validate_required(@required)
end

Expand All @@ -45,6 +45,6 @@ defmodule Core.Schema.DnsDomain do
end

def regex(base_domain) do
~r/([a-z0-9-]+\.)#{base_domain}/
~r/^[a-z0-9-]+\.#{base_domain}$/
end
end
2 changes: 1 addition & 1 deletion apps/core/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule Core.MixProject do
{:ex_machina, "~> 2.3", only: :test},
{:comeonin, "~> 5.1.2"},
{:argon2_elixir, "~> 2.0"},
{:piazza_core, "~> 0.3.6"},
{:piazza_core, "~> 0.3.7"},
{:bamboo, "~> 2.0"},
{:parallax, "~> 1.0"},
{:bourne, "~> 1.1"},
Expand Down
6 changes: 6 additions & 0 deletions apps/core/test/services/dns_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ defmodule Core.Services.DnsTest do

{:error, _} = Dns.create_domain(%{name: "some.wrong.domain"}, user)
end

test "it cannot create a nested onplural domain" do
user = insert(:user)

{:error, _} = Dns.create_domain(%{name: "some.wrong.onplural.sh"}, user)
end
end

describe "#update_domain/3" do
Expand Down
1 change: 0 additions & 1 deletion apps/cron/lib/cron/task/repo_readme.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ defmodule Cron.Task.RepoReadme do
Backfills all repository readmes
"""
use Cron
alias Core.Schema.Repository

def run() do
Core.Repo.all(Core.Schema.Repository)
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.1", "274a4b07c4adbdd7785d45a8b0bb57634d0b4f45b18d2c508b26c0344bd59b8f", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "41b4103a2fa282cfd747d377233baf213c648fdcc7928f432937676532490eee"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.15.4", "86908dc9603cc81c07e84725ee42349b5325cb250c9c20d3533856ff18dbb7dc", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 0.5", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "35d78f3c35fe10a995dca5f4ab50165b7a90cbe02e23de245381558f821e9462"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
"piazza_core": {:hex, :piazza_core, "0.3.6", "acaff9453aeab1e439589b4531e6f27de147eaf1bdf80117bcb5e5f3ef075c71", [:mix], [{:ecto_enum, "~> 1.4", [hex: :ecto_enum, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ex_crypto, "~> 0.10", [hex: :ex_crypto, repo: "hexpm", optional: false]}, {:gen_stage, "~> 0.14.2", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.5.3", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "dd99faaf425d814aabf4452c252155d0ea8d8feac8399c626d56a0c649c3efe8"},
"piazza_core": {:hex, :piazza_core, "0.3.7", "78cb63e33166cbf2d58975ff443fdc5a54f75b01f616704386bb19f084a87bce", [:mix], [{:ecto_enum, "~> 1.4", [hex: :ecto_enum, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ex_crypto, "~> 0.10", [hex: :ex_crypto, repo: "hexpm", optional: false]}, {:gen_stage, "~> 0.14.2", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.5.3", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "8b1337143c6bc0dd17746fbba97448bca00f1993265a57e43d3bf87f57a29776"},
"plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
"plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
Expand Down