Skip to content

fix(secops-soar): load marketplace modules by file path so dotted filenames work - #352

Open
atrearyan wants to merge 2 commits into
google:mainfrom
atrearyan:fix/marketplace-dotted-modules
Open

atrearyan wants to merge 2 commits into
google:mainfrom
atrearyan:fix/marketplace-dotted-modules

Conversation

@atrearyan

Copy link
Copy Markdown
Contributor

Summary

The --integrations loader in server/secops-soar/secops_soar_mcp/server.py imported each enabled module as marketplace.{filename stem}. Four marketplace files have dots in their names, and the import system reads every dot as a package separator. Those modules could never load, so their 19 tools could not be enabled:

  • any.run
  • stealthwatchv6.10
  • symantecemailsecurity.cloud
  • tenable.io

The loader now imports each enabled module from its file path, under secops_soar_mcp.marketplace.<stem with dots replaced by underscores>.

Closes #350

Behavior

Tests

New tests/unit/test_marketplace_loading.py (7 tests):

  • The four dotted integrations register all of their tools.
  • Every one of the 294 marketplace modules loads with no errors, and every @mcp.tool() it defines is registered.
  • Dotted integration names are matched case-insensitively (Tenable.io, Any.Run).
  • A module that fails to import is logged, and the other integrations still load.
  • A failed load leaves no partial module in sys.modules.
  • An already-imported module is reused.
  • Replacing dots with underscores maps no two files to the same module name.

The first two tests fail on main: all 294 modules fail with No module named 'marketplace' under pytest. All 7 pass with this change. tests/unit passes on Python 3.11, 3.12 and 3.14 (18 passed).

I also ran the real server over stdio against a stub SOAR API with --integrations tenable.io,any.run,stealthwatchv6.10,symantecemailsecurity.cloud,CSV:

Launch main This PR
README way (--directory .../secops_soar_mcp run server.py) CSV only; 0 tools from the dotted integrations all 5 integrations: 8 + 6 + 3 + 2 + 4 tools
As a package (python -m secops_soar_mcp.server, another cwd) no integration tools all 5 integrations: 8 + 6 + 3 + 2 + 4 tools

Notes

  • Module and logger names change from marketplace.<stem> to secops_soar_mcp.marketplace.<stem>. Nothing in the repo refers to the old names.
  • docs/toc.md links soar_integrations/tenable_io.md, which does not exist. I left that for a separate docs change.

The --integrations loader imported each module as
`marketplace.{filename stem}`. Four marketplace files have dots in
their names (any.run, stealthwatchv6.10, symantecemailsecurity.cloud,
tenable.io), and the import system reads every dot as a package
separator, so those 19 tools could never be enabled.

Load each enabled module from its file path under
`secops_soar_mcp.marketplace.<stem with dots replaced by underscores>`
instead. --integrations names are unchanged, an already-imported module
is reused, and a module that fails to import is removed from
sys.modules before the existing error handling logs it. Loading by path
also no longer depends on the marketplace directory being on sys.path.

Closes google#350
@atrearyan
atrearyan requested a review from a team November 13, 2026 00:48
…ilures

- Import the marketplace package and set each loaded module as an
  attribute on it, as a regular import does. Without this,
  `secops_soar_mcp.marketplace.tenable_io` attribute access and
  mock.patch targets under it raised AttributeError.
- Remove a partially executed module from sys.modules on any exception,
  including SystemExit and KeyboardInterrupt, so a later call cannot
  reuse it.
- Log every failure to load a module as an import failure. Errors other
  than ImportError, such as SyntaxError, were logged as "Failed during
  registration call".
- Drop the missing __init__.py warning: loading by file path no longer
  depends on it.
- test_every_marketplace_module_loads also fails on warnings, so a
  module without register_tools is caught.
@atrearyan

Copy link
Copy Markdown
Contributor Author

Hi @dandye , Follow-up comment: loaded modules are now bound on the secops_soar_mcp.marketplace package like a regular import, partial modules are removed on any exception (including SystemExit), all load failures are
logged as import failures, and the stale missing __init__.py warning is removed. test_every_marketplace_module_loads now also fails on warnings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[secops-soar] --integrations cannot load marketplace modules with dots in their filenames

1 participant