UNPKG

@mitre-attack/attack-data-model

Version:

A TypeScript API for the MITRE ATT&CK data model

66 lines (63 loc) 1.92 kB
import { attackBaseDomainObjectSchema } from "./chunk-ZQ5CIHH7.js"; import { xMitreDomainsSchema, xMitreModifiedByRefSchema } from "./chunk-Z7F5EWOT.js"; import { createAttackExternalReferencesSchema } from "./chunk-QY7EQ3UO.js"; import { createStixIdValidator } from "./chunk-OM2DJ5DL.js"; import { createStixTypeValidator } from "./chunk-5JU73PGM.js"; // src/schemas/sdo/log-source.schema.ts import { z } from "zod/v4"; var xMitreLogSourcePermutationsSchema = z.array( z.object({ name: z.string().nonempty(), channel: z.string().nonempty() }) ).nonempty().refine( // Reject duplicate (name, channel) pairs // Allow same name with different channels // Allow same channel with different names (permutations) => { const seen = /* @__PURE__ */ new Set(); for (const perm of permutations) { const key = `${perm.name}|${perm.channel}`; if (seen.has(key)) { return false; } seen.add(key); } return true; }, { message: "Duplicate log source permutation found: each (name, channel) pair must be unique", path: ["x_mitre_log_source_permutations"] } ); var extensibleLogSourceSchema = attackBaseDomainObjectSchema.extend({ id: createStixIdValidator("x-mitre-log-source"), type: createStixTypeValidator("x-mitre-log-source"), // Optional in STIX but required in ATT&CK external_references: createAttackExternalReferencesSchema("x-mitre-log-source"), x_mitre_domains: xMitreDomainsSchema, x_mitre_modified_by_ref: xMitreModifiedByRefSchema, x_mitre_log_source_permutations: xMitreLogSourcePermutationsSchema }).required({ object_marking_refs: true, // Optional in STIX but required in ATT&CK created_by_ref: true // Optional in STIX but required in ATT&CK }).strict(); var logSourceSchema = extensibleLogSourceSchema; export { xMitreLogSourcePermutationsSchema, extensibleLogSourceSchema, logSourceSchema };