-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #169: Bug in automatic artifact extraction
* Quickfix for #169: filter input from artifacts, only allow letters for tld part of domains * Forgot to clean-up. :) * Quickfix for #169: added same regex change for fqdn detection * Bump version
- Loading branch information
Showing
6 changed files
with
62 additions
and
7 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
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') |