File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,11 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
237
237
let signing_key = Context. gh_hook_token_of_secrets secrets repo.url in
238
238
Github. validate_signature ?signing_key ~headers body
239
239
in
240
+ let repo_is_allowed secrets payload =
241
+ let repo = Github. repo_of_notification payload in
242
+ let allowed_repos = secrets.allowed_repos in
243
+ List. is_empty allowed_repos || List. exists allowed_repos ~f: (String. equal repo.url)
244
+ in
240
245
try % lwt
241
246
let secrets = Context. get_secrets_exn ctx in
242
247
match Github. parse_exn headers body with
@@ -245,6 +250,9 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
245
250
match validate_signature secrets payload with
246
251
| Error e -> action_error e
247
252
| Ok () ->
253
+ match repo_is_allowed secrets payload with
254
+ | false -> action_error " unsupported repository"
255
+ | true ->
248
256
( match % lwt refresh_repo_config ctx payload with
249
257
| Error e -> action_error e
250
258
| Ok () ->
Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ type gh_repo_secrets = {
57
57
type secrets = {
58
58
(* repo-specific secrets; overrides global values if defined for a given repo *)
59
59
~repo_secrets <ocaml default="Common.StringMap.empty"> : gh_repo_secrets map_as_object;
60
+ (* whitelist of repository URLs to handle notifications for *)
61
+ ~allowed_repos <ocaml default="[]"> : string list;
60
62
(* GitHub personal access token, if repo access requires it *)
61
63
?gh_token : string nullable;
62
64
(* GitHub webhook token to secure the webhook *)
You can’t perform that action at this time.
0 commit comments