diff --git a/VERSION.json b/VERSION.json index 7b36fa445..d5cd3311a 100644 --- a/VERSION.json +++ b/VERSION.json @@ -1 +1 @@ -{"major":2, "minor":4, "hotfix":167} +{"major":3, "minor":0, "hotfix":0} diff --git a/src/Lib/Tools/HttpTool.php b/src/Lib/Tools/HttpTool.php index cf4c4f5db..c7da589e4 100644 --- a/src/Lib/Tools/HttpTool.php +++ b/src/Lib/Tools/HttpTool.php @@ -132,7 +132,8 @@ class HttpTool extends CakeClient } // Add user-agent - $this->_defaultConfig['headers']['User-Agent'] = "MISP - Threat Intelligence & Sharing Platform"; // LATER add MISP version + $this->_defaultConfig['headers']['User-Agent'] = "MISP - Threat Intelligence & Sharing Platform"; + // TODO add MISP version? or only do it for server to server communication? (see configFromServer()) } /** @@ -159,9 +160,31 @@ class HttpTool extends CakeClient if (!empty($server['skip_proxy'])) { $this->_defaultConfig['skip_proxy'] = true; } + if (!empty($server['authkey'])) { + $this->_defaultConfig['headers']['Authorization'] = $server['authkey']; + } + $this->_defaultConfig['headers']['Accept'] = 'application/json'; + $this->_defaultConfig['headers']['Content-Type'] = 'application/json'; + // we're talking to another MISP server, it is therefore interesting to share out version and UUID to ensure compatible communication + $this->shareMISPInfo(); } } + + /** + * shareMISPInfo - share MISP version and UUID in the headers + * + * @return void + */ + public function shareMISPInfo() + { + $misp_version = implode('.', \App\Lib\Tools\MISPTool::getVersion()); + // FIXME set User-Agent is alread set, but without with MISP version: and co - 'User-Agent' => 'MISP ' . $version . (empty($commit) ? '' : ' - #' . $commit), + $this->_defaultConfig['headers']['MISP-version'] = $misp_version; + $this->_defaultConfig['headers']['MISP-uuid'] = Configure::read('MISP.uuid'); + + } + /** * Helper method for doing requests. This method is there to provide us a wrapper implementing custom MISP options. diff --git a/src/Lib/Tools/MISPTool.php b/src/Lib/Tools/MISPTool.php new file mode 100644 index 000000000..8522103fc --- /dev/null +++ b/src/Lib/Tools/MISPTool.php @@ -0,0 +1,27 @@ +Log; } + + /** + * @deprecated checkMISPVersion - use \App\Lib\Tools\MISPTool::getVersion() instead + * + * @return array + */ + public function checkMISPVersion() + { + return \App\Lib\Tools\MISPTool::getVersion(); + } } diff --git a/src/VERSION.json b/src/VERSION.json deleted file mode 100644 index a51d7e020..000000000 --- a/src/VERSION.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.8", - "application": "Cerebrate" -}