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 @@ -211,6 +211,11 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
211
211
let signing_key = Context. gh_hook_token_of_secrets secrets repo.url in
212
212
Github. validate_signature ?signing_key ~headers body
213
213
in
214
+ let repo_is_allowed secrets payload =
215
+ let repo = Github. repo_of_notification payload in
216
+ let allowed_repositories = secrets.allowed_repos in
217
+ List. is_empty allowed_repositories || List. exists allowed_repositories ~f: (String. equal repo.url)
218
+ in
214
219
try % lwt
215
220
let secrets = Context. get_secrets_exn ctx in
216
221
match Github. parse_exn headers body with
@@ -219,6 +224,9 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
219
224
match validate_signature secrets payload with
220
225
| Error e -> action_error e
221
226
| Ok () ->
227
+ match repo_is_allowed secrets payload with
228
+ | false -> action_error " unsupported repository"
229
+ | true ->
222
230
( match % lwt refresh_repo_config ctx payload with
223
231
| Error e -> action_error e
224
232
| Ok () ->
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ type gh_repo_secrets = {
49
49
type secrets = {
50
50
(* repo-specific secrets; overrides global values if defined for a given repo *)
51
51
~repos <ocaml default="Common.StringMap.empty"> : gh_repo_secrets map_as_object;
52
+ (* whitelist of repository URLs to handle notifications for *)
53
+ ~allowed_repos <ocaml default="[]"> : string list;
52
54
(* GitHub personal access token, if repo access requires it *)
53
55
?gh_token : string nullable;
54
56
(* GitHub webhook token to secure the webhook *)
You can’t perform that action at this time.
0 commit comments