UNPKG

@mitre-attack/attack-data-model

Version:

A TypeScript API for the MITRE ATT&CK data model

142 lines (139 loc) 5.93 kB
import { z } from 'zod'; import { Aliases, XMitreDomains, KillChainPhase } from '../schemas/common/common-properties.cjs'; import { ExternalReferences } from '../schemas/common/misc.cjs'; import { XMitreFirstSeenCitation, XMitreLastSeenCitation } from '../schemas/sdo/campaign.schema.cjs'; import { StixBundle } from '../schemas/sdo/stix-bundle.schema.cjs'; import { Technique, XMitreIsSubtechnique, XMitrePermissionsRequired, XMitreEffectivePermissions, XMitreSystemRequirements, XMitreDefenseBypasses, XMitreRemoteSupport, XMitreImpactType, XMitreDataSources, XMitreTacticType } from '../schemas/sdo/technique.schema.cjs'; import '../schemas/common/stix-identifier.cjs'; import '../schemas/common/stix-type.cjs'; import '../schemas/common/attack-id.cjs'; import '../schemas/sdo/malware.schema.cjs'; import '../schemas/sdo/asset.schema.cjs'; import '../schemas/sdo/data-component.schema.cjs'; import '../schemas/sdo/data-source.schema.cjs'; import '../schemas/sdo/identity.schema.cjs'; import '../schemas/sdo/matrix.schema.cjs'; import '../schemas/sdo/tool.schema.cjs'; import '../schemas/sdo/tactic.schema.cjs'; import '../schemas/sdo/group.schema.cjs'; import '../schemas/sdo/mitigation.schema.cjs'; import '../schemas/sdo/collection.schema.cjs'; import '../schemas/sro/relationship.schema.cjs'; import '../schemas/smo/marking-definition.schema.cjs'; /** * Creates a refinement for validating that the first alias matches the object's name * * @param schema The object to validate * @param ctx The Zod refinement context * * @returns A superRefine 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 = createFirstAliasNameMatchRefinement(); * const schema = baseSchema.superRefine(validateFirstAlias); * ``` */ declare function createFirstAliasRefinement(): (schema: { aliases?: Aliases; name: string; }, ctx: z.RefinementCtx) => 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 = createFirstXMitreAliasValidator(); * const schema = extensibleSchema.superRefine(validateFirstXMitreAlias); * ``` */ declare function createFirstXMitreAliasRefinement(): (schema: { x_mitre_aliases?: string[]; name: string; }, ctx: z.RefinementCtx) => void; /** * Creates a refinement for validating citation formats and references * * @param schema The object to validate * @param ctx The Zod refinement context * * @returns A superRefine 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 = createCitationRefinement(); * const schema = baseSchema.superRefine(validateCitations); * ``` */ declare function createCitationsRefinement(): (schema: { external_references: ExternalReferences; x_mitre_first_seen_citation?: XMitreFirstSeenCitation; x_mitre_last_seen_citation?: XMitreLastSeenCitation; }, ctx: z.RefinementCtx) => 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 = createFirstBundleObjectValidator(); * const schema = extensibleStixBundleSchema.superRefine(validateFirstBundleObject); * ``` */ declare function createFirstBundleObjectRefinement(): (schema: StixBundle, ctx: z.RefinementCtx) => 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(): (schema: Technique | { external_references: ExternalReferences; x_mitre_is_subtechnique: XMitreIsSubtechnique; }, ctx: z.RefinementCtx) => void; /** * Creates a refinement function for validating enterprise-only properties of techniques * * @returns A refinement function for enterprise-only property validation */ declare function createEnterpriseOnlyPropertiesRefinement(): (schema: 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; }, ctx: z.RefinementCtx) => void; /** * Creates a refinement function for validating mobile-only properties of techniques * * @returns A refinement function for mobile-only property validation */ declare function createMobileOnlyPropertiesRefinement(): (schema: Technique | { x_mitre_domains: XMitreDomains; x_mitre_tactic_type?: XMitreTacticType; x_mitre_data_sources?: XMitreDataSources; }, ctx: z.RefinementCtx) => void; export { createAttackIdInExternalReferencesRefinement, createCitationsRefinement, createEnterpriseOnlyPropertiesRefinement, createFirstAliasRefinement, createFirstBundleObjectRefinement, createFirstXMitreAliasRefinement, createMobileOnlyPropertiesRefinement };