Skip to content

Commit 7b34087

Browse files
authored
Merge pull request #60 from chihsuan/auto/RSM-3022-secret-url-validation
Validate wrapped webhook URLs
2 parents 0b44ae7 + c4fdb07 commit 7b34087

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

elixir/lib/symphony_elixir/config/schema.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ defmodule SymphonyElixir.Config.Schema do
13241324
value = Map.get(channel, field)
13251325
allow_private = Map.get(channel, :allow_private) == true
13261326

1327-
case Notifications.Channel.validate_webhook_url(value, allow_private, allow_env_references: false) do
1327+
case Notifications.Channel.validate_webhook_url(Secret.unwrap(value), allow_private, allow_env_references: false) do
13281328
:ok -> :ok
13291329
{:error, message} -> {:error, "notifications.channels[#{index}].#{field} #{message}"}
13301330
end

elixir/test/symphony_elixir/notifications_test.exs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ defmodule SymphonyElixir.NotificationsTest do
237237
%{
238238
notifications: %{
239239
channels: [
240-
%{kind: "webhook", url: "https://hooks.slack.com/services/T000/B000/XXX"},
241-
%{kind: "webhook", url: "https://discord.com/api/webhooks/123/secret"},
242-
%{kind: "webhook", url: "https://10.0.0.1/events", allow_private: true}
240+
%{kind: "webhook", url: slack_url},
241+
%{kind: "webhook", url: discord_url},
242+
%{kind: "webhook", url: private_url, allow_private: true}
243243
]
244244
}
245245
}} =
@@ -253,6 +253,10 @@ defmodule SymphonyElixir.NotificationsTest do
253253
]
254254
}
255255
})
256+
257+
assert Secret.unwrap(slack_url) == "https://hooks.slack.com/services/T000/B000/XXX"
258+
assert Secret.unwrap(discord_url) == "https://discord.com/api/webhooks/123/secret"
259+
assert Secret.unwrap(private_url) == "https://10.0.0.1/events"
256260
end
257261

258262
test "notification schema validates webhook URLs resolved from environment" do

0 commit comments

Comments
 (0)