-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [modules] many modules not loaded as python module
- Loading branch information
1 parent
9e95c0e
commit 79442c2
Showing
10 changed files
with
117 additions
and
13 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
File renamed without changes.
File renamed without changes.
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,30 @@ | ||
import os | ||
import unittest | ||
import requests | ||
|
||
|
||
class TestActions(unittest.TestCase): | ||
"""Unittest module for action modules""" | ||
def setUp(self): | ||
self.headers = {'Content-Type': 'application/json'} | ||
self.url = "http://127.0.0.1:6666/" | ||
|
||
def test_introspection(self): | ||
"""checks if all action modules are offered through the misp-modules service""" | ||
try: | ||
response = requests.get(self.url + "modules") | ||
modules = [module["name"] for module in response.json()] | ||
# list modules in the export_mod folder | ||
export_mod_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'misp_modules', 'modules', "action_mod") | ||
module_files = [file[:-3] for file in os.listdir(export_mod_path) if file.endswith(".py") if file not in ['__init__.py']] | ||
missing = [] | ||
for module in module_files: | ||
if module not in modules: | ||
missing.append(module) | ||
self.assertEqual(missing, [], f"Missing modules in __init__: {missing}") | ||
finally: | ||
response.connection.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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,30 @@ | ||
import os | ||
import unittest | ||
import requests | ||
|
||
|
||
class TestImports(unittest.TestCase): | ||
"""Unittest module for import modules""" | ||
def setUp(self): | ||
self.headers = {'Content-Type': 'application/json'} | ||
self.url = "http://127.0.0.1:6666/" | ||
|
||
def test_introspection(self): | ||
"""checks if all import modules are offered through the misp-modules service""" | ||
try: | ||
response = requests.get(self.url + "modules") | ||
modules = [module["name"] for module in response.json()] | ||
# list modules in the export_mod folder | ||
export_mod_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'misp_modules', 'modules', "import_mod") | ||
module_files = [file[:-3] for file in os.listdir(export_mod_path) if file.endswith(".py") if file not in ['__init__.py', 'testimport.py']] | ||
missing = [] | ||
for module in module_files: | ||
if module not in modules: | ||
missing.append(module) | ||
self.assertEqual(missing, [], f"Missing modules in __init__: {missing}") | ||
finally: | ||
response.connection.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |