@@ -143,10 +143,13 @@ def lambda_handler(event, context):
143143 if event ['params' ]['header' ]['X-Gitlab-Token' ] in apikeys :
144144 secure = True
145145 if 'X-Hub-Signature' in event ['params' ]['header' ].keys ():
146- logger .info ('Checking X-Hub-Signature' )
147146 for k in apikeys :
148- k1 = hmac .new (str (k ), str (event ['context' ]['raw-body' ]), hashlib .sha256 ).hexdigest ()
149- k2 = str (event ['params' ]['header' ]['X-Hub-Signature' ].replace ('sha256=' , '' ))
147+ if 'use-sha256' in event ['context' ]:
148+ k1 = hmac .new (str (k ), str (event ['context' ]['raw-body' ]), hashlib .sha256 ).hexdigest ()
149+ k2 = str (event ['params' ]['header' ]['X-Hub-Signature' ].replace ('sha256=' , '' ))
150+ else :
151+ k1 = hmac .new (str (k ), str (event ['context' ]['raw-body' ]), hashlib .sha1 ).hexdigest ()
152+ k2 = str (event ['params' ]['header' ]['X-Hub-Signature' ].replace ('sha1=' , '' ))
150153 if k1 == k2 :
151154 secure = True
152155 # TODO: Add the ability to clone TFS repo using SSH keys
@@ -156,7 +159,9 @@ def lambda_handler(event, context):
156159 try :
157160 full_name = event ['body-json' ]['repository' ]['fullName' ]
158161 except KeyError :
159- full_name = event ['body-json' ]['repository' ]['path_with_namespace' ]
162+ try :
163+ full_name = event ['body-json' ]['repository' ]['path_with_namespace' ]
164+ except KeyError :
160165 try :
161166 full_name = event ['body-json' ]['repository' ]['name' ]
162167 except KeyError : # BitBucket pull-request
@@ -184,7 +189,9 @@ def lambda_handler(event, context):
184189 try :
185190 remote_url = 'git@' + event ['body-json' ]['repository' ]['links' ]['html' ]['href' ].replace ('https://' , '' ).replace ('/' , ':' , 1 )+ '.git'
186191 except :
187- remote_url = event ['body-json' ]['repository' ]['ssh_url' ]
192+ try :
193+ remote_url = event ['body-json' ]['repository' ]['ssh_url' ]
194+ except : #Bitbucket
188195 try :
189196 for i , url in enumerate (event ['body-json' ]['repository' ]['links' ]['clone' ]):
190197 if url ['name' ] == 'ssh' :
0 commit comments