mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 01:02:46 +01:00
Ensure API key is used
This commit is contained in:
@@ -19,7 +19,8 @@ def sendReq(conf, meta, ip):
|
||||
url = url + 'v3/community/' + ip
|
||||
elif conf['api_version'] == 'investigate' or 'automate':
|
||||
url = url + 'v2/noise/context/' + ip
|
||||
response = requests.request('GET', url)
|
||||
headers = {"key": conf['api_key']}
|
||||
response = requests.request('GET', url=url, headers=headers)
|
||||
return response.json()
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class TestGreynoiseMethods(unittest.TestCase):
|
||||
conf = {"base_url": "https://myurl/", "api_key": "abcd1234", "api_version": "community"}
|
||||
ip = "192.168.1.1"
|
||||
response = greynoise.sendReq(conf=conf, meta=meta, ip=ip)
|
||||
mock.assert_called_once_with("GET", "https://myurl/v3/community/192.168.1.1")
|
||||
mock.assert_called_once_with("GET", headers={'key': 'abcd1234'}, url="https://myurl/v3/community/192.168.1.1")
|
||||
self.assertIsNotNone(response)
|
||||
|
||||
def test_sendReq_investigate(self):
|
||||
@@ -46,7 +46,7 @@ class TestGreynoiseMethods(unittest.TestCase):
|
||||
conf = {"base_url": "https://myurl/", "api_key": "abcd1234", "api_version": "investigate"}
|
||||
ip = "192.168.1.1"
|
||||
response = greynoise.sendReq(conf=conf, meta=meta, ip=ip)
|
||||
mock.assert_called_once_with("GET", "https://myurl/v2/noise/context/192.168.1.1")
|
||||
mock.assert_called_once_with("GET", headers={'key': 'abcd1234'}, url="https://myurl/v2/noise/context/192.168.1.1")
|
||||
self.assertIsNotNone(response)
|
||||
|
||||
def test_sendReq_automate(self):
|
||||
@@ -55,7 +55,7 @@ class TestGreynoiseMethods(unittest.TestCase):
|
||||
conf = {"base_url": "https://myurl/", "api_key": "abcd1234", "api_version": "automate"}
|
||||
ip = "192.168.1.1"
|
||||
response = greynoise.sendReq(conf=conf, meta=meta, ip=ip)
|
||||
mock.assert_called_once_with("GET", "https://myurl/v2/noise/context/192.168.1.1")
|
||||
mock.assert_called_once_with("GET", headers={'key': 'abcd1234'}, url="https://myurl/v2/noise/context/192.168.1.1")
|
||||
self.assertIsNotNone(response)
|
||||
|
||||
def test_prepareResults_invalidIP(self):
|
||||
|
||||
Reference in New Issue
Block a user