Skip to content

Commit ab95e44

Browse files
committed
feat(detection-strategy.schema): enforce unique keys in x_mitre_analytic_refs
1 parent e14b106 commit ab95e44

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/schemas/sdo/detection-strategy.schema.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ export const detectionStrategySchema = attackBaseDomainObjectSchema
3030
x_mitre_analytic_refs: z
3131
.array(createStixIdValidator('x-mitre-analytic'))
3232
.nonempty({ error: 'At least one analytic ref is required' })
33+
.check((ctx) => {
34+
const seen = new Set<string>();
35+
ctx.value.forEach((analyticId, index) => {
36+
if (seen.has(analyticId)) {
37+
ctx.issues.push({
38+
code: 'custom',
39+
message: `Duplicate reference "${analyticId}" found. Each embedded relationship referenced in x_mitre_analytic_refs must be unique.`,
40+
path: ['x_mitre_analytic_refs', index],
41+
input: analyticId,
42+
});
43+
} else {
44+
seen.add(analyticId);
45+
}
46+
});
47+
})
3348
.meta({
3449
description:
3550
'Array of STIX IDs referencing `x-mitre-analytic` objects that implement this detection strategy.',

0 commit comments

Comments
 (0)