Skip to content

Commit e2df6bf

Browse files
authored
Merge pull request #40 from mitre-attack/doc-cleanup
Remove extensible schemas and update documentation
2 parents 21072c9 + 5e9151b commit e2df6bf

File tree

123 files changed

+16626
-5307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+16626
-5307
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# auto-generated schema documentation
2+
docusaurus/docs/reference/schemas/
3+
14
# TypeScript artifacts
25
*.d.ts
36
*.ts.map

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# MITRE ATT&CK® Data Model
22

3-
The ATT&CK Data Model (ADM) is a TypeScript library that provides a structured way to interact with MITRE ATT&CK datasets. It uses Zod schemas, TypeScript types, and ES6 classes to create a type-safe, object-oriented interface for navigating the ATT&CK data model. This library is designed to parse, validate, and serialize STIX 2.1 formatted content, making it easy to work with ATT&CK-related data in a programmatic and intuitive way.
3+
**A TypeScript library for working with MITRE ATT&CK data using STIX 2.1**
44

5-
You can browse the ATT&CK schemas in a user-friendly interface at:
5+
The ATT&CK Data Model (ADM) provides a type-safe, object-oriented interface for working with MITRE ATT&CK datasets.
6+
Built on STIX 2.1 compliance, it uses Zod schemas and TypeScript types to ensure data integrity while providing intuitive relationship navigation between ATT&CK objects.
67

7-
https://mitre-attack.github.io/attack-data-model/.
8+
**[CLICK HERE](https://mitre-attack.github.io/attack-data-model) <sup>[1](#footnotes)</sup>** to browse the ATT&CK schemas in a user-friendly interface.
89

9-
This site is dynamically generated from the contents of the `@latest` distribution channel / `main` branch. Please note that we do not currently maintain separate documentation for previous releases.
10-
11-
## Features
10+
## Key Features
1211

1312
- **Type-Safe Data Parsing**: ADM validates STIX 2.1 bundles using Zod schemas, ensuring data model compliance and type safety.
1413
- **Easy Relationship Navigation**: Each object instance contains pointers to related objects, simplifying the process of navigating between techniques, tactics, and other ATT&CK elements.
@@ -91,9 +90,9 @@ For most users, we recommend:
9190

9291
Example of loading the latest ATT&CK data:
9392
```javascript
94-
import { registerDataSource, loadDataModel, DataSource } from '@mitre-attack/attack-data-model';
93+
import { registerDataSource, loadDataModel, DataSourceRegistration } from '@mitre-attack/attack-data-model';
9594

96-
const dataSource = new DataSource({
95+
const dataSource = new DataSourceRegistration({
9796
source: 'attack',
9897
domain: 'enterprise-attack',
9998
version: '17.1',
@@ -133,12 +132,12 @@ For additional context about the ATT&CK specification, please refer to the [ATT&
133132
Here's an example script that demonstrates how to use the ADM library to load ATT&CK data from the official MITRE ATT&CK GitHub repository:
134133

135134
```typescript
136-
import { registerDataSource, loadDataModel, DataSource } from '@mitre-attack/attack-data-model';
135+
import { registerDataSource, loadDataModel, DataSourceRegistration } from '@mitre-attack/attack-data-model';
137136

138137
(async () => {
139-
140-
// Instantiating a DataSource object will validate that the data source is accessible and readable
141-
const dataSource = new DataSource({
138+
139+
// Instantiating a DataSourceRegistration object will validate that the data source is accessible and readable
140+
const dataSource = new DataSourceRegistration({
142141
source: 'attack', // Built-in index to retrieve ATT&CK content from the official MITRE ATT&CK STIX 2.1 GitHub repository
143142
domain: 'enterprise-attack',
144143
version: '15.1', // Omitting 'version' will default to the latest version available in the repository
@@ -160,7 +159,7 @@ import { registerDataSource, loadDataModel, DataSource } from '@mitre-attack/att
160159

161160
// Type hinting is supported for all object properties
162161
if (technique.x_mitre_is_subtechnique) {
163-
162+
164163
// Access related objects with helpful getter methods
165164
console.log(technique.getParentTechnique());
166165
}
@@ -231,20 +230,24 @@ For more detailed examples, please refer to the [examples](./examples/README.md)
231230

232231
## Compatibility Matrix
233232

234-
Our [COMPATIBILITY.md](./docs/COMPATIBILITY.md) document tracks the compatibility between versions of the ATT&CK Data Model (ADM) TypeScript API (`@mitre-attack/attack-data-model`) and versions of the MITRE ATT&CK® dataset (`mitre-attack/attack-stix-data`).
233+
Our [Compatibility documentation](https://mitre-attack.github.io/attack-data-model/principles/versioning-philosophy) tracks the compatibility between versions of the ATT&CK Data Model (ADM) TypeScript API (`@mitre-attack/attack-data-model`) and versions of the MITRE ATT&CK dataset (`mitre-attack/attack-stix-data`).
235234

236235
## Contributing
237236

238237
We welcome contributions! Please see our [CONTRIBUTING.md](./docs/CONTRIBUTING.md) file for details on how to contribute to this project.
239238

239+
## Footnotes
240+
241+
<sup>1</sup> The [schemas site](https://mitre-attack.github.io/attack-data-model) is dynamically generated from the contents of the `@latest` distribution channel / `main` branch. We do not currently maintain separate documentation for previous releases, though we hope to in the future.
242+
240243
## License
241244

242245
This project is licensed under the Apache 2.0 License.
243246

244-
## Notice
247+
## Notice
245248

246249
Copyright 2020-2025 The MITRE Corporation.
247250

248-
This project makes use of ATT&CK®
251+
This project makes use of ATT&CK
249252

250-
[ATT&CK Terms of Use](https://attack.mitre.org/resources/terms-of-use/)
253+
[ATT&CK Terms of Use](https://attack.mitre.org/resources/terms-of-use/)

docs/CONTRIBUTING.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,21 @@ When submitting a pull request:
6161
5. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
6262
6. Include a description of your changes and why they're necessary.
6363

64+
## Developer Setup
65+
66+
### Requirements
67+
68+
- [Node.js](https://nodejs.org/) v18.20
69+
70+
### Install dependences
71+
72+
```bash
73+
npm install
74+
```
75+
6476
## Developer Workflow
6577

66-
To maintain code quality and consistency, we use **ESLint**, **Prettier**, and **Husky** as part of the development workflow. Below is an overview of how each tool is configured and how it affects the contribution process:
78+
To maintain code quality and consistency, we use **ESLint**, **Prettier**, and **Husky** as part of the development workflow. These tools are installed and configured by the [Developer Setup](#developer-setup) steps above. Below is an overview of how each tool is configured and how it affects the contribution process:
6779

6880
### ESLint and Prettier Configuration
6981

docs/SPEC.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
> [!IMPORTANT]
22
> **Documentation Notice**
3-
>
3+
>
44
> This document is **not the source of truth** for the ATT&CK specification. The authoritative source is the **ATT&CK Data Model (ADM) TypeScript library**.
5-
>
6-
> 📖 **Browse ATT&CK schemas:** https://mitre-attack.github.io/attack-data-model/
7-
>
5+
>
6+
> 📖 **Browse ATT&CK schemas:** <https://mitre-attack.github.io/attack-data-model/>
7+
>
88
> While maintained to the best of our ability, this documentation may drift from the ADM library. If you find discrepancies, please [open a GitHub Issue](https://github.com/mitre-attack/attack-data-model/issues).
99
1010
# The ATT&CK Specification
@@ -60,8 +60,7 @@ There are three general ways that ATT&CK extends the STIX 2.1 specification:
6060
| `x_mitre_domains` | string[] | Identifies the domains the object is found in. See [domains](#domains) for more information.<br>Not found on objects of type `relationship`, `identity`, or `marking-definition`. |
6161
| `x_mitre_attack_spec_version`<sup>1</sup> | string | The version of the ATT&CK specification used by the object. Consuming software can use this field to determine if the data format is supported. Current version is 3.3.0. |
6262

63-
64-
- New relationship types. Unlike custom object types and extended fields, custom relationship types are **not** prefixed with `x_mitre_`. You can find a full list of relationship types in the [Relationships](#Relationships) section, which also mentions whether the type is a default STIX type.
63+
- New relationship types. Unlike custom object types and extended fields, custom relationship types are **not** prefixed with `x_mitre_`. You can find a full list of relationship types in the [Relationships](#relationships) section, which also mentions whether the type is a default STIX type.
6564

6665
Please see also the STIX documentation on [customizing STIX](https://docs.oasis-open.org/cti/stix/v2.0/csprd01/part1-stix-core/stix-v2.0-csprd01-part1-stix-core.html#_Toc476227365).
6766

@@ -93,7 +92,7 @@ The `x_mitre_domains` (string array) field identifies the "domain" to which the
9392
| `mobile-attack` | Mobile |
9493
| `ics-attack` | ATT&CK for ICS |
9594

96-
Most objects in ATT&CK belong in a single technology domain, but an object _may_ be included in multiple domains.
95+
Most objects in ATT&CK belong in a single technology domain, but an object _may_ be included in multiple domains.
9796

9897
`x_mitre_domains` is supported on all ATT&CK object types except the following:
9998

@@ -127,6 +126,7 @@ ATT&CK IDs are human-readable identifiers commonly used for referencing objects
127126
| [Log Source](#log-sources) | `LSxxxx` |
128127

129128
**Important limitations:**
129+
130130
- ATT&CK IDs are not guaranteed to be unique (see [Collisions with Technique ATT&CK IDs](#collisions-with-technique-attck-ids))
131131
- Matrices within the same domain share identical ATT&CK IDs
132132
- Relationship objects do not have ATT&CK IDs
@@ -213,6 +213,7 @@ Sub-techniques are specialized implementations of parent techniques, providing m
213213
Procedures describe specific instances of technique implementation by adversaries. Unlike other ATT&CK concepts, procedures are not represented by dedicated STIX objects. Instead, they are modeled as `uses` relationships where the `target_ref` points to a technique (`attack-pattern`).
214214

215215
**Procedure relationships:**
216+
216217
- **Source objects:** Groups (`intrusion-set`) or software (`malware`/`tool`)
217218
- **Target objects:** Techniques (`attack-pattern`)
218219
- **Content:** Procedure details are captured in the relationship's `description` field
@@ -250,6 +251,7 @@ Software represents tools and malicious code used by adversaries to accomplish t
250251
Data sources and data components define the telemetry and observational data that security teams can use to detect adversary techniques. This hierarchical model provides granular mapping between detection capabilities and techniques.
251252

252253
**Structural relationships:**
254+
253255
- Data components are nested within data sources but maintain separate STIX objects
254256
- Each data component has exactly one parent data source
255257
- Data sources can contain multiple data components
@@ -364,6 +366,7 @@ Detection strategies define high-level approaches for detecting specific adversa
364366
| `x_mitre_analytic_refs` | string[] | Array of STIX IDs referencing `x-mitre-analytic` objects that implement this detection strategy. |
365367

366368
**Key characteristics:**
369+
367370
- Each detection strategy has a one-to-one relationship with a specific ATT&CK technique
368371
- Detection strategies typically reference 1-3 analytics (one for each supported platform)
369372
- Uses soft relationships (STIX ID references) to analytics for flexibility
@@ -497,4 +500,4 @@ Relationship objects frequently include `description` fields that provide contex
497500

498501
### Collections
499502

500-
See our [collections document](https://github.com/center-for-threat-informed-defense/attack-workbench-frontend/blob/master/docs/collections.md) for more information about the design and intention of collection objects.
503+
See our [collections document](https://github.com/center-for-threat-informed-defense/attack-workbench-frontend/blob/master/docs/collections.md) for more information about the design and intention of collection objects.

docs/USAGE.md

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -105,68 +105,44 @@ The library provides Zod schemas for all ATT&CK object types, enabling validatio
105105

106106
### Accessing Schemas
107107

108-
Schemas are available under the `schemas` directory. You can import them directly from the package root:
108+
Schemas and their associated TypeScript types are available under the `schemas` directory. You can import them directly from the package root:
109109

110110
```typescript
111-
import { tacticSchema } from '@mitre-attack/attack-data-model';
111+
import { campaignSchema } from '@mitre-attack/attack-data-model';
112+
import type { Campaign } from '@mitre-attack/attack-data-model';
112113
```
113114

114-
Notably, there are two versions of each ATT&CK type available:
115-
116-
* One "extensible" schema (denoted by its `extensible` prefix) that returns a `ZodType`
117-
* One "standard" schema that returns a `ZodEffect`
118-
119-
The extensible schemas (e.g., `extensibleCampaignSchema`) return a `ZodType` by intentionally omitting all Zod refinements. You should use these schemas if you are looking to extend or modify the baseline schema behaviors.
120-
121-
For example, let's say you wish to augment ATT&CK campaigns with your own custom fields—you can do this with the `extensibleCampaignSchema` as follows:
122-
123-
```typescript
124-
// Using the extensible schema for type definition or extension
125-
import { extensibleCampaignSchema } from '@mitre-attack/attack-data-model';
126-
const myCustomCampaignSchema = extensibleCampaignSchema.extend({ /* additional fields */ });
127-
```
115+
Many of the ATT&CK schemas use Zod refinements. We leverage refinements to execute advanced validation checks (e.g., validating that the first reference in `external_references` contains a valid ATT&CK ID).
128116

129-
This would not work for the "standard" `campaignSchema`.
117+
Unfortunately, in current versions of Zod, if a schema is modified with one of the object methods (`pick`, `omit`, `extend`), the refinements will be discarded.
130118

131-
`campaignSchema` returns a `ZodEffect` by nature of employing Zod refinements. We leverage refinements to execute advanced validation checks (e.g., validating that the first reference in `external_references` contains a valid ATT&CK ID). You can use the refined schemas like you would any other Zod schema, with the added disclaimer that they are less extensible than their aforementioned counterparts:
119+
For example, let's say you wish to augment ATT&CK campaigns with your own custom fields:
132120

133121
```typescript
134-
// Using the refined schema for validation
135122
import { campaignSchema } from '@mitre-attack/attack-data-model';
136-
const validCampaign = campaignSchema.parse(rawCampaignData);
123+
const myCustomCampaignSchema = campaignSchema.extend({ /* additional fields */ });
137124
```
138125

139-
And don't worry—you can still use these refinements with your custom schemas. Each ATT&CK refinement is decoupled so they can be used modularly. They are exported as factory functions in the `refinements` sub-package:
126+
`myCustomCampaignSchema` would not be valid, as it is missing the refinements that were originally present in `campaignSchema`.
140127

141-
```typescript
142-
// Step 1 - import the refinements you want to use
143-
import { createFirstAliasRefinement, createCitationsRefinement } from '@mitre-attack/attack-data-model';
128+
You can still use the original refinements in your custom schemas, it will just take an extra step. Each ATT&CK refinement is decoupled so they can be used modularly. They are exported as factory functions in the `refinements` sub-package:
144129

145-
// Step 2 - initialize the refinements
146-
const validateFirstAlias = createFirstAliasRefinement();
147-
const validateCitations = createCitationsRefinement();
130+
```typescript
131+
// Import the original schema, and the refinements you want to use
132+
import { campaignSchema, createFirstAliasRefinement, createCitationsRefinement } from '@mitre-attack/attack-data-model';
148133

149-
// Step 3 - apply a single refinement that combines the imported refinements
150-
const myCustomCampaignSchema = extensibleCampaignSchema
134+
// Apply a single refinement that combines the imported refinements
135+
const myCustomCampaignSchema = campaignSchema
151136
.extend({ /* additional fields */ })
152-
.superRefine((val, ctx) => {
153-
validateFirstAlias(val, ctx);
154-
validateCitations(val, ctx);
137+
.check((ctx) => {
138+
createFirstAliasRefinement()(ctx);
139+
createCitationsRefinement()(ctx);
155140
});
156141
```
157142

158-
Notably, all ATT&CK schemas export only one TypeScript type, named in accordance with the refined schema, but inferred from the extensible schema. Since the refinements only add validation rules (rejected values) without changing the shape of valid data, a single type definition is sufficient:
159-
160-
```typescript
161-
// An extensible schema for customizing or augmenting ATT&CK campaigns
162-
import { extensibleCampaignSchema } from '@mitre-attack/attack-data-model';
163-
164-
// An inelastic but fully implemented schema for validating ATT&CK campaigns
165-
import { campaignSchema } from '@mitre-attack/attack-data-model';
143+
You will have to look in the original schema file, in this case [/src/schemas/sdo/campaign.schema.ts](/src/schemas/sdo/campaign.schema.ts) to see which refinements, if any, should be applied to the ATT&CK schema that you wish to extend.
166144

167-
// One type definition for *all* ATT&CK campaigns (custom or otherwise)
168-
import type { Campaign } from '@mitre-attack/attack-data-model';
169-
```
145+
This [GitHub issue](https://github.com/colinhacks/zod/issues/4874) and [pull request](https://github.com/colinhacks/zod/pull/4865) describe the behavior and an upcoming `safeExtend` method that will allow you to extend the ATT&CK schemas without having to reapply the refinements.
170146

171147
### Validating Data
172148

docusaurus/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@
1818
npm-debug.log*
1919
yarn-debug.log*
2020
yarn-error.log*
21-
22-
docs/*/*
23-
!docs/sdo/stix-bundle.schema.md

docusaurus/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $ npm install
2525
The `generate-docs.sh` script is used to automate the process of converting Zod schemas into Markdown.
2626

2727
```bash
28-
$ npm run autodocs
28+
$ npm run gendocs
2929
```
3030

3131
## Local Development

docusaurus/blog/known-issues.md

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Coding Style & Linting
2+
3+
ADM enforces a **single source-of-truth** for style:
4+
5+
* **ESLint**`@eslint/js` + custom rules
6+
* **Prettier** – code formatting
7+
* **commitlint** – conventional-commits
8+
9+
## ESLint + Prettier
10+
11+
```bash
12+
npm run lint # read-only
13+
npm run format # auto-fix + prettier
14+
```
15+
16+
CI will fail if `npm run lint` reports errors or if Prettier formatting changes are uncommitted.
17+
18+
## Typical workflow
19+
20+
```bash
21+
git checkout -b feat/my-awesome-change
22+
# …code…
23+
npm run format
24+
git add .
25+
git commit -m "feat(core): add awesome change"
26+
```
27+
28+
The commit message is checked by [commitlint](https://commitlint.js.org).
29+
Prefix your commit with one of the following:
30+
31+
| Prefix | Description | Example Commit Command |
32+
|----------|------------------------------------------------|----------------------------------------------------------|
33+
| feat | A new feature | `git commit -m "feat: add new schema"` |
34+
| fix | A bug fix | `git commit -m "fix: correct null pointer exception"` |
35+
| docs | Documentation only changes | `git commit -m "docs: update installation instructions"` |
36+
| chore | Routine tasks, maintenance, or tooling | `git commit -m "chore: update dependency versions"` |
37+
| refactor | Code changes that neither fix nor add features | `git commit -m "refactor: simplify token validation"` |
38+
| test | Adding or updating tests | `git commit -m "test: add tests for date parser"` |
39+
| perf | Performance improvements | `git commit -m "perf: optimize query performance"` |
40+
41+
## TypeScript strictness
42+
43+
The library is compiled with `"strict": true` and imports must be path-alias aware (`@/…`).
44+
Run `npm run build` to catch any type errors locally.
45+
46+
---

0 commit comments

Comments
 (0)