mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Add function/test for non-existent VT api_key
This commit is contained in:
@@ -3,6 +3,14 @@ import requests
|
||||
import argparse
|
||||
import helpers
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def checkConfigRequirements(conf):
|
||||
if "api_key" not in conf or len(conf['api_key']) == 0:
|
||||
sys.exit(126)
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def buildHeaders(conf):
|
||||
@@ -58,6 +66,7 @@ def prepareResults(raw):
|
||||
|
||||
|
||||
def analyze(conf, input):
|
||||
checkConfigRequirements(conf)
|
||||
meta = helpers.loadMetadata(__file__)
|
||||
data = helpers.parseArtifact(input)
|
||||
helpers.checkSupportedType(meta, data["artifactType"])
|
||||
|
||||
@@ -25,6 +25,12 @@ class TestVirusTotalMethods(unittest.TestCase):
|
||||
self.assertEqual(mock_stdout.getvalue(), expected)
|
||||
mock.assert_called_once()
|
||||
|
||||
def checkConfigRequirements(self):
|
||||
conf = {"not_a_key": "abcd12345"}
|
||||
with self.assertRaises(SystemExit) as cm:
|
||||
virustotal.checkConfigRequirements(conf)
|
||||
self.assertEqual(cm.exception.code, 126)
|
||||
|
||||
def test_buildHeaders(self):
|
||||
result = virustotal.buildHeaders({"api_key": "xyz"})
|
||||
self.assertEqual("xyz", result["x-apikey"])
|
||||
|
||||
Reference in New Issue
Block a user