-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
185 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from .base import OrchestratorBase | ||
from api_utils import signature | ||
import logging | ||
|
||
class GithubOrchestrator(OrchestratorBase): | ||
|
||
|
||
@staticmethod | ||
def log(): | ||
return logging.getLogger("BitBucketDataCenterOrchestrator") | ||
|
||
@property | ||
def config_key(self): | ||
return "gh" | ||
|
||
@property | ||
def is_diagnostic(self) -> bool: | ||
return self.__isdiagnostic | ||
|
||
|
||
def __init__(self, headers : dict, webhook_payload : dict): | ||
OrchestratorBase.__init__(self, headers, webhook_payload) | ||
|
||
self.__isdiagnostic = False | ||
|
||
self.__event = self.get_header_key_safe('X-GitHub-Event') | ||
|
||
if not self.__event is None and self.__event == "ping": | ||
self.__isdiagnostic = True | ||
return | ||
|
||
|
||
async def is_signature_valid(self, shared_secret : str) -> bool: | ||
sig = self.get_header_key_safe('X-Hub-Signature-256') | ||
if sig is None: | ||
GithubOrchestrator.log().warning("X-Hub-Signature-256 header is missing, rejecting.") | ||
return False | ||
|
||
hashalg,hash = sig.split("=") | ||
payload_hash = signature.get(hashalg, shared_secret, self._webhook_payload) | ||
|
||
return hash == payload_hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .scm import SCMService | ||
|
||
|
||
class GHService(SCMService): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters