secureworks / taegis-magic

Taegis Magic is a Jupyter Notebook and Command Line Interface for interacting with the Secureworks Taegis™ security platform. The Magics project is intended to assist users with workflows and analysis through Jupyter Notebook integrations and Pandas DataFrames.
https://www.secureworks.com/
Apache License 2.0
8 stars 5 forks source link

Taegis Magic works in CLI but not in Jupyter Notebook #17

Closed mbornhoefft closed 8 months ago

mbornhoefft commented 8 months ago

Installed last version of Taegis Magic and Taegis SDK via pip. Taegis Magic works fine in CLI (Powershell), but if I try to use it from Jupyter Notebook it fails to find a certain import: `%load_ext taegis_magic

ModuleNotFoundError Traceback (most recent call last) Cell In[8], line 1 ----> 1 get_ipython().run_line_magic('load_ext', 'taegis_magic')

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\IPython\core\interactiveshell.py:2456, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth) 2454 kwargs['local_ns'] = self.get_local_scope(stack_depth) 2455 with self.builtin_trap: -> 2456 result = fn(*args, **kwargs) 2458 # The code below prevents the output from being displayed 2459 # when using magics with decorator @output_can_be_silenced 2460 # when the last Python token in the expression is a ';'. 2461 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\IPython\core\magics\extension.py:33, in ExtensionMagics.load_ext(self, module_str) 31 if not module_str: 32 raise UsageError('Missing module name.') ---> 33 res = self.shell.extension_manager.load_extension(module_str) 35 if res == 'already loaded': 36 print("The %s extension is already loaded. To reload it, use:" % module_str)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\IPython\core\extensions.py:62, in ExtensionManager.load_extension(self, module_str) 55 """Load an IPython extension by its module name. 56 57 Returns the string "already loaded" if the extension is already loaded, 58 "no load function" if the module doesn't have a load_ipython_extension 59 function, or None if it succeeded. 60 """ 61 try: ---> 62 return self._load_extension(module_str) 63 except ModuleNotFoundError: 64 if module_str in BUILTINS_EXTS:

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\IPython\core\extensions.py:77, in ExtensionManager._load_extension(self, module_str) 75 with self.shell.builtin_trap: 76 if module_str not in sys.modules: ---> 77 mod = import_module(module_str) 78 mod = sys.modules[module_str] 79 if self._call_load_ipython_extension(mod):

File ~\AppData\Local\Programs\Python\Python310\lib\importlib__init__.py:126, in import_module(name, package) 124 break 125 level += 1 --> 126 return _bootstrap._gcd_import(name[level:], package, level)

File :1050, in _gcd_import(name, package, level)

File :1027, in _find_andload(name, import)

File :1006, in _find_and_loadunlocked(name, import)

File :688, in _load_unlocked(spec)

File :883, in exec_module(self, module)

File :241, in _call_with_frames_removed(f, *args, **kwds)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\taegis_magic__init__.py:1 ----> 1 from .magics import TaegisMagics, load_ipython_extension

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\taegis_magic\magics.py:15 13 from IPython.core.magic import Magics, line_cell_magic, magics_class 14 from IPython.display import display, display_markdown, Javascript ---> 15 from taegis_magic.cli import app 16 from taegis_magic.core.cache import ( 17 get_cache_item, 18 decode_base64_obj_as_pickle, 19 display_cache, 20 ) 22 log = logging.getLogger(name)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\taegis_magic\cli.py:8 6 import typer 7 from gql.transport.exceptions import TransportQueryError ----> 8 from taegis_magic.commands import ( 9 alerts, 10 audits, 11 clients, 12 configure, 13 events, 14 investigations, 15 preferences, 16 rules, 17 tenant_profiles, 18 tenants, 19 threat, 20 users, 21 ) 22 from taegis_magic.core.log import TRACE_LOG_LEVEL, get_module_logger 24 log = logging.getLogger(name)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\taegis_magic\commands\investigations.py:41 39 from taegis_magic.core.callbacks import verify_file 40 from taegis_sdk_python import build_output_string ---> 41 from taegis_sdk_python.services.investigations2.types import ( 42 CreateInvestigationInput, 43 InvestigationStatus, 44 InvestigationsV2, 45 InvestigationsV2Arguments, 46 InvestigationType, 47 InvestigationV2, 48 InvestigationFileV2Arguments, 49 InvestigationFilesV2Arguments, 50 DeleteInvestigationFileInput, 51 InitInvestigationFileUploadInput, 52 ) 53 from taegis_sdk_python.services.sharelinks.types import ShareLinkCreateInput 54 from typing_extensions import Annotated

ModuleNotFoundError: No module named 'taegis_sdk_python.services.investigations2'`

mbornhoefft commented 8 months ago

Issue seemed to relate to my environment. When starting in a clean virtual environment, the issue disappeared.