Skip to content

Commit 095a9cd

Browse files
committed
fix: add new SDO types to attack-data.test.ts to update expected counts
1 parent 9d62a2b commit 095a9cd

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

test/utils/attack-data.test.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22

33
describe('Global Tests', () => {
44
describe('ATT&CK Testing Data', () => {
@@ -43,50 +43,52 @@ describe('Global Tests', () => {
4343
'x-mitre-matrix',
4444
'x-mitre-tactic',
4545
'x-mitre-asset',
46+
'x-mitre-analytic',
47+
'x-mitre-detection-strategy'
4648
];
47-
49+
4850
const presentTypes = Object.keys(globalThis.attackData.objectsByType);
4951
const missingTypes = expectedSDOs.filter((type) => !presentTypes.includes(type));
5052
const unexpectedTypes = presentTypes.filter((type) => !expectedSDOs.includes(type));
51-
53+
5254
if (missingTypes.length > 0) {
5355
console.warn('Missing SDO types:', missingTypes);
5456
}
5557
if (unexpectedTypes.length > 0) {
5658
console.warn('Unexpected SDO types:', unexpectedTypes);
5759
}
58-
60+
5961
expectedSDOs.forEach((type) => {
6062
if (globalThis.attackData.objectsByType[type]) {
6163
expect(globalThis.attackData.objectsByType[type].length).toBeGreaterThan(0);
6264
} else {
6365
console.warn(`Missing SDO type: ${type}`);
6466
}
6567
});
66-
68+
6769
expect(missingTypes).toHaveLength(0);
6870
expect(unexpectedTypes).toHaveLength(0);
6971
});
70-
72+
7173
it('should have STIX Relationship Objects (SROs)', () => {
7274
expect(globalThis.attackData.sros).toBeDefined();
7375
expect(globalThis.attackData.sros.length).toBeGreaterThan(0);
7476
});
75-
77+
7678
it('should have marking definitions (SMOs)', () => {
7779
expect(globalThis.attackData.smos).toBeDefined();
7880
expect(globalThis.attackData.smos.length).toBeGreaterThan(0);
7981
});
80-
82+
8183
it('should have software objects (combination of malware and tools)', () => {
8284
expect(globalThis.attackData.objectsByType['software']).toBeDefined();
8385
expect(globalThis.attackData.objectsByType['software'].length).toBeGreaterThan(0);
8486
expect(globalThis.attackData.objectsByType['software'].length).toEqual(
8587
globalThis.attackData.objectsByType['malware'].length +
86-
globalThis.attackData.objectsByType['tool'].length,
88+
globalThis.attackData.objectsByType['tool'].length,
8789
);
8890
});
89-
91+
9092
it('should have data sources and data components', () => {
9193
expect(globalThis.attackData.objectsByType['x-mitre-data-source']).toBeDefined();
9294
expect(globalThis.attackData.objectsByType['x-mitre-data-source'].length).toBeGreaterThan(0);
@@ -95,23 +97,23 @@ describe('Global Tests', () => {
9597
0,
9698
);
9799
});
98-
100+
99101
it('should have assets for ICS', () => {
100102
expect(globalThis.attackData.objectsByType['x-mitre-asset']).toBeDefined();
101103
expect(globalThis.attackData.objectsByType['x-mitre-asset'].length).toBeGreaterThan(0);
102104
});
103-
105+
104106
it('should have correct number of objects in allObjects', () => {
105107
const totalObjectCount = Object.values(globalThis.attackData.objectsByType).reduce(
106108
(sum, arr) => sum + arr.length,
107109
0,
108110
);
109111
// Subtract software count as it's a duplicate of malware and tool
110112
const adjustedCount =
111-
totalObjectCount - globalThis.attackData.objectsByType['software'].length;
113+
totalObjectCount - globalThis.attackData.objectsByType['software'].length;
112114
expect(globalThis.attackData.allObjects.length).toEqual(adjustedCount);
113115
});
114-
116+
115117
it('should have correct number of SDOs', () => {
116118
const sdoTypes = [
117119
'attack-pattern',
@@ -129,6 +131,8 @@ describe('Global Tests', () => {
129131
'x-mitre-data-source',
130132
'x-mitre-data-component',
131133
'x-mitre-asset',
134+
'x-mitre-analytic',
135+
'x-mitre-detection-strategy'
132136
];
133137
const sdoCount = sdoTypes.reduce(
134138
(sum, type) => sum + (globalThis.attackData.objectsByType[type]?.length || 0),

0 commit comments

Comments
 (0)