chg: [workflow:module_webhook] Added support of more parameter to perform a request

composer_fix
Sami Mokaddem 2023-02-23 10:46:52 +01:00
parent d418f33835
commit 1994f35e95
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 8 additions and 6 deletions

View File

@ -5,6 +5,7 @@ class Module_ms_teams_webhook extends Module_webhook
{
public $id = 'ms-teams-webhook';
public $name = 'MS Teams Webhook';
public $version = '0.2';
public $description = 'Perform callbacks to the MS Teams webhook provided by the "Incoming Webhook" connector';
public $icon_path = 'MS_Teams.png';
@ -37,7 +38,7 @@ class Module_ms_teams_webhook extends Module_webhook
];
}
protected function doRequest($url, $contentType, $data)
protected function doRequest($url, $contentType, $data, $headers = [], $serverConfig = null)
{
$data = '{"text":"' . implode($data) . '"}';
return parent::doRequest($url, $contentType, $data);

View File

@ -8,7 +8,7 @@ class Module_webhook extends WorkflowBaseActionModule
{
public $id = 'webhook';
public $name = 'Webhook';
public $version = '0.2';
public $version = '0.3';
public $description = 'Allow to perform custom callbacks to the provided URL';
public $icon_path = 'webhook.png';
public $inputs = 1;
@ -106,21 +106,22 @@ class Module_webhook extends WorkflowBaseActionModule
return false;
}
protected function doRequest($url, $contentType, $data)
protected function doRequest($url, $contentType, $data, $headers = [], $serverConfig = null)
{
$this->Event = ClassRegistry::init('Event'); // We just need a model to use AppModel functions
$version = implode('.', $this->Event->checkMISPVersion());
$commit = $this->Event->checkMIPSCommit();
$request = [
'header' => [
'header' => array_merge([
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'User-Agent' => 'MISP ' . $version . (empty($commit) ? '' : ' - #' . $commit),
]
], $headers)
];
$syncTool = new SyncTool();
$HttpSocket = $syncTool->setupHttpSocket(null, $this->timeout);
$serverConfig = !empty($serverConfig['Server']) ? $serverConfig : ['Server' => $serverConfig];
$HttpSocket = $syncTool->setupHttpSocket($serverConfig, $this->timeout);
if ($contentType == 'form') {
$request['header']['Content-Type'] = 'application/x-www-form-urlencoded';
$response = $HttpSocket->post($url, $data, $request);