UNPKG

@mitre-attack/attack-data-model

Version:

A TypeScript API for the MITRE ATT&CK data model

148 lines (145 loc) 6.29 kB
import { z } from 'zod/v4'; import { Aliases, XMitreDomains, KillChainPhase } from '../schemas/common/common-properties.js'; import { ExternalReferences } from '../schemas/common/misc.js'; import { XMitreFirstSeenCitation, XMitreLastSeenCitation } from '../schemas/sdo/campaign.schema.js'; import { Technique, XMitreIsSubtechnique, XMitrePermissionsRequired, XMitreEffectivePermissions, XMitreSystemRequirements, XMitreDefenseBypasses, XMitreRemoteSupport, XMitreImpactType, XMitreDataSources, XMitreTacticType } from '../schemas/sdo/technique.schema.js'; import { StixBundle } from '../schemas/sdo/stix-bundle.schema.js'; import { Relationship, RelationshipType } from '../schemas/sro/relationship.schema.js'; import '../schemas/common/stix-identifier.js'; import '../schemas/common/stix-type.js'; import '../schemas/common/attack-id.js'; import '../schemas/sdo/malware.schema.js'; import '../schemas/sdo/asset.schema.js'; import '../schemas/sdo/data-component.schema.js'; import '../schemas/sdo/log-source.schema.js'; import '../schemas/sdo/data-source.schema.js'; import '../schemas/sdo/identity.schema.js'; import '../schemas/sdo/matrix.schema.js'; import '../schemas/sdo/tool.schema.js'; import '../schemas/sdo/tactic.schema.js'; import '../schemas/sdo/group.schema.js'; import '../schemas/sdo/mitigation.schema.js'; import '../schemas/sdo/collection.schema.js'; import '../schemas/sdo/detection-strategy.schema.js'; import '../schemas/sdo/analytic.schema.js'; import '../schemas/smo/marking-definition.schema.js'; /** * Creates a refinement for validating that the first alias matches the object's name * * @returns A refinement callback function for alias validation * * @remarks * This function is used to validate that when aliases are present, the first * alias must match the object's name. * * @example * ```typescript * const validateFirstAlias = createFirstAliasRefinement(); * const schema = baseSchema.superRefine(validateFirstAlias); * ``` */ declare function createFirstAliasRefinement(): (ctx: z.core.ParsePayload<{ aliases?: Aliases; name: string; }>) => void; /** * Creates a refinement function for validating that the first x_mitre_alias matches the object's name * * @returns A refinement function for x_mitre_alias validation * * @remarks * This function validates that when x_mitre_aliases are present, the first * alias must match the object's name. * * @example * ```typescript * const validateFirstXMitreAlias = createFirstXMitreAliasRefinement(); * const schema = extensibleSchema.superRefine(validateFirstXMitreAlias); * ``` */ declare function createFirstXMitreAliasRefinement(): (ctx: z.core.ParsePayload<{ x_mitre_aliases?: string[]; name: string; }>) => void; /** * Creates a refinement for validating citation formats and references * * @returns A refinement callback function for citation validation * * @remarks * This function validates that citation strings follow the correct format * and that all cited sources exist in the external_references. * * @example * ```typescript * const validateCitations = createCitationsRefinement(); * const schema = baseSchema.superRefine(validateCitations); * ``` */ declare function createCitationsRefinement(): (ctx: z.core.ParsePayload<{ external_references: ExternalReferences; x_mitre_first_seen_citation?: XMitreFirstSeenCitation; x_mitre_last_seen_citation?: XMitreLastSeenCitation; }>) => void; /** * Creates a refinement function for validating that the first object in a STIX bundle * is of type 'x-mitre-collection' * * @returns A refinement function for STIX bundle validation * * @remarks * This function validates that the first object in the 'objects' array of a STIX bundle * is of type 'x-mitre-collection', which is required for ATT&CK bundles. * * @example * ```typescript * const validateFirstBundleObject = createFirstBundleObjectRefinement(); * const schema = extensibleStixBundleSchema.superRefine(validateFirstBundleObject); * ``` */ declare function createFirstBundleObjectRefinement(): (ctx: z.core.ParsePayload<StixBundle>) => void; /** * Creates a refinement function for validating ATT&CK ID in external references * * @returns A refinement function for ATT&CK ID validation */ declare function createAttackIdInExternalReferencesRefinement(): (ctx: z.core.ParsePayload<Technique | { external_references: ExternalReferences; x_mitre_is_subtechnique: XMitreIsSubtechnique; }>) => void; /** * Creates a refinement function for validating enterprise-only properties of techniques * * @returns A refinement function for enterprise-only property validation */ declare function createEnterpriseOnlyPropertiesRefinement(): (ctx: z.core.ParsePayload<Technique | { x_mitre_domains: XMitreDomains; kill_chain_phases?: KillChainPhase[]; x_mitre_permissions_required?: XMitrePermissionsRequired; x_mitre_effective_permissions?: XMitreEffectivePermissions; x_mitre_system_requirements?: XMitreSystemRequirements; x_mitre_defense_bypassed?: XMitreDefenseBypasses; x_mitre_remote_support?: XMitreRemoteSupport; x_mitre_impact_type?: XMitreImpactType; x_mitre_data_sources?: XMitreDataSources; }>) => void; /** * Creates a refinement function for validating mobile-only properties of techniques * * @returns A refinement function for mobile-only property validation */ declare function createMobileOnlyPropertiesRefinement(): (ctx: z.core.ParsePayload<Technique | { x_mitre_domains: XMitreDomains; x_mitre_tactic_type?: XMitreTacticType; x_mitre_data_sources?: XMitreDataSources; }>) => void; /** * Creates a refinement function for validating 'found-in' relationships * * @returns A refinement function for 'found-in' relationship validation */ declare function createFoundInRelationshipRefinement(): (ctx: z.core.ParsePayload<Relationship | { relationship_type: RelationshipType; x_mitre_log_source_channel?: z.ZodString; }>) => void; export { createAttackIdInExternalReferencesRefinement, createCitationsRefinement, createEnterpriseOnlyPropertiesRefinement, createFirstAliasRefinement, createFirstBundleObjectRefinement, createFirstXMitreAliasRefinement, createFoundInRelationshipRefinement, createMobileOnlyPropertiesRefinement };