Skip to content

feat(usta): complete manager-supported catalog migration (#7656) - #7703

Open
Hugo Dupras (jabesq) wants to merge 6 commits into
masterfrom
feat/7656-usta-catalog
Open

Hugo Dupras (jabesq) wants to merge 6 commits into
masterfrom
feat/7656-usta-catalog

Conversation

@jabesq

Copy link
Copy Markdown
Member

Proposed changes

  • Replace ~70 lines of hand-rolled configuration boilerplate with the canonical connectors-sdk base classes. settings.py carried its own private copies of BaseConfigModel, _OpenCTIConfig, _BaseConnectorConfig, BaseExternalImportConnectorConfig, BaseConnectorSettings and to_helper_config(). Duplicated base classes drift from the SDK over time and each connector then fixes the same bug independently, so these now import from connectors-sdk. Field names, types, defaults and environment variable names are preserved 1:1 — this is a no-behaviour-change refactor apart from the security fix below.
  • Security fix: stop leaking USTA_API_KEY into the helper config. The removed hand-rolled @field_serializer("api_key") called .get_secret_value() during model_dump(), which defeated the whole point of SecretStr and pushed the plaintext API key into the dict handed to OpenCTIConnectorHelper — where it could surface in helper state and debug output. The SDK's SecretStr handling redacts it instead, while connector.py continues to read the real token via .get_secret_value() at the call site where it is actually needed. This is the most reviewer-relevant change in the PR.
  • Move connector.scope to the SDK ListFromString type. The scope is semantically a list, and modelling it as one lets the generated config schema describe it correctly for the connector catalog. The values are identical and pycti still receives the comma-joined string, so deployed behaviour is unchanged.
  • Add the missing connectors-sdk dependency to src/requirements.txt. Without it the config-schema generator refuses to run, so the connector could never be onboarded into the catalog.
  • Add src/__init__.py re-exporting ConnectorSettings. The schema generator imports the settings class from the package root; this matches the layout already used by cybelangel, elastic-security-incidents and alienvault.
  • Give connector.id a repo-unique UUIDv4 default. Catalog deployment has no opportunity to inject a CONNECTOR_ID, so a required-with-no-default field made the connector undeployable from the catalog. CONNECTOR_ID=ChangeMe is deliberately kept in docker-compose.yml and .env.sample: operators running multiple USTA instances must still override it to avoid two connectors sharing an identity, and the README now says so explicitly.
  • Mark the connector as manager_supported: true in __metadata__/connector_manifest.json and commit the generated connector_config_schema.json and CONNECTOR_CONFIG_DOC.md, which together form the machine-readable contract the OpenCTI connector manager consumes.
  • Normalize the config files. .env.sample is regrouped into REQUIRED / OPTIONAL blocks with the optional variables commented out, so settings.py remains the single source of truth for defaults rather than having the same value restated — and silently diverging — in three places. The README configuration table is updated to match, including the newly documented connector.scope and connector.log_level rows.
  • Extend the test suite. All existing tests are kept; added SDK-style settings coverage for valid full and minimal input, invalid-input cases raising ConfigValidationError, an assertion on the connector.id default, a test_api_key_is_a_secret regression test pinning the redaction fix, and a to_helper_config() pycti-compatibility test. 222 tests pass.

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

This is a deliberately structure-preserving pass: file structure, file names, class names, logging and the schedule_process / duration_period scheduling mechanism are all unchanged, which keeps the diff reviewable and lets the API-key redaction fix land without being buried in a restructuring. USTA was already partially migrated on master (a Pydantic settings.py existed and main.py already wired ConnectorSettings()to_helper_config()), but it was not actually catalog-ready — this branch finishes that job.

The connector is now manager-supported but not yet "verified": package restructuring, the logging refactor and the STIX-ID determinism review are intentionally left for a separate pass.

Validation run locally: isort + black clean, flake8 --ignore=E,W clean, 222/222 tests passing on Python 3.12, the custom STIX-ID pylint plugin rated 10.00/10, and mise gs external-import/usta reproduces the committed schema and config doc with no diff.

Copilot AI lite review requested due to automatic review settings September 16, 2026 13:43
@jabesq Hugo Dupras (jabesq) added the filigran team Item from the Filigran team. label Sep 16, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unused dependencies detected

The following packages appear to be unused:

  • pydantic_settings in external-import/usta/src/requirements.txt

How to fix: (1) if the package is used but under a different import name (e.g. PyYAMLyaml), add a mapping line to .github/deptry-package-map.txt. (2) if truly unused, remove it from the connector's requirements.txt.

@github-actions

Copy link
Copy Markdown

🔴 Connector Linter errors detected

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

Migrates USTA to the canonical connectors-sdk configuration and OpenCTI connector catalog format, including secure API-key handling and generated metadata.

Changes:

  • Replaced local configuration models with SDK equivalents.
  • Added catalog metadata, schema, documentation, and manager support.
  • Added validation, secret-redaction, and helper compatibility tests.
  • Updated deployment configuration and documentation.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Summary
external-import/usta/tests/test_main.py Added integration and helper compatibility coverage.
external-import/usta/tests/test_connector/test_settings.py Added settings validation and secret-redaction tests.
external-import/usta/src/requirements.txt Added the connectors-sdk dependency.
external-import/usta/src/connector/settings.py Migrated settings to SDK models with secure secret handling.
external-import/usta/src/__init__.py Re-exported ConnectorSettings.
external-import/usta/README.md Updated configuration and deployment documentation.
external-import/usta/docker-compose.yml Preserved deployment environment settings.
external-import/usta/.env.sample Organized configuration variables; CONNECTOR_LOG_LEVEL remains active despite the optional block.
external-import/usta/__metadata__/connector_manifest.json Enabled manager support.
external-import/usta/__metadata__/connector_config_schema.json Added generated catalog schema.
external-import/usta/__metadata__/CONNECTOR_CONFIG_DOC.md Added generated configuration documentation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +8 to +10
# Connector parameters - OPTIONAL (default values are defined in src/connector/settings.py)
# CONNECTOR_NAME=USTA
# CONNECTOR_SCOPE=indicator,observable,malware,identity,incident,user-account,report,threat-actor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team Item from the Filigran team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(prodaft-usta): migrate connector to the catalog

3 participants