Skip to content

feat(contracts): asset group reference and tags contract fields for external injectors #389

Done

Description

Symptom

An external (Python) injector that needs a parameter pointing at an existing asset group or at tags can only declare a ContractText field. The user pastes a raw UUID in the inject form, nothing validates it, and a wrong id only surfaces at execution (for example "asset group update failed" in the execution message). Seen on the DNS enumeration injector (dns-enum, contract "DNS / subdomain enumeration"): "Asset group ID to add the created endpoints to (optional)" and "Tags set on the created endpoints" are both free text.

What the platform already offers (read at OpenAEV-Platform/openaev main, after #9747, merged 25 Nov 2026)

  • openaev-framework/.../injector_contract/fields/ContractFieldType.java: AssetGroupReference("asset-group-reference") and Tags("tags").
  • ContractAssetGroupReference(key, label, cardinality): searchable asset group picker; the selected id (cardinality one) or list of ids (cardinality multiple) is stored in inject_content under the field key; no targeting, no expectation on the group's assets; several such fields per contract allowed.
  • ContractTags(key, label): tag picker, always multiple, stores the selected tag ids in inject_content under the field key.
  • The front renders and validates both (AssetGroupReferenceFieldController, TagFieldController, getValidatingRule).

Cause (read at client-python main)

pyoaev/contracts/contract_config.py:

  • class ContractFieldType(str, Enum) has no AssetGroupReference / Tags member.
  • No element dataclass exists for them. The only asset group element, ContractAssetGroup, is the targeting field (key fixed to ContractFieldKey.AssetGroup = asset_groups, stored in the inject targets, expectations computed on its assets), so it is not a fit for a parameter.

Proposed fix

  1. ContractFieldType: add AssetGroupReference: str = "asset-group-reference" and Tags: str = "tags" (labels identical to the Java enum).
  2. Add, next to ContractAssetGroup:
    • @dataclass class ContractAssetGroupReference(ContractCardinalityElement): free-form key, get_type returns ContractFieldType.AssetGroupReference.value.
    • @dataclass class ContractTags(ContractCardinalityElement): free-form key, cardinality forced to ContractCardinality.Multiple in __post_init__ (as ContractTuple does), get_type returns ContractFieldType.Tags.value.
  3. Export both from pyoaev.contracts.contract_config like the other elements.

Acceptance tests

  • ContractAssetGroupReference(key="asset_group_id", label="...", cardinality=ContractCardinality.One) serialises (through prepare_contracts / EnhancedJSONEncoder) with "type": "asset-group-reference", the given key and cardinality 1.
  • ContractTags(key="endpoint_tags", label="...") serialises with "type": "tags" and cardinality n, whatever cardinality is passed.
  • ContractAssetGroup is unchanged (key asset_groups, type asset-group).
  • A contract carrying both registers on a platform built after openaev #9747 and the inject form shows an asset group picker and a tag picker; the saved inject_content holds the id / list of ids under the field keys.

Follow-up once released (OpenAEV-Platform/injectors, dns-enum)

  • dns_enum_contracts.py: asset_group_id becomes ContractAssetGroupReference(..., cardinality=One).
  • Tags: the field today takes tag NAMES (upserted, default discovered:dns, parse_tags in models/data.py); a ContractTags field stores tag IDS. The injector must then accept ids (resolve them, keep accepting names for existing injects) before the field type changes.
  • Requires the pyoaev release carrying this change, pinned in the injector.

Impact

UX and input validation for every external injector that references existing asset groups or tags; no wrong result today beyond a failed group update when a bad id is pasted.

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

Metadata

Metadata

Labels

featureharness-gapneeds triagesolved

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions