@mitre-attack/attack-data-model
Version:
A TypeScript API for the MITRE ATT&CK data model
61 lines (57 loc) • 2.65 kB
JavaScript
;
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/schemas/common/property-schemas/stix-kill-chains.ts
var stix_kill_chains_exports = {};
__export(stix_kill_chains_exports, {
killChainNameSchema: () => killChainNameSchema,
killChainPhaseSchema: () => killChainPhaseSchema
});
module.exports = __toCommonJS(stix_kill_chains_exports);
var import_zod2 = require("zod");
// src/schemas/common/property-schemas/generics.ts
var import_zod = require("zod");
var nonEmptyRequiredString = import_zod.z.string().trim().min(1, { error: "At least one character is required. Whitespace is not permissible." });
var emptyStixListErrorMessage = "Empty lists are prohibited in STIX and MUST NOT be used as a substitute for omitting the property if it is optional. The list MUST be present and MUST have at least one value.";
var stixListOfString = import_zod.z.array(nonEmptyRequiredString).min(1, { error: emptyStixListErrorMessage });
// src/schemas/common/property-schemas/stix-kill-chains.ts
var killChainNameSchema = import_zod2.z.enum([
"mitre-attack",
"mitre-mobile-attack",
"mitre-ics-attack"
]);
var killChainPhaseSchema = import_zod2.z.object({
phase_name: nonEmptyRequiredString.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();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
killChainNameSchema,
killChainPhaseSchema
});