$ show MaltegoTech/maltego-trx
maltego-trx is the legacy Python SDK for building Maltego transforms (the OSINT/graph investigation platform), now explicitly archived and superseded by the actively maintained maltego-transforms SDK. In production it runs as a Flask HTTP server: the Maltego desktop client POSTs an XML transform request to /run/<transform_name>/, the server parses it into a MaltegoMsg, dispatches to a registered transform class, and serializes the resulting MaltegoTransform response back as XML. Transform classes are auto-discovered from the project's local `transforms` package (class name must match the filename and subclass DiscoverableTransform). The package also ships a CLI (`maltego-trx start`/`init`) that scaffolds new transform projects from a template directory, plus a project-level CLI (`project.py runserver/list/local`) implemented in handler.py.
The LLM identified 4 files worth highlighting for reuse:
Self-contained generic utility module with zero internal imports. Standouts: export_as_csv splits large config exports into multiple files to stay under TDS import line limits; chunk_list even-splits sequences into balanced chunks; filter_unique deduplicates by arbitrary key; escape_csv_fields safely quotes separator-containing fields; serialize_xml produces canonical, deterministic XML via ElementTree across Python versions. Easily extractable into any Python project.
Decorator-driven TransformRegistry that collects transform metadata at class-definition time and projects it into multiple export formats: TDS import CSVs (with automatic chunking to respect import line limits) and Maltego local .mtz archives. Built on dataclasses, generator pipelines, and setting deduplication. The decorator-registry to multi-format-exporter pattern is cleanly encapsulated and adaptable to other metadata-driven config generation problems.
Authoritative implementation of the XML schema for Maltego .mtz local-transform packages: local server .tas files, per-transform .transform definitions, .transformsettings, and transform sets. Purely stdlib (ElementTree, datetime) with zero internal imports. Encodes non-obvious domain knowledge of the exact attribute sets the Maltego desktop client requires, in a clean builder-function API that can be reused in any tool that generates local transform configs.
MaltegoOauth.decrypt_secrets decrypts TDS-issued OAuth secret blobs containing token, token_secret, refresh_token, and expires_in fields, selecting RSA-PKCS1v15 vs AES-ECB/PKCS7 decryption based on the number of $-separated ciphertext parts. Also provides OAuth2BearerToken, a requests AuthBase. Isolated crypto helper with only external (cryptography, requests) imports, directly reusable in other Maltego/TDS integrations.