forked from TheHive-Project/Cortex-Analyzers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quickfix for TheHive-Project#169: filter input from artifacts, only a…
…llow letters for tld part of domains
- Loading branch information
Showing
5 changed files
with
65 additions
and
5 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
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,35 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
import json | ||
import unittest | ||
import sys | ||
|
||
from cortexutils.analyzer import Analyzer | ||
|
||
# Different lib when using python3 or 2 | ||
if sys.version_info >= (3, 0): | ||
from io import StringIO | ||
else: | ||
from StringIO import StringIO | ||
|
||
class AnalyzerExtractorOutputTest(unittest.TestCase): | ||
def setUp(self): | ||
sys.stdin = StringIO(json.dumps({ | ||
"data": "8.8.8.8", | ||
"dataType": "ip" | ||
})) | ||
sys.stdout = StringIO() | ||
self.analyzer = Analyzer() | ||
|
||
def test_output(self): | ||
# Run the report method | ||
self.analyzer.report({'result': '1.2.3.4'}) | ||
|
||
# Grab the output | ||
output = self.analyzer.fpoutput.getvalue().strip() | ||
json_output = json.loads(output) | ||
|
||
# Checks | ||
self.assertNotIn(self.analyzer.get_data(), output) | ||
self.assertEqual(json_output['artifacts'][0]['value'], '1.2.3.4') | ||
self.assertEqual(json_output['artifacts'][0]['type'], 'ip') |