File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,11 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
223
223
let signing_key = Context. gh_hook_token_of_secrets secrets repo.url in
224
224
Github. validate_signature ?signing_key ~headers body
225
225
in
226
+ let repo_is_allowed secrets payload =
227
+ let repo = Github. repo_of_notification payload in
228
+ let allowed_repositories = secrets.allowed_repositories in
229
+ List. is_empty allowed_repositories || List. exists allowed_repositories ~f: (String. equal repo.url)
230
+ in
226
231
try % lwt
227
232
let secrets = Context. get_secrets_exn ctx in
228
233
match Github. parse_exn headers body with
@@ -231,6 +236,9 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
231
236
match validate_signature secrets payload with
232
237
| Error e -> action_error e
233
238
| Ok () ->
239
+ match repo_is_allowed secrets payload with
240
+ | false -> action_error " unsupported repository"
241
+ | true ->
234
242
( match % lwt refresh_repo_config ctx payload with
235
243
| Error e -> action_error e
236
244
| Ok () ->
Original file line number Diff line number Diff line change @@ -49,4 +49,5 @@ type secrets = {
49
49
?gh_token : string option; (* GitHub personal access token, if repo access requires it *)
50
50
?gh_hook_token : string option; (* GitHub webhook token to secure the webhook *)
51
51
~repositories <ocaml default="Common.StringMap.empty"> : gh_repo_secrets map_as_object;
52
+ ~allowed_repositories <ocaml default="[]"> : string list; (* whitelist of repository URLs to handle notifications for *)
52
53
}
You can’t perform that action at this time.
0 commit comments