@mitre-attack/attack-data-model
Version:
A TypeScript API for the MITRE ATT&CK data model
387 lines (368 loc) • 9.35 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/classes/sdo/index.ts
var sdo_exports = {};
__export(sdo_exports, {
AnalyticImpl: () => AnalyticImpl,
AssetImpl: () => AssetImpl,
CampaignImpl: () => CampaignImpl2,
CollectionImpl: () => CollectionImpl,
DataComponentImpl: () => DataComponentImpl,
DataSourceImpl: () => DataSourceImpl,
DetectionStrategyImpl: () => DetectionStrategyImpl,
GroupImpl: () => GroupImpl,
IdentityImpl: () => IdentityImpl,
LogSourceImpl: () => LogSourceImpl,
MalwareImpl: () => MalwareImpl,
MatrixImpl: () => MatrixImpl,
MitigationImpl: () => MitigationImpl,
TacticImpl: () => TacticImpl,
TechniqueImpl: () => TechniqueImpl2,
ToolImpl: () => ToolImpl
});
module.exports = __toCommonJS(sdo_exports);
// src/classes/common/attack-object.impl.ts
var AttackBaseImpl = class {
/**
* Sets the object that revokes the current object.
* @param obj - The object that revokes this object.
*/
setRevokedBy(obj) {
this.revokedBy = obj;
}
/**
* Returns the object that revoked this object.
*/
getRevokedBy() {
return this.revokedBy;
}
};
// src/classes/sdo/asset.impl.ts
var AssetImpl = class extends AttackBaseImpl {
constructor(asset) {
super();
this.asset = asset;
// Custom properties prefixed with `_` to avoid conflicts
this._techniques = [];
Object.assign(this, asset);
}
addTechnique(technique) {
this._techniques.push(technique);
}
// Custom method or property
getDisplayName() {
return `${this.asset.name} - Asset`;
}
};
// src/classes/sdo/tactic.impl.ts
var TacticImpl = class extends AttackBaseImpl {
constructor(tactic) {
super();
this.tactic = tactic;
Object.assign(this, tactic);
}
};
// src/classes/sdo/mitigation.impl.ts
var MitigationImpl = class extends AttackBaseImpl {
constructor(mitigation) {
super();
this.mitigation = mitigation;
Object.assign(this, mitigation);
}
};
// src/classes/sdo/log-source.impl.ts
var LogSourceImpl = class extends AttackBaseImpl {
constructor(logSource) {
super();
this.logSource = logSource;
this._dataComponents = [];
Object.assign(this, logSource);
}
addFoundBy(dataComponent) {
this._dataComponents.push(dataComponent);
}
};
// src/classes/sdo/data-component.impl.ts
var DataComponentImpl = class extends AttackBaseImpl {
constructor(dataComponent) {
super();
this.dataComponent = dataComponent;
this._detectedTechniques = [];
this._logSources = [];
Object.assign(this, dataComponent);
}
// Add a technique detected by this data component
addDetectedTechnique(technique) {
this._detectedTechniques.push(technique);
}
addFoundIn(logSource) {
this._logSources.push(logSource);
}
// Getters
getDetectedTechniques() {
return this._detectedTechniques;
}
getLogSources() {
return this._logSources;
}
get foundIn() {
return this._logSources;
}
};
// src/classes/sdo/technique.impl.ts
var TechniqueImpl2 = class extends AttackBaseImpl {
constructor(technique) {
super();
this.technique = technique;
this._subTechniques = [];
this._tactics = [];
this._mitigations = [];
this._logSources = [];
this._relatedTechniques = [];
this._targetAssets = [];
this._detectingDataComponents = [];
Object.assign(this, technique);
}
setParent(parent) {
this._parentTechnique = parent;
}
addSubTechnique(subTechnique) {
this._subTechniques.push(subTechnique);
}
addTactic(tactic) {
this._tactics.push(tactic);
}
addMitigation(mitigation) {
this._mitigations.push(mitigation);
}
addLogSource(logSource) {
this._logSources.push(logSource);
}
addRelatedTechnique(technique) {
this._relatedTechniques.push(technique);
}
addTargetAsset(asset) {
this._targetAssets.push(asset);
}
addDetectingDataComponent(dataComponent) {
this._detectingDataComponents.push(dataComponent);
}
// Getters
getSubTechniques() {
return this._subTechniques;
}
getTactics() {
return this._tactics;
}
getMitigations() {
return this._mitigations;
}
getLogSources() {
return this._logSources;
}
getParentTechnique() {
return this._parentTechnique;
}
getRelatedTechniques() {
return this._relatedTechniques;
}
getTargetAssets() {
return this._targetAssets;
}
getDetectingDataComponents() {
return this._detectingDataComponents;
}
};
// src/classes/sdo/malware.impl.ts
var MalwareImpl = class extends AttackBaseImpl {
constructor(malware) {
super();
this.malware = malware;
this._techniques = [];
Object.assign(this, malware);
}
// Add a technique used by the malware
addTechnique(technique) {
this._techniques.push(technique);
}
// Getters
getTechniques() {
return this._techniques;
}
};
// src/classes/sdo/tool.impl.ts
var ToolImpl = class extends AttackBaseImpl {
constructor(tool) {
super();
this.tool = tool;
this._techniques = [];
Object.assign(this, tool);
}
// Add a technique used by the tool
addTechnique(technique) {
this._techniques.push(technique);
}
// Getters
getTechniques() {
return this._techniques;
}
};
// src/classes/sdo/group.impl.ts
var GroupImpl = class extends AttackBaseImpl {
constructor(group) {
super();
this.group = group;
this._techniques = [];
this._software = [];
this._attributedCampaigns = [];
Object.assign(this, group);
}
// Add a technique used by the group
addTechnique(technique) {
this._techniques.push(technique);
}
// Add software used by the group
addSoftware(software) {
this._software.push(software);
}
addAttributedCampaign(campaign) {
this._attributedCampaigns.push(campaign);
}
// Getters
getTechniques() {
return this._techniques;
}
getSoftware() {
return this._software;
}
getAttributedCampaigns() {
return this._attributedCampaigns;
}
};
// src/classes/sdo/campaign.impl.ts
var CampaignImpl2 = class extends AttackBaseImpl {
constructor(campaign) {
super();
this.campaign = campaign;
this._techniques = [];
this._software = [];
Object.assign(this, campaign);
}
// Add a technique used by the campaign
addTechnique(technique) {
this._techniques.push(technique);
}
// Add software used by the campaign
addSoftware(software) {
this._software.push(software);
}
// Set the group this campaign is attributed to
setAttributedTo(group) {
this._attributedTo = group;
}
// Getters
getTechniques() {
return this._techniques;
}
getSoftware() {
return this._software;
}
getAttributedTo() {
return this._attributedTo;
}
};
// src/classes/sdo/collection.impl.ts
var CollectionImpl = class extends AttackBaseImpl {
constructor(collection) {
super();
this.collection = collection;
Object.assign(this, collection);
}
};
// src/classes/sdo/data-source.impl.ts
var DataSourceImpl = class extends AttackBaseImpl {
constructor(dataSource) {
super();
this.dataSource = dataSource;
Object.assign(this, dataSource);
}
};
// src/classes/sdo/identity.impl.ts
var IdentityImpl = class extends AttackBaseImpl {
constructor(identity) {
super();
this.identity = identity;
Object.assign(this, identity);
}
};
// src/classes/sdo/matrix.impl.ts
var MatrixImpl = class extends AttackBaseImpl {
constructor(matrix) {
super();
this.matrix = matrix;
Object.assign(this, matrix);
}
};
// src/classes/sdo/detection-strategy.impl.ts
var DetectionStrategyImpl = class extends AttackBaseImpl {
constructor(detectionStrategy) {
super();
this.detectionStrategy = detectionStrategy;
this._techniques = [];
Object.assign(this, detectionStrategy);
}
// Add a technique used by the group
addTechnique(technique) {
this._techniques.push(technique);
}
// Getters
getTechniques() {
return this._techniques;
}
get detects() {
return this._techniques;
}
};
// src/classes/sdo/analytic.impl.ts
var AnalyticImpl = class extends AttackBaseImpl {
constructor(analytic) {
super();
this.analytic = analytic;
Object.assign(this, analytic);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AnalyticImpl,
AssetImpl,
CampaignImpl,
CollectionImpl,
DataComponentImpl,
DataSourceImpl,
DetectionStrategyImpl,
GroupImpl,
IdentityImpl,
LogSourceImpl,
MalwareImpl,
MatrixImpl,
MitigationImpl,
TacticImpl,
TechniqueImpl,
ToolImpl
});