File tree Expand file tree Collapse file tree 5 files changed +35
-2
lines changed
Expand file tree Collapse file tree 5 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 11# Unreleased
22
3+ # 0.44.0
4+ * Return 422 and log when a webhook is from an unknown (unconfigured) GitHub organization.
5+
36# 0.43.3
47* (bugfix) Ensure we always call ` bundle config set without ` , even if the without group is empty
58
Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- shipit-engine (0.43.4 )
4+ shipit-engine (0.44.0 )
55 active_model_serializers (~> 0.9.3 )
66 ansi_stream (~> 0.0.6 )
77 autoprefixer-rails (~> 6.4.1 )
Original file line number Diff line number Diff line change @@ -36,6 +36,16 @@ def verify_signature
3636 "signature=#{ request . headers [ 'X-Hub-Signature' ] } " ,
3737 "status=#{ status } "
3838 ] . join ( ' ' ) )
39+ rescue Shipit ::GithubOrganizationUnknown => e
40+ head ( 422 )
41+ Rails . logger . warn ( [
42+ 'WebhookController#verify_signature' ,
43+ 'Webhook from unknown organization' ,
44+ "event=#{ event } " ,
45+ "repository_owner=#{ repository_owner } " ,
46+ "unknown_organization=#{ e . message } " ,
47+ "status=#{ status } "
48+ ] . join ( ' ' ) )
3949 end
4050
4151 def check_if_ping
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33module Shipit
4- VERSION = '0.43.4 '
4+ VERSION = '0.44.0 '
55end
Original file line number Diff line number Diff line change @@ -106,6 +106,26 @@ class WebhooksControllerTest < ActionController::TestCase
106106 assert_response :unprocessable_entity
107107 end
108108
109+ test "unknown github organization logs and returns unprocessable entity" do
110+ @request . headers [ 'X-Github-Event' ] = 'push'
111+
112+ payload = JSON . parse ( payload ( :push_master ) )
113+ payload [ "repository" ] [ "owner" ] [ "login" ] = "unknown-org"
114+
115+ Shipit . stubs ( :github ) . raises ( Shipit ::GithubOrganizationUnknown . new ( "unknown-org" ) )
116+ Rails . logger . expects ( :warn ) . with ( [
117+ 'WebhookController#verify_signature' ,
118+ 'Webhook from unknown organization' ,
119+ "event=push" ,
120+ "repository_owner=unknown-org" ,
121+ "unknown_organization=unknown-org" ,
122+ "status=422"
123+ ] . join ( ' ' ) )
124+
125+ post :create , body : payload . to_json , as : :json
126+ assert_response :unprocessable_entity
127+ end
128+
109129 test ":membership creates the mentioned team on the fly" do
110130 @request . headers [ 'X-Github-Event' ] = 'membership'
111131 assert_difference -> { Team . count } , 1 do
You can’t perform that action at this time.
0 commit comments