Add GET /system/types: dynamic list of every creatable object type - #1341
Merged
Conversation
Fixes #1254 and the root cause of #1260. Observable/entity/indicator types are each defined via a static TYPE_MAPPING registry (core/schemas/{observable,entity,indicator}.py) that a CI test already guarantees is complete relative to what's on disk -- but the frontend maintains its own hand-written, independently-drifting type list for each family, which is what let ja3/jarm/mutex/named_pipe/package silently go missing from the "New Observable" dropdown despite being fully supported types. Derives the response directly from each family's TYPE_MAPPING (plus DFIQ's, for shape-parity with the paired frontend change) rather than hand-listing types again in a third place, so it can't drift the same way and automatically picks up plugin-registered private/custom types for free. Labels are hardcoded to match the frontend's existing display strings exactly (verified against src/definitions/*.ts) for the already -known types, falling back to a formatted version of the type string for anything new. Paired with a frontend PR (yeti-feeds-frontend#304) that already expects exactly this endpoint and response shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TYPE_MAPPINGregistry (core/schemas/{observable,entity,indicator}.py), which a CI test (tests/schemas/registry.py) already guarantees is complete relative to what's actually on disk -- but the frontend maintains its own hand-written, independently-drifting type list per family, which is exactly what letja3/jarm/mutex/named_pipe/packagesilently go missing from the "New Observable" dropdown despite being fully supported.GET /system/typesderives its response directly from each family'sTYPE_MAPPING(plus DFIQ's, for shape parity with the paired frontend PR) instead of hand-listing types a third time, so it can't drift the same way, and automatically includes plugin-registered private/custom types (core/schemas/loader.py'sload_private_types) for free -- directly answers the "how would you handle custom observables?" question raised in Add API endpoint that returns available object types #1254's linked discussion.src/definitions/*.ts) for every already-known type, falling back to a formatted version of the type string (type.replace(...).title()) for anything new -- verified this fallback produces sensible output for the two entity types the frontend doesn't currently expose at all (note,phone)./workers, not/config-- this isn't needed pre-login).Paired with yeti-feeds-frontend#304, which already expects exactly this endpoint and response shape (
{observables, entities, indicators, dfiq}, each a list of{type, label}).Test plan
tests/apiv2/system.py: response shape, all 5 previously-missing observable types present, base-type aliases (observable/observables/dfiq) don't leak into entries, indicator set matches exactly, every entry has a non-empty label, 401 without authtests/apiv2/system.py+tests/schemas/observable.py+tests/schemas/entity.py+tests/schemas/indicator.py+tests/apiv2/dfiq.py-- 127/127 passruff check/format --checkclean;ty checkclean (fixed one real finding:dict's invariant value type rejected passingdict[str, type[Observable]]wheredict[str, type]was declared -- switched tocollections.abc.Mapping, which is covariant)