@mitre-attack/attack-data-model
Version:
A TypeScript API for the MITRE ATT&CK data model
1,244 lines (1,215 loc) • 88.7 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/refinements/index.ts
var refinements_exports = {};
__export(refinements_exports, {
createAttackIdInExternalReferencesRefinement: () => createAttackIdInExternalReferencesRefinement,
createCitationsRefinement: () => createCitationsRefinement,
createEnterpriseOnlyPropertiesRefinement: () => createEnterpriseOnlyPropertiesRefinement,
createFirstAliasRefinement: () => createFirstAliasRefinement,
createFirstBundleObjectRefinement: () => createFirstBundleObjectRefinement,
createFirstXMitreAliasRefinement: () => createFirstXMitreAliasRefinement,
createFoundInRelationshipRefinement: () => createFoundInRelationshipRefinement,
createMobileOnlyPropertiesRefinement: () => createMobileOnlyPropertiesRefinement
});
module.exports = __toCommonJS(refinements_exports);
var import_v432 = require("zod/v4");
// src/schemas/common/attack-base-object.ts
var import_v410 = require("zod/v4");
// src/schemas/common/stix-core.ts
var import_v49 = require("zod/v4");
// src/schemas/common/stix-identifier.ts
var import_v42 = require("zod/v4");
// src/schemas/common/stix-type.ts
var import_v4 = require("zod/v4");
var stixTypeToTypeName = {
"attack-pattern": "Technique",
bundle: "StixBundle",
campaign: "Campaign",
"course-of-action": "Mitigation",
"extension-definition": null,
identity: "Identity",
"intrusion-set": "Group",
malware: "Malware",
tool: "Tool",
"marking-definition": "MarkingDefinition",
"x-mitre-analytic": "Analytic",
"x-mitre-data-component": "DataComponent",
"x-mitre-detection-strategy": "DetectionStrategy",
"x-mitre-data-source": "DataSource",
"x-mitre-log-source": "LogSource",
"x-mitre-tactic": "Tactic",
"x-mitre-asset": "Asset",
"x-mitre-matrix": "Matrix",
"x-mitre-collection": "Collection",
relationship: "Relationship",
file: "",
// not used in ATT&CK but used in sample_refs for Malware
artifact: ""
// not used in ATT&CK but used in sample_refs for Malware
// 'observed-data': 'ObservedData', // not used in ATT&CK
// 'report': 'Report', // not used in ATT&CK
// 'threat-actor': 'ThreatActor', // not used in ATT&CK
// 'vulnerability': 'Vulnerability', // not used in ATT&CK
};
var supportedStixTypes = [
"attack-pattern",
"bundle",
"campaign",
"course-of-action",
"extension-definition",
"identity",
"intrusion-set",
"malware",
"tool",
"marking-definition",
"x-mitre-analytic",
"x-mitre-data-component",
"x-mitre-detection-strategy",
"x-mitre-tactic",
"x-mitre-asset",
"x-mitre-data-source",
"x-mitre-log-source",
"x-mitre-matrix",
"x-mitre-collection",
"relationship",
"file",
// not used in ATT&CK but used in sample_refs for Malware
"artifact"
// not used in ATT&CK but used in sample_refs for Malware
// "indicator", // not used in ATT&CK
// "observed-data", // not used in ATT&CK
// "report", // not used in ATT&CK
// "threat-actor", // not used in ATT&CK
// "vulnerability", // not used in ATT&CK
];
var stixTypeSchema = import_v4.z.enum(supportedStixTypes, {
error: (issue) => {
if (issue.code === "invalid_value") {
const received = typeof issue.input === "string" ? issue.input : String(issue.input);
return `Invalid STIX type '${received}'. Expected one of the supported STIX types.`;
}
return void 0;
}
}).meta({
description: "The type property identifies the type of STIX Object (SDO, Relationship Object, etc). The value of the type field MUST be one of the types defined by a STIX Object (e.g., indicator)."
});
function createStixTypeValidator(stixType) {
const objectName = stixTypeToTypeName[stixType];
return import_v4.z.literal(stixType).refine((val) => val === stixType, {
error: (issue) => `Invalid 'type' property. Expected '${stixType}' for ${objectName} object, but received '${issue.input}'.`
});
}
function createMultiStixTypeValidator(stixTypes) {
const objectNames = stixTypes.map((type) => stixTypeToTypeName[type]).join(" or ");
const typeList = stixTypes.map((t) => `'${t}'`).join(" or ");
const literals = stixTypes.map((type) => import_v4.z.literal(type));
return import_v4.z.union(literals).refine((val) => stixTypes.includes(val), {
error: (issue) => `Invalid 'type' property. Expected ${typeList} for ${objectNames} object, but received '${issue.input}'.`
});
}
// src/schemas/common/stix-identifier.ts
var stixIdentifierSchema = import_v42.z.string().refine((val) => val.includes("--") && val.split("--").length === 2, {
error: (issue) => ({
code: "custom",
message: "Invalid STIX Identifier: must comply with format 'type--UUIDv4'",
input: issue.input,
path: []
})
}).refine(
(val) => {
const [type] = val.split("--");
return stixTypeSchema.safeParse(type).success;
},
{
error: (issue) => {
const val = issue.input;
const [type] = val.split("--");
const typeName = type in stixTypeToTypeName ? stixTypeToTypeName[type] : "STIX";
return {
code: "custom",
message: `Invalid STIX Identifier for ${typeName} object: contains invalid STIX type '${type}'`,
input: issue.input,
path: []
};
}
}
).refine(
(val) => {
const [, uuid] = val.split("--");
return import_v42.z.uuid().safeParse(uuid).success;
},
{
error: (issue) => {
const val = issue.input;
const [type] = val.split("--");
const typeName = type in stixTypeToTypeName ? stixTypeToTypeName[type] : "STIX";
return {
code: "custom",
message: `Invalid STIX Identifier for ${typeName} object: contains invalid UUIDv4 format`,
input: issue.input,
path: []
};
}
}
).meta({
description: "Represents identifiers across the CTI specifications. The format consists of the name of the top-level object being identified, followed by two dashes (--), followed by a UUIDv4."
});
function createStixIdValidator(expectedType) {
return stixIdentifierSchema.refine(
(val) => val.startsWith(`${expectedType}--`),
{
error: () => ({
code: "custom",
message: `Invalid STIX Identifier: must start with '${expectedType}--'`,
input: expectedType,
path: []
})
}
);
}
// src/schemas/common/stix-spec-version.ts
var import_v43 = require("zod/v4");
var specVersionDescription = [
"The version of the STIX specification used to represent this object.",
"The value of this property MUST be 2.1 for STIX Objects defined according to this specification.",
"If objects are found where this property is not present, the implicit value for all STIX Objects other than SCOs is 2.0.",
"Since SCOs are now top-level objects in STIX 2.1, the default value for SCOs is 2.1."
].join(" ");
var stixSpecVersionSchema = import_v43.z.enum(["2.0", "2.1"]).meta({ description: specVersionDescription });
// src/schemas/common/stix-timestamp.ts
var import_v44 = require("zod/v4");
var stixTimestampSchema = import_v44.z.iso.datetime({
error: "Invalid STIX timestamp format: must be an RFC3339 timestamp with a timezone specification of 'Z'."
}).refine((val) => val.endsWith("Z"), {
message: "STIX timestamps must use 'Z' timezone specification"
}).meta({
description: "Represents timestamps across the CTI specifications. The format is an RFC3339 timestamp, with a required timezone specification of 'Z'."
});
var stixCreatedTimestampSchema = stixTimestampSchema.brand();
var stixModifiedTimestampSchema = stixTimestampSchema.brand();
// src/schemas/common/misc.ts
var import_v46 = require("zod/v4");
// src/schemas/common/attack-id.ts
var import_v45 = require("zod/v4");
var attackIdConfig = {
tactic: {
pattern: /^TA\d{4}$/,
message: "Must match ATT&CK Tactic ID format (TA####)",
example: "TA####",
stixTypes: ["x-mitre-tactic"]
},
technique: {
pattern: /^T\d{4}$/,
message: "Must match ATT&CK Technique ID format (T####)",
example: "T####",
stixTypes: ["attack-pattern"]
// Note: attack-pattern can be technique or subtechnique
},
subtechnique: {
pattern: /^T\d{4}\.\d{3}$/,
message: "Must match ATT&CK Sub-technique ID format (T####.###)",
example: "T####.###",
stixTypes: ["attack-pattern"]
// Note: attack-pattern can be technique or subtechnique
},
group: {
pattern: /^G\d{4}$/,
message: "Must match ATT&CK Group ID format (G####)",
example: "G####",
stixTypes: ["intrusion-set"]
},
software: {
pattern: /^S\d{4}$/,
message: "Must match ATT&CK Software ID format (S####)",
example: "S####",
stixTypes: ["malware", "tool"]
},
mitigation: {
pattern: /^M\d{4}$/,
message: "Must match ATT&CK Mitigation ID format (M####)",
example: "M####",
stixTypes: ["course-of-action"]
},
asset: {
pattern: /^A\d{4}$/,
message: "Must match ATT&CK Asset ID format (A####)",
example: "A####",
stixTypes: ["x-mitre-asset"]
},
"data-source": {
pattern: /^DS\d{4}$/,
message: "Must match ATT&CK Data Source ID format (DS####)",
example: "DS####",
stixTypes: ["x-mitre-data-source"]
},
"log-source": {
pattern: /^LS\d{4}$/,
message: "Must match ATT&CK Log Source ID format (DS####)",
example: "LS####",
stixTypes: ["x-mitre-log-source"]
},
campaign: {
pattern: /^C\d{4}$/,
message: "Must match ATT&CK Campaign ID format (C####)",
example: "C####",
stixTypes: ["campaign"]
},
"data-component": {
pattern: /^DC\d{4}$/,
message: "Must match ATT&CK Data Component Source ID format (DC####)",
example: "DC####",
stixTypes: ["x-mitre-data-component"]
},
"detection-strategy": {
pattern: /^DET\d{4}$/,
message: "Must match ATT&CK Detection Strategy Source ID format (DET####)",
example: "DET####",
stixTypes: ["x-mitre-detection-strategy"]
},
analytic: {
pattern: /^AN\d{4}$/,
message: "Must match ATT&CK Analytic Source ID format (AN####)",
example: "AN####",
stixTypes: ["x-mitre-analytic"]
}
};
var stixTypeToAttackIdMapping = {
"x-mitre-tactic": "tactic",
"attack-pattern": "technique",
// Default to technique; subtechnique handling is done contextually
"intrusion-set": "group",
malware: "software",
tool: "software",
"course-of-action": "mitigation",
"x-mitre-asset": "asset",
"x-mitre-data-source": "data-source",
campaign: "campaign",
"x-mitre-data-component": "data-component",
"x-mitre-log-source": "log-source",
"x-mitre-detection-strategy": "detection-strategy",
"x-mitre-analytic": "analytic"
};
var attackIdPatterns = Object.fromEntries(
Object.entries(attackIdConfig).map(([key, config]) => [key, config.pattern])
);
var attackIdMessages = Object.fromEntries(
Object.entries(attackIdConfig).map(([key, config]) => [key, config.message])
);
var attackIdExamples = Object.fromEntries(
Object.entries(attackIdConfig).map(([key, config]) => [key, config.example])
);
function getAttackIdExample(stixType) {
if (stixType === "attack-pattern") {
return `${attackIdExamples.technique} or ${attackIdExamples.subtechnique}`;
}
const attackIdType = stixTypeToAttackIdMapping[stixType];
return attackIdExamples[attackIdType];
}
// src/schemas/common/misc.ts
var externalReferenceSchema = import_v46.z.object({
source_name: import_v46.z.string({
error: (issue) => issue.input === void 0 ? "Source name is required" : "Source name must be a string"
}),
description: import_v46.z.string({
error: "Description must be a string"
}).optional(),
url: import_v46.z.url({
error: (issue) => issue.input === null ? "URL cannot be null" : "Invalid URL format. Please provide a valid URL"
}).optional(),
external_id: import_v46.z.string({
error: "External ID must be a string"
}).optional()
});
var externalReferencesSchema = import_v46.z.array(externalReferenceSchema).min(1, "At least one external reference is required when 'external_references' is defined").meta({
description: "A list of external references which refers to non-STIX information"
});
var createAttackExternalReferencesSchema = (stixType) => {
return import_v46.z.array(externalReferenceSchema).min(1, "At least one external reference is required").refine((refs) => !!refs[0]?.external_id, {
message: "ATT&CK ID must be defined in the first external_references entry.",
path: [0, "external_id"]
}).refine(
(refs) => {
if (!refs[0]?.external_id) return true;
const attackIdType = stixTypeToAttackIdMapping[stixType];
if (attackIdType === "technique") {
return attackIdPatterns["technique"].test(refs[0].external_id) || attackIdPatterns["subtechnique"].test(refs[0].external_id);
}
return attackIdPatterns[attackIdType].test(refs[0].external_id);
},
{
message: `The first external_reference must match the ATT&CK ID format ${getAttackIdExample(stixType)}.`,
path: [0, "external_id"]
}
).meta({
description: "A list of external references with the first containing a valid ATT&CK ID"
});
};
var stixCreatedByRefSchema = createStixIdValidator("identity").meta({
description: "The created_by_ref property specifies the id property of the identity object that describes the entity that created this object. If this attribute is omitted, the source of this information is undefined. This may be used by object creators who wish to remain anonymous."
});
var granularMarkingSchema = import_v46.z.object({
marking_ref: stixIdentifierSchema,
selectors: import_v46.z.array(import_v46.z.string())
});
// src/schemas/common/common-properties.ts
var import_v47 = require("zod/v4");
var versionSchema = import_v47.z.string().regex(/^\d+\.\d+$/, "Version must be in the format 'major.minor'").default("2.1").meta({
description: "Represents the version of the object in a 'major.minor' format, where both 'major' and 'minor' are integers. This versioning follows semantic versioning principles but excludes the patch number. The version number is incremented by ATT&CK when the content of the object is updated. This property does not apply to relationship objects."
});
var nameSchema = import_v47.z.string().min(1, "Name must not be empty").meta({ description: "The name of the object." });
var descriptionSchema = import_v47.z.string().meta({ description: "A description of the object." });
var aliasesSchema = import_v47.z.array(import_v47.z.string(), { error: "Aliases must be an array of strings." }).meta({
description: "Alternative names used to identify this object. The first alias must match the object's name."
});
var xMitreVersionSchema = import_v47.z.string().regex(/^(\d{1,2})\.(\d{1,2})$/, "Version must be in format 'M.N' where M and N are 0-99").meta({
description: "Represents the version of the object in a 'major.minor' format, where both 'major' and 'minor' are integers between 0 and 99. This versioning follows semantic versioning principles but excludes the patch number. The version number is incremented by ATT&CK when the content of the object is updated. This property does not apply to relationship objects."
});
var semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
var xMitreAttackSpecVersionSchema = import_v47.z.string().regex(semverRegex, "Must be valid semantic version (MAJOR.MINOR.PATCH)").meta({
description: "The version of the ATT&CK spec used by the object. This field helps consuming software determine if the data format is supported. If the field is not present on an object, the spec version will be assumed to be 2.0.0. Refer to the ATT&CK CHANGELOG for all supported versions."
});
var oldAttackIdRegex = /^MOB-(M|S)\d{4}$/;
function createOldMitreAttackIdSchema(stixType) {
const baseSchema = import_v47.z.string().meta({ description: "Old ATT&CK IDs that may have been associated with this object" });
switch (stixType) {
case "malware":
case "tool":
return baseSchema.refine(
(value) => {
return /^MOB-S\d{4}$/.test(value);
},
{
message: `x_mitre_old_attack_id for ${stixType} need to be in the format MOB-S####`
}
);
case "course-of-action":
return baseSchema.refine(
(value) => {
return /^MOB-M\d{4}$/.test(value);
},
{
message: `x_mitre_old_attack_id for ${stixType} need to be in the format MOB-M####`
}
);
default:
throw new Error(`Unsupported STIX type: ${stixType}`);
}
}
var xMitreOldAttackIdSchema = import_v47.z.string().refine(
(value) => {
return oldAttackIdRegex.test(value);
},
{
message: "Must be in the format 'MOB-X0000' where X is either 'M' or 'S', followed by exactly four digits"
}
).meta({ description: "Old ATT&CK IDs that may have been associated with this object" });
var attackDomainSchema = import_v47.z.enum(["enterprise-attack", "mobile-attack", "ics-attack"]);
var xMitreDomainsSchema = import_v47.z.array(attackDomainSchema).min(1, {
message: "At least one MITRE ATT&CK domain must be specified."
}).meta({ description: "The technology domains to which the ATT&CK object belongs." });
var xMitreDeprecatedSchema = import_v47.z.boolean({
error: "x_mitre_deprecated must be a boolean."
}).meta({ description: "Indicates whether the object has been deprecated." });
var supportedMitrePlatforms = [
"Field Controller/RTU/PLC/IED",
"Network Devices",
"Data Historian",
"Google Workspace",
"Office Suite",
"ESXi",
"Identity Provider",
"Containers",
"Azure AD",
"Engineering Workstation",
"Control Server",
"Human-Machine Interface",
"Windows",
"Linux",
"IaaS",
"None",
"iOS",
"PRE",
"SaaS",
"Input/Output Server",
"macOS",
"Android",
"Safety Instrumented System/Protection Relay",
"Embedded"
];
var xMitrePlatformSchema = import_v47.z.enum(supportedMitrePlatforms, {
error: () => `Platform must be one of: ${supportedMitrePlatforms.join(", ")}`
});
var xMitrePlatformsSchema = import_v47.z.array(xMitrePlatformSchema, {
error: (issue) => issue.code === "invalid_type" ? "x_mitre_platforms must be an array of strings" : "Invalid platforms array"
}).min(1, "At least one platform is required").refine((items) => new Set(items).size === items.length, {
message: "Platforms must be unique (no duplicates allowed)."
}).meta({ description: "List of platforms that apply to the object." });
var objectMarkingRefsSchema = import_v47.z.array(
stixIdentifierSchema.startsWith(
"marking-definition--",
'Identifier must start with "marking-definition--"'
)
).meta({
description: "The list of marking-definition objects to be applied to this object."
});
var xMitreContributorsSchema = import_v47.z.array(import_v47.z.string().nonempty()).meta({
description: "People and organizations who have contributed to the object. Not found on objects of type `relationship`."
}).nonempty();
var xMitreIdentity = "identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5";
var xMitreIdentitySchema = import_v47.z.literal(xMitreIdentity);
var xMitreModifiedByRefSchema = xMitreIdentitySchema.meta({
description: "The STIX ID of the MITRE identity object. Used to track the identity of the MITRE organization, which created the current version of the object. Previous versions of the object may have been created by other individuals or organizations."
});
var killChainNameSchema = import_v47.z.enum([
"mitre-attack",
"mitre-mobile-attack",
"mitre-ics-attack"
]);
var killChainPhaseSchema = import_v47.z.object({
phase_name: import_v47.z.string({
error: (issue) => issue.input === void 0 ? "Phase name is required" : "Phase name must be a string"
}).refine(
(value) => {
const isLowercase = value === value.toLowerCase();
const usesHyphens = !value.includes(" ") && !value.includes("_");
return isLowercase && usesHyphens;
},
{
message: "Phase name should be all lowercase and use hyphens instead of spaces or underscores."
}
).meta({
description: "The name of the phase in the kill chain. The value of this property SHOULD be all lowercase and SHOULD use hyphens instead of spaces or underscores as word separators."
}),
kill_chain_name: killChainNameSchema
}).strict();
// src/schemas/common/extensions.ts
var import_v48 = require("zod/v4");
var extensionTypeSchema = import_v48.z.enum([
"new-sdo",
"new-sco",
"new-sro",
"property-extension",
"toplevel-property-extension"
]);
var extensionSchema = import_v48.z.object({
extension_type: extensionTypeSchema
// Additional properties depend on extension type - using record for flexibility
}).catchall(import_v48.z.unknown());
var extensionsSchema = import_v48.z.record(import_v48.z.string(), import_v48.z.union([extensionSchema, import_v48.z.record(import_v48.z.string(), import_v48.z.unknown())])).meta({
description: "Specifies any extensions of the object, as a dictionary where keys are extension definition UUIDs"
});
var extensionPropertyNameSchema = import_v48.z.string().min(3, "Extension property names must be at least 3 characters").max(250, "Extension property names must be no longer than 250 characters").regex(
/^[a-z0-9_]+$/,
"Extension property names must only contain lowercase letters, digits, and underscores"
);
var extensionObjectTypeSchema = import_v48.z.string().min(3, "Extension object type must be at least 3 characters").max(250, "Extension object type must be no longer than 250 characters").regex(
/^[a-z0-9-]+$/,
"Extension object type must only contain lowercase letters, digits, and hyphens"
).refine(
(value) => !value.includes("--"),
"Extension object type must not contain consecutive hyphens"
);
var extensionDefinitionSchema = import_v48.z.object({
// Required common properties
id: createStixIdValidator("extension-definition"),
type: createStixTypeValidator("extension-definition"),
spec_version: stixSpecVersionSchema,
created: import_v48.z.iso.datetime(),
modified: import_v48.z.iso.datetime(),
created_by_ref: stixCreatedByRefSchema,
// Optional common properties
revoked: import_v48.z.boolean().optional(),
labels: import_v48.z.array(import_v48.z.string()).optional(),
external_references: externalReferencesSchema.optional(),
object_marking_refs: objectMarkingRefsSchema.optional(),
granular_markings: import_v48.z.array(granularMarkingSchema).optional(),
// Extension definition specific properties
name: nameSchema,
description: import_v48.z.string({
error: "Description must be a string"
}).optional(),
schema: import_v48.z.string({
error: "Schema must be a string"
}),
version: import_v48.z.string({
error: "Version must be a string"
}).regex(/^\d+\.\d+\.\d+$/, "Version must follow semantic versioning (MAJOR.MINOR.PATCH)"),
extension_types: import_v48.z.array(extensionTypeSchema).min(1, "At least one extension type is required"),
extension_properties: import_v48.z.array(extensionPropertyNameSchema).optional()
}).strict().refine(
(data) => {
if (data.extension_types.includes("toplevel-property-extension")) {
return data.extension_properties && data.extension_properties.length > 0;
}
return true;
},
{
message: "extension_properties must be provided when extension_types includes toplevel-property-extension"
}
).meta({
description: "Extension Definition object allows producers to extend existing STIX objects or create new STIX objects"
});
// src/schemas/common/stix-core.ts
var stixBaseObjectSchema = import_v49.z.object({
id: stixIdentifierSchema.meta({
description: "The id property universally and uniquely identifies this object."
}),
type: stixTypeSchema,
spec_version: stixSpecVersionSchema.meta({
description: "The version of the STIX specification used to represent this object."
}),
created: stixCreatedTimestampSchema.meta({
description: "The created property represents the time at which the first version of this object was created. The timstamp value MUST be precise to the nearest millisecond."
}),
modified: stixModifiedTimestampSchema.meta({
description: "The modified property represents the time that this particular version of the object was modified. The timstamp value MUST be precise to the nearest millisecond."
}),
created_by_ref: stixCreatedByRefSchema.optional(),
labels: import_v49.z.array(import_v49.z.string()).meta({
description: "The labels property specifies a set of terms used to meta this object."
}).optional(),
revoked: import_v49.z.boolean().meta({ description: "The revoked property indicates whether the object has been revoked." }).optional(),
confidence: import_v49.z.number().meta({
description: "Identifies the confidence that the creator has in the correctness of their data."
}).int().min(1).max(99).optional().refine((val) => val === void 0 || val > 0 && val < 100, {
message: "Confidence must be between 1 and 99 inclusive."
}).optional(),
lang: import_v49.z.string().meta({ description: "Identifies the language of the text content in this object." }).optional(),
external_references: externalReferencesSchema.optional(),
object_marking_refs: objectMarkingRefsSchema.optional(),
granular_markings: import_v49.z.array(granularMarkingSchema).meta({ description: "The set of granular markings that apply to this object." }).optional(),
extensions: extensionsSchema.optional()
}).strict();
var stixDomainObjectSchema = stixBaseObjectSchema.extend({});
var stixRelationshipObjectSchema = stixBaseObjectSchema.extend({});
// src/schemas/common/attack-base-object.ts
var attackBaseObjectSchema = stixDomainObjectSchema.extend({
name: nameSchema,
/**
* Required on all ATT&CK schemas except:
* - Marking Definition
*/
x_mitre_attack_spec_version: xMitreAttackSpecVersionSchema,
/**
* Required on all ATT&CK schemas except:
* - Marking Definition
* - Identity
* - Relationship
*/
x_mitre_version: xMitreVersionSchema,
x_mitre_old_attack_id: xMitreOldAttackIdSchema.optional(),
x_mitre_deprecated: xMitreDeprecatedSchema.optional()
});
var attackBaseDomainObjectSchema = attackBaseObjectSchema.extend({});
var attackBaseRelationshipObjectSchema = attackBaseObjectSchema.extend({});
var attackBaseMetaObjectSchema = attackBaseObjectSchema.extend({}).omit({ modified: true });
// src/schemas/common/open-vocabulary.ts
var import_v411 = require("zod/v4");
var MalwareTypeOV = import_v411.z.enum([
"adware",
"backdoor",
"bot",
"bootkit",
"ddos",
"downloader",
"dropper",
"exploit-kit",
"keylogger",
"ransomware",
"remote-access-trojan",
"resource-exploitation",
"rogue-security-software",
"rootkit",
"screen-capture",
"spyware",
"trojan",
"virus",
"webshell",
"wiper",
"worm",
"unknown"
]);
var ProcessorArchitectureOV = import_v411.z.enum([
"alpha",
"arm",
"ia-64",
"mips",
"powerpc",
"sparc",
"x86",
"x86-64"
]);
var ImplementationLanguageOV = import_v411.z.enum([
"applescript",
"bash",
"c",
"c++",
"c#",
"go",
"java",
"javascript",
"lua",
"objective-c",
"perl",
"php",
"powershell",
"python",
"ruby",
"scala",
"swift",
"typescript",
"visual-basic",
"x86-32",
"x86-64"
]);
var MalwareCapabilityOV = import_v411.z.enum([
"accesses-remote-machines",
"anti-debugging",
"anti-disassembly",
"anti-emulation",
"anti-memory-forensics",
"anti-sandbox",
"anti-vm",
"captures-input-peripherals",
"captures-output-peripherals",
"captures-system-state-data",
"cleans-traces-of-infection",
"commits-fraud",
"communicates-with-c2",
"compromises-data-integrity",
"compromises-data-availability",
"compromises-system-availability",
"controls-local-machine",
"degrades-security-software",
"degrades-system-updates",
"determines-c2-server",
"emails-spam",
"escalates-privileges",
"evades-av",
"exfiltrates-data",
"fingerprints-host",
"hides-artifacts",
"hides-executing-code",
"infects-files",
"infects-remote-machines",
"installs-other-components",
"persists-after-system-reboot",
"prevents-artifact-access",
"prevents-artifact-deletion",
"probes-network-environment",
"self-modifies",
"steals-authentication-credentials",
"violates-system-operational-integrity"
]);
var ToolTypeOV = import_v411.z.enum([
"denial-of-service",
"exploitation",
"information-gathering",
"network-capture",
"credential-exploitation",
"remote-access",
"vulnerability-scanning",
"unknown"
]);
var IdentityClassOV = import_v411.z.enum([
"individual",
"group",
"system",
"organization",
"class",
"unspecified"
]);
var AttackMotivationOV = import_v411.z.enum([
"accidental",
"coercion",
"dominance",
"ideology",
"notoriety",
"organizational-gain",
"personal-gain",
"personal-satisfaction",
"revenge",
"unpredictable"
]);
var AttackResourceLevelOV = import_v411.z.enum([
"individual",
"club",
"contest",
"team",
"organization",
"government"
]);
var IndustrySectorOV = import_v411.z.enum([
"agriculture",
"aerospace",
"automotive",
"chemical",
"commercial",
"communications",
"construction",
"defense",
"education",
"energy",
"entertainment",
"financial-services",
"government",
"government-emergency-services",
"government-local",
"government-national",
"government-public-services",
"government-regional",
"healthcare",
"hospitality-leisure",
"infrastructure",
"infrastructure-dams",
"infrastructure-nuclear",
"infrastructure-water",
"insurance",
"manufacturing",
"mining",
"non-profit",
"pharmaceuticals",
"retail",
"technology",
"telecommunications",
"transportation",
"utilities"
]);
var MitreCollectionLayerOV = import_v411.z.enum([
"Cloud Control Plane",
"Host",
"Report",
"Container",
"Device",
"OSINT",
"Network"
]);
var PatternTypeOV = import_v411.z.enum(["spl", "stix", "pcre", "sigma", "snort", "suricata", "yara"]).meta({
description: "This is a non-exhaustive, open vocabulary that covers common pattern languages and is intended to characterize the pattern language that the indicator pattern is expressed in."
});
var IndicatorTypeOV = import_v411.z.enum([
"anomalous-activity",
"anonymization",
"benign",
"compromised",
"malicious-activity",
"attribution",
"unknown"
]).meta({
description: "Indicator type is an open vocabulary used to categorize Indicators. It is intended to be high-level to promote consistent practices. Indicator types should not be used to capture information that can be better captured via related Malware or Attack Pattern objects. It is better to link an Indicator to a Malware object describing Poison Ivy rather than simply providing a type or label of 'poison-ivy.'"
});
// src/schemas/sdo/analytic.schema.ts
var import_v412 = require("zod/v4");
var xMitreLogSourcePermutationKey = import_v412.z.string();
var xMitreLogSourceRefSchema = import_v412.z.object({
ref: createStixIdValidator("x-mitre-log-source"),
keys: import_v412.z.array(import_v412.z.string()).nonempty().meta({
description: "Must match one of the elements in the ``x_mitre_log_source_permutations`` array"
}).nonempty()
}).meta({
description: "A reference to a log source permutation"
});
var xMitreLogSourceRefsSchema = import_v412.z.array(xMitreLogSourceRefSchema).nonempty().refine(
// Reject duplicate refs (cannot reference the same log source twice)
// Reject duplicate key elements for each ref (cannot reference the same key twice)
(logSourceRefs) => {
const seenRefs = /* @__PURE__ */ new Set();
for (const logSourceRef of logSourceRefs) {
if (seenRefs.has(logSourceRef.ref)) {
return false;
}
seenRefs.add(logSourceRef.ref);
const seenKeys = /* @__PURE__ */ new Set();
for (const key of logSourceRef.keys) {
if (seenKeys.has(key)) {
return false;
}
seenKeys.add(key);
}
}
return true;
},
{
message: "Duplicate log source permutation found: each (name, channel) pair must be unique",
path: ["x_mitre_log_source_permutations"]
}
).meta({
description: "A list of log source STIX IDs, plus the specific channel or event type, e.g., sysmon:1 or auditd:SYSCALL."
});
var xMitreMutableElementSchema = import_v412.z.object({
field: import_v412.z.string().nonempty(),
description: import_v412.z.string().nonempty()
});
var xMitreMutableElementsSchema = import_v412.z.array(xMitreMutableElementSchema).nonempty().meta({
description: "Environment-specific tuning knobs like TimeWindow, UserContext, or PortRange, so defenders can adapt without changing core behavior."
});
var extensibleAnalyticSchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("x-mitre-analytic"),
type: createStixTypeValidator("x-mitre-analytic"),
x_mitre_platforms: xMitrePlatformsSchema.max(1),
// 0 or 1
x_mitre_detects: import_v412.z.string().nonempty().meta({
description: "A tool-agnostic description of the adversary behavior chain this analytic looks for."
}),
external_references: createAttackExternalReferencesSchema("x-mitre-analytic"),
x_mitre_log_sources: xMitreLogSourceRefsSchema,
x_mitre_mutable_elements: xMitreMutableElementsSchema,
x_mitre_domains: xMitreDomainsSchema
}).required({
created_by_ref: true,
object_marking_refs: true
}).strict();
var analyticSchema = extensibleAnalyticSchema;
// src/schemas/sdo/asset.schema.ts
var import_v413 = require("zod/v4");
var supportedAssetSectors = [
"Electric",
"Water and Wastewater",
"Manufacturing",
"Rail",
"Maritime",
"General"
];
var xMitreSectorsSchema = import_v413.z.array(
import_v413.z.enum(supportedAssetSectors, {
error: () => `Sector must be one of: ${supportedAssetSectors.join(", ")}`
}),
{
error: (issue) => issue.code === "invalid_type" ? "related_asset_sectors must be an array" : "Invalid asset sectors array"
}
).meta({
description: "List of industry sector(s) an asset may be commonly observed in"
});
var relatedAssetSchema = import_v413.z.object({
name: import_v413.z.string({
error: (issue) => issue.input === void 0 ? "Related asset name is required" : "Related asset name must be a string"
}),
related_asset_sectors: xMitreSectorsSchema.optional(),
description: descriptionSchema.optional()
});
var relatedAssetsSchema = import_v413.z.array(relatedAssetSchema).meta({
description: "Related assets describe sector specific device names or alias that may be commonly associated with the primary asset page name or functional description. Related asset objects include a description of how the related asset is associated with the page definition"
});
var extensibleAssetSchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("x-mitre-asset"),
type: createStixTypeValidator("x-mitre-asset"),
description: descriptionSchema.optional(),
// Optional in STIX but required in ATT&CK
external_references: createAttackExternalReferencesSchema("x-mitre-asset"),
x_mitre_platforms: xMitrePlatformsSchema.optional(),
x_mitre_domains: xMitreDomainsSchema,
x_mitre_contributors: xMitreContributorsSchema.optional(),
x_mitre_sectors: xMitreSectorsSchema.optional(),
x_mitre_related_assets: relatedAssetsSchema.optional(),
x_mitre_modified_by_ref: xMitreModifiedByRefSchema.optional()
}).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 assetSchema = extensibleAssetSchema;
// src/schemas/sdo/campaign.schema.ts
var import_v414 = require("zod/v4");
var baseCitationSchema = import_v414.z.custom(
(value) => {
if (typeof value !== "string") return false;
if (!value.startsWith("(") || !value.endsWith(")")) return false;
const content = value.slice(1, -1);
const parts = content.split(":");
if (parts.length !== 2) return false;
if (parts[0].trim() !== "Citation") return false;
if (parts[1].trim() === "") return false;
return true;
},
{
message: "Each citation must conform to the pattern '(Citation: [citation name])'"
}
);
var multipleCitationsSchema = import_v414.z.custom(
(value) => {
if (typeof value !== "string") return false;
const citations = value.match(/\(Citation:[^)]+\)/g);
if (!citations) return false;
return citations.join("") === value && citations.every((citation) => baseCitationSchema.safeParse(citation).success);
},
{
message: "Must be one or more citations in the form '(Citation: [citation name])' without any separators"
}
);
var xMitreFirstSeenCitationSchema = multipleCitationsSchema.meta({
description: "One or more citations for when the object was first seen, in the form '(Citation: [citation name])(Citation: [citation name])...', where each [citation name] can be found as one of the source_name values in the external_references."
});
var xMitreLastSeenCitationSchema = multipleCitationsSchema.meta({
description: "One or more citations for when the object was last seen, in the form '(Citation: [citation name])(Citation: [citation name])...', where each [citation name] can be found as one of the source_name values in the external_references."
});
var extensibleCampaignSchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("campaign"),
type: createStixTypeValidator("campaign"),
description: descriptionSchema,
external_references: createAttackExternalReferencesSchema("campaign"),
x_mitre_domains: xMitreDomainsSchema,
x_mitre_modified_by_ref: xMitreModifiedByRefSchema,
x_mitre_contributors: xMitreContributorsSchema.optional(),
aliases: aliasesSchema,
// Optional in STIX but required in ATT&CK
first_seen: stixTimestampSchema.meta({
description: "The time that this Campaign was first seen."
}),
// Optional in STIX but required in ATT&CK
last_seen: stixTimestampSchema.meta({
description: "The time that this Campaign was last seen."
}),
x_mitre_first_seen_citation: xMitreFirstSeenCitationSchema,
x_mitre_last_seen_citation: xMitreLastSeenCitationSchema
}).required({
created_by_ref: true,
// Optional in STIX but required in ATT&CK
object_marking_refs: true,
// Optional in STIX but required in ATT&CK
revoked: true
// Optional in STIX but required in ATT&CK
}).strict();
var campaignSchema = extensibleCampaignSchema.check((ctx) => {
createFirstAliasRefinement()(ctx);
createCitationsRefinement()(ctx);
});
// src/schemas/sdo/collection.schema.ts
var import_v415 = require("zod/v4");
var objectVersionReferenceSchema = import_v415.z.object({
object_ref: stixIdentifierSchema.meta({ description: "The ID of the referenced object." }),
object_modified: stixModifiedTimestampSchema.meta({
description: "The modified time of the referenced object. It MUST be an exact match for the modified time of the STIX object being referenced."
})
});
var xMitreContentsSchema = import_v415.z.array(objectVersionReferenceSchema).min(1, "At least one STIX object reference is required.").meta({ description: "Specifies the objects contained within the collection." });
var extensibleCollectionSchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("x-mitre-collection"),
type: createStixTypeValidator("x-mitre-collection"),
// Optional in STIX but required in ATT&CK
created_by_ref: stixCreatedByRefSchema,
// Optional in STIX but required in ATT&CK
object_marking_refs: objectMarkingRefsSchema,
description: descriptionSchema.meta({
description: "Details, context, and explanation about the purpose or contents of the collection."
}),
x_mitre_contents: xMitreContentsSchema.min(1, "At least one STIX object reference is required")
}).strict();
var collectionSchema = extensibleCollectionSchema;
// src/schemas/sdo/data-component.schema.ts
var import_v416 = require("zod/v4");
var xMitreDataSourceRefSchema = createStixIdValidator("x-mitre-data-source").meta({
description: "STIX ID of the data source this component is a part of."
});
var extensibleDataComponentSchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("x-mitre-data-component"),
type: createStixTypeValidator("x-mitre-data-component"),
description: descriptionSchema,
// Optional in STIX but required in ATT&CK
created_by_ref: stixCreatedByRefSchema,
// Optional in STIX but required in ATT&CK
object_marking_refs: objectMarkingRefsSchema,
x_mitre_domains: xMitreDomainsSchema,
x_mitre_modified_by_ref: xMitreModifiedByRefSchema,
x_mitre_data_source_ref: xMitreDataSourceRefSchema
}).strict();
var dataComponentSchema = extensibleDataComponentSchema;
// src/schemas/sdo/detection-strategy.schema.ts
var import_v417 = require("zod/v4");
var extensibleDetectionStrategySchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("x-mitre-detection-strategy"),
type: createStixTypeValidator("x-mitre-detection-strategy"),
external_references: createAttackExternalReferencesSchema("x-mitre-detection-strategy"),
x_mitre_modified_by_ref: xMitreModifiedByRefSchema,
x_mitre_contributors: xMitreContributorsSchema,
x_mitre_analytics: import_v417.z.array(createStixIdValidator("x-mitre-analytic")).nonempty(),
x_mitre_domains: xMitreDomainsSchema
}).required({
created_by_ref: true,
object_marking_refs: true
}).meta({
description: "The detection logic and patterns used to identify malicious activities based on the collected data."
});
var detectionStrategySchema = extensibleDetectionStrategySchema;
// src/schemas/sdo/group.schema.ts
var import_v418 = require("zod/v4");
var extensibleGroupSchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("intrusion-set"),
type: createStixTypeValidator("intrusion-set"),
// Not used in ATT&CK Group but defined in STIX
description: import_v418.z.string().optional().meta({
description: "A description that provides more details and context about the Intrusion Set, potentially including its purpose and its key characteristics"
}),
// Optional in STIX but required in ATT&CK
external_references: createAttackExternalReferencesSchema("intrusion-set"),
x_mitre_domains: xMitreDomainsSchema,
x_mitre_contributors: import_v418.z.array(import_v418.z.string()).optional(),
x_mitre_modified_by_ref: xMitreModifiedByRefSchema.optional(),
aliases: aliasesSchema.optional().meta({
description: "Alternative names used to identify this group. The first alias must match the object's name"
}),
// Not used in ATT&CK Group but defined in STIX
first_seen: stixTimestampSchema.optional().meta({
description: "The time that this Intrusion Set was first seen"
}),
// Not used in ATT&CK Group but defined in STIX
last_seen: stixTimestampSchema.optional().meta({
description: "The time that this Intrusion Set was last seen"
}),
// Not used in ATT&CK Group but defined in STIX
goals: import_v418.z.array(import_v418.z.string()).optional().meta({
description: "The high-level goals of this Intrusion Set, namely, what are they trying to do"
}),
// Not used in ATT&CK Group but defined in STIX
resource_level: AttackResourceLevelOV.optional().meta({
description: "This property specifies the organizational level at which this Intrusion Set typically works, which in turn determines the resources available to this Intrusion Set for use in an attack"
}),
primary_motivation: AttackMotivationOV.optional().meta({
description: "The primary reason, motivation, or purpose behind this Intrusion Set"
}),
secondary_motivations: import_v418.z.array(AttackMotivationOV).optional().meta({
description: "The secondary reasons, motivations, or purposes behind this Intrusion Set"
})
}).strict();
var groupSchema = extensibleGroupSchema.check((ctx) => {
createFirstAliasRefinement()(ctx);
});
// src/schemas/sdo/identity.schema.ts
var import_v419 = require("zod/v4");
var extensibleIdentitySchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("identity"),
type: createStixTypeValidator("identity"),
object_marking_refs: objectMarkingRefsSchema,
identity_class: IdentityClassOV.meta({
description: "The type of entity that this Identity describes, e.g., an individual or organization. This is an open vocabulary and the values SHOULD come from the identity-class-ov vocabulary"
}),
description: import_v419.z.string().meta({
description: "A description of the object"
}).optional(),
// Not used in ATT&CK Identity but defined in STIX
roles: import_v419.z.array(import_v419.z.string(), {
error: (issue) => issue.code === "invalid_type" ? "Roles must be an array of strings" : "Invalid roles array"
}).meta({
description: "The list of roles that this Identity performs"
}).optional(),
// Not used in ATT&CK Identity but defined in STIX
sectors: import_v419.z.array(IndustrySectorOV).meta({
description: "The list of industry sectors that this Identity belongs to. This is an open vocabulary and values SHOULD come from the industry-sector-ov vocabulary"
}).optional(),
// Not used in ATT&CK Identity but defined in STIX
contact_information: import_v419.z.string().meta({
description: "The contact information (e-mail, phone number, etc.) for this Identity"
}).optional()
}).omit({
x_mitre_version: true
}).strict();
var identitySchema = extensibleIdentitySchema;
// src/schemas/sdo/log-source.schema.ts
var import_v420 = require("zod/v4");
var xMitreLogSourcePermutationsSchema = import_v420.z.array(
import_v420.z.object({
name: import_v420.z.string().nonempty(),
channel: import_v420.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;
// src/schemas/sdo/data-source.schema.ts
var import_v421 = require("zod/v4");
var supportedMitreCollectionLayers = [
"Cloud Control Plane",
"Host",
"Report",
"Container",
"Device",
"OSINT",
"Network"
];
var xMitreCollectionLayersSchema = import_v421.z.array(import_v421.z.enum(supportedMitreCollectionLayers), {
error: (issue) => issue.code === "invalid_type" ? "x_mitre_collection_layers must be an array of supported collection layers." : "x_mitre_collection_layers is invalid or missing"
}).meta({ description: "List of places the data can be collected from." });
var extensibleDataSourceSchema = attackBaseDomainObjectSchema.extend({
id: createStixIdValidator("x-mitre-data-source"),
type: createStixTypeValidator("x-mitre-data-source"),
description: descriptionSchema,
// Optional in STIX but required in ATT&CK
external_references: createAttackExternalReferencesSchema("x-mitre-data-source"),
x_mitre_platforms: xMitrePlatformsSchema.optional(),
x_mitre_domains: xMitreDomainsSchema,
x_mitre_modified_by_ref: xMitreModifiedByRefSchema,
x_mitre_contributors: xMitreContributorsSchema.optional(),
x_mitre_collection_layers: xMitreCollectionLayersSchema
}).required({
created_by_ref: true,
// Optional in STIX but required in ATT&CK
object_marking_refs: true
// Optional in STIX but required in ATT&CK
}).strict();
var dataSourceSchema = extensibleDataSourceSchema;
// src/schemas/sdo/malware.schema.ts
var import_v423 = require("zod/v4");
// src/schemas/sdo/software.schema.ts
var import_v422 = require("zod/v4");
var extensibleSoftwareSchema = attackBaseDomainObjectSchema.extend({
type: createMultiStixTypeValidator(["malware", "tool"]),
created_by_ref: stixCreatedByRefSchema.meta({
description: "The ID of the Source object that describes who created this object."
}),
description: descriptionSchema,
external_references: externalReferencesSchema,
object_marking_refs: objectMarkingRefsSchema,
// Malware: Required
// Tool: Optional
x_mitre_platforms: xMitrePlatformsSchema.optional(),
x_mitre_contributors: import_v422.z.array(import_v422.z.string()).optional(),
x_mitre_aliases: aliasesSchema.optional().meta({
description: "Alternative names used to identify this software. The first alias must match the object's name."