Skip to content

feat(metras): add Metras internal-enrichment connector for fleet-presence lookups (#7042)#7040

Open
Khidr6G wants to merge 3 commits into
OpenCTI-Platform:masterfrom
Khidr6G:feature/metras-internal-enrichment
Open

feat(metras): add Metras internal-enrichment connector for fleet-presence lookups (#7042)#7040
Khidr6G wants to merge 3 commits into
OpenCTI-Platform:masterfrom
Khidr6G:feature/metras-internal-enrichment

Conversation

@Khidr6G

@Khidr6G Khidr6G commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

  • Add a new INTERNAL_ENRICHMENT connector for the Metras EDR platform
    (api.metras.sa, X-API-KEY) under internal-enrichment/metras/.
  • Answers "have I seen this in my fleet?" for IPv4-Addr and StixFile observables:
    • IPv4-Addr → Metras EDR alerts (agent_ip) + endpoint inventory (interface_ip).
    • StixFile → Metras binary list (sha256/sha1) + binary details (md5).
    • Output: a context Note summarizing local presence, plus an optional
      Identity(identity_class="system") for each matched fleet endpoint and a related-to
      relationship. No Sighting is emitted (stix2 forbids sighting an SCO) and no
      Infrastructure objects are created.
  • Enrichment-safe behavior: custom TLP gate (no helper.check_max_tlp), refang before external
    calls, entity_in_scope guard with file → stixfile alias, and a raised ValueError on
    total lookup failure (never silently completes with 0 objects). Playbook-compatible
    (playbook_supported: true).
  • STIX id of the enriched entity resolved from enrichment_entity.standard_id then
    stix_entity.id (never the internal DB id); deterministic IDs for notes/identities/relationships.
  • Secrets typed pydantic.SecretStr; typed SDK config (TLPLevel, ListFromString);
    structured logging; CIS-hardened compose; non-root python:3.12-alpine image.
  • Unit tests for settings, API client, converter, and orchestration; pyproject.toml coverage
    config. black / isort --profile black / flake8 --ignore=E,W clean.
  • Validated end-to-end against OpenCTI 7.260529.0 (pycti==7.260529.0,
    connectors-sdk @7.260529.0, support_version ">=7.260529.0").

Related issues

Checklist

  • I consider the submitted work as finished
  • I have signed my commits using GPG key.
  • I tested the code for its functionality using different use cases
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

Scope is intentionally limited to IPv4-Addr and StixFile: Metras has no value-filterable
lookup for domains/URLs (the /v4/threats/detail endpoint requires incident identifiers, not a
single observable value), so enriching those types is not possible with the current API.

Copilot AI review requested due to automatic review settings July 17, 2026 18:56
@Filigran-Automation Filigran-Automation added the community Contribution from the community. label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Metras INTERNAL_ENRICHMENT connector under internal-enrichment/metras/ to enrich IPv4-Addr and StixFile observables with “fleet presence” context from the Metras EDR API, emitting Notes and optional System identities + related-to relationships.

Changes:

  • Introduces the connector runtime (settings model, Metras API client with retries, enrichment orchestration, and STIX conversion).
  • Adds containerization + deployment artifacts (Dockerfile, compose, entrypoint, sample config, metadata/manifest, versioning).
  • Adds a unit test suite for settings, API client, orchestration, and utils (but no converter-specific tests despite the PR description stating otherwise).

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal-enrichment/metras/VERSION Declares connector version.
internal-enrichment/metras/src/requirements.txt Pins runtime dependencies (pycti, stix2, requests, connectors-sdk).
internal-enrichment/metras/src/main.py Connector entrypoint wiring settings → helper → connector run loop.
internal-enrichment/metras/src/connector/init.py Exposes main connector classes for imports.
internal-enrichment/metras/src/connector/settings.py Pydantic/SDK-based configuration models (connector + Metras settings).
internal-enrichment/metras/src/connector/utils.py Refang + basic validators used by connector/tests.
internal-enrichment/metras/src/connector/converter_to_stix.py Builds deterministic STIX Note/Identity/Relationship outputs.
internal-enrichment/metras/src/connector/connector.py Enrichment orchestration (scope/TLP gate, lookups, bundle send).
internal-enrichment/metras/src/metras_client/init.py Exports client + error type.
internal-enrichment/metras/src/metras_client/api_client.py HTTP client wrapper for Metras API endpoints + retry strategy.
internal-enrichment/metras/tests/test-requirements.txt Test dependency entrypoint for isolated test runs.
internal-enrichment/metras/tests/conftest.py Adds src/ to import path for tests.
internal-enrichment/metras/tests/test_main.py Unit tests for utils (refang/validators).
internal-enrichment/metras/tests/test_connector/test_settings.py Unit tests for settings/config model behavior.
internal-enrichment/metras/tests/test_connector/test_client.py Unit tests for HTTP client behaviors (mocked session).
internal-enrichment/metras/tests/test_connector/test_orchestration.py Unit tests for enrichment orchestration (mocked helper/client).
internal-enrichment/metras/README.md Connector documentation (scope, behavior, configuration, usage).
internal-enrichment/metras/pyproject.toml Coverage configuration for connector packages.
internal-enrichment/metras/entrypoint.sh Container entrypoint script.
internal-enrichment/metras/Dockerfile Container build (Alpine Python 3.12, non-root user).
internal-enrichment/metras/docker-compose.yml Hardened compose example for running the connector.
internal-enrichment/metras/config.yml.sample Sample YAML config for local/manual runs.
internal-enrichment/metras/.dockerignore Docker build context exclusions.
internal-enrichment/metras/metadata/connector_manifest.json Connector manifest metadata for OpenCTI ecosystem.

Comment on lines +9 to +13
def refang(value: str) -> str:
"""Remove common defanging so values match the external API."""
if not value:
return value
v = value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

Comment on lines +180 to +182
names = ", ".join(
sorted({a.get("alert_name", "?") for a in alert_data})[:10]
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

Comment on lines +200 to +203
notes.append(
f"Matches {len(endpoints)} fleet endpoint(s): "
+ ", ".join(e.get("name", "?") for e in endpoints[:10])
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

Comment on lines +16 to +20
class ConverterToStix:
def __init__(self, helper: OpenCTIConnectorHelper) -> None:
self.helper = helper
self.author = self._create_author()
self._confidence = getattr(helper, "connect_confidence_level", None) or 50

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

@Khidr6G Khidr6G changed the title feat(metras): add Metras internal-enrichment connector for fleet-presence lookups (#7038) feat(metras): add Metras internal-enrichment connector for fleet-presence lookups (#7042) Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Contribution from the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(metras): Add Metras EDR connector suite (external-import, internal-enrichment, stream)

4 participants