@ampsec/platform-client 84.40.0 → 84.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/dto/findings.dto.d.ts +97 -5
- package/build/src/dto/findings.dto.js +26 -1
- package/build/src/dto/findings.dto.js.map +1 -1
- package/build/src/dto/findingsInsights.dto.d.ts +2 -2
- package/build/src/dto/platform/platform.findings.dto.d.ts +5 -5
- package/build/src/dto/platform/platform.webhookProviders.dto.d.ts +5 -5
- package/build/src/dto/webhookProviders.dto.d.ts +5 -5
- package/build/src/services/ContentTemplateService.d.ts +10 -0
- package/build/src/services/ContentTemplateService.js +50 -24
- package/build/src/services/ContentTemplateService.js.map +1 -1
- package/package.json +1 -1
- package/src/dto/findings.dto.ts +28 -0
- package/src/services/ContentTemplateService.ts +54 -31
|
@@ -25,6 +25,98 @@ export declare const _FindingBucketDto: z.ZodObject<{
|
|
|
25
25
|
key: string;
|
|
26
26
|
}>;
|
|
27
27
|
export type FindingBucketDto = z.infer<typeof _FindingBucketDto>;
|
|
28
|
+
/**
|
|
29
|
+
* Zod schema for the finding-level keys (BaseDto + FindingUpsertDto).
|
|
30
|
+
* Used to derive template variable paths for Custom Content dynamic variables.
|
|
31
|
+
*/
|
|
32
|
+
export declare const _FindingDtoSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
createdAt: z.ZodString;
|
|
35
|
+
updatedAt: z.ZodString;
|
|
36
|
+
deletedAt: z.ZodNullable<z.ZodString>;
|
|
37
|
+
}, {
|
|
38
|
+
discoveredAt: z.ZodOptional<z.ZodString>;
|
|
39
|
+
closedAt: z.ZodOptional<z.ZodString>;
|
|
40
|
+
category: z.ZodString;
|
|
41
|
+
kind: z.ZodString;
|
|
42
|
+
status: z.ZodString;
|
|
43
|
+
severity: z.ZodString;
|
|
44
|
+
outcome: z.ZodOptional<z.ZodString>;
|
|
45
|
+
numberOfEngagements: z.ZodNumber;
|
|
46
|
+
displayValue: z.ZodString;
|
|
47
|
+
description: z.ZodOptional<z.ZodString>;
|
|
48
|
+
cid: z.ZodString;
|
|
49
|
+
pid: z.ZodString;
|
|
50
|
+
aid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
uid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
scid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
fsid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
verificationCount: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
bucket: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
/** Bucket key */
|
|
57
|
+
key: z.ZodString;
|
|
58
|
+
/** Severity of the bucket */
|
|
59
|
+
score: z.ZodNumber;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
score: number;
|
|
62
|
+
key: string;
|
|
63
|
+
}, {
|
|
64
|
+
score: number;
|
|
65
|
+
key: string;
|
|
66
|
+
}>>;
|
|
67
|
+
}>, "strip", z.ZodTypeAny, {
|
|
68
|
+
status: string;
|
|
69
|
+
id: string;
|
|
70
|
+
cid: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
deletedAt: string | null;
|
|
74
|
+
displayValue: string;
|
|
75
|
+
kind: string;
|
|
76
|
+
category: string;
|
|
77
|
+
severity: string;
|
|
78
|
+
numberOfEngagements: number;
|
|
79
|
+
pid: string;
|
|
80
|
+
description?: string | undefined;
|
|
81
|
+
uid?: string | null | undefined;
|
|
82
|
+
aid?: string | null | undefined;
|
|
83
|
+
discoveredAt?: string | undefined;
|
|
84
|
+
closedAt?: string | undefined;
|
|
85
|
+
outcome?: string | undefined;
|
|
86
|
+
scid?: string | null | undefined;
|
|
87
|
+
fsid?: string | null | undefined;
|
|
88
|
+
verificationCount?: number | undefined;
|
|
89
|
+
bucket?: {
|
|
90
|
+
score: number;
|
|
91
|
+
key: string;
|
|
92
|
+
} | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
status: string;
|
|
95
|
+
id: string;
|
|
96
|
+
cid: string;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
updatedAt: string;
|
|
99
|
+
deletedAt: string | null;
|
|
100
|
+
displayValue: string;
|
|
101
|
+
kind: string;
|
|
102
|
+
category: string;
|
|
103
|
+
severity: string;
|
|
104
|
+
numberOfEngagements: number;
|
|
105
|
+
pid: string;
|
|
106
|
+
description?: string | undefined;
|
|
107
|
+
uid?: string | null | undefined;
|
|
108
|
+
aid?: string | null | undefined;
|
|
109
|
+
discoveredAt?: string | undefined;
|
|
110
|
+
closedAt?: string | undefined;
|
|
111
|
+
outcome?: string | undefined;
|
|
112
|
+
scid?: string | null | undefined;
|
|
113
|
+
fsid?: string | null | undefined;
|
|
114
|
+
verificationCount?: number | undefined;
|
|
115
|
+
bucket?: {
|
|
116
|
+
score: number;
|
|
117
|
+
key: string;
|
|
118
|
+
} | undefined;
|
|
119
|
+
}>;
|
|
28
120
|
export type FindingUpsertDto = BaseUpsertDto & {
|
|
29
121
|
/** Date the finding was discoverd by the integration */
|
|
30
122
|
discoveredAt?: string;
|
|
@@ -324,6 +416,7 @@ export declare const _FindingSpecDto: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
324
416
|
description?: unknown;
|
|
325
417
|
cid?: string | null | undefined;
|
|
326
418
|
score?: number | undefined;
|
|
419
|
+
outcome?: FindingOutcome | undefined;
|
|
327
420
|
insights?: {
|
|
328
421
|
meta?: {
|
|
329
422
|
displayValue: string;
|
|
@@ -345,7 +438,6 @@ export declare const _FindingSpecDto: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
345
438
|
} | undefined;
|
|
346
439
|
} | undefined;
|
|
347
440
|
expireAfterDays?: number | null | undefined;
|
|
348
|
-
outcome?: FindingOutcome | undefined;
|
|
349
441
|
}, {
|
|
350
442
|
name: string;
|
|
351
443
|
id: string;
|
|
@@ -359,6 +451,7 @@ export declare const _FindingSpecDto: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
359
451
|
description?: unknown;
|
|
360
452
|
cid?: string | null | undefined;
|
|
361
453
|
score?: number | undefined;
|
|
454
|
+
outcome?: FindingOutcome | undefined;
|
|
362
455
|
insights?: {
|
|
363
456
|
meta?: {
|
|
364
457
|
displayValue: string;
|
|
@@ -380,7 +473,6 @@ export declare const _FindingSpecDto: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
380
473
|
} | undefined;
|
|
381
474
|
} | undefined;
|
|
382
475
|
expireAfterDays?: number | null | undefined;
|
|
383
|
-
outcome?: FindingOutcome | undefined;
|
|
384
476
|
}>;
|
|
385
477
|
export type FindingSpecDto = z.infer<typeof _FindingSpecDto>;
|
|
386
478
|
export declare const _FindingSpecUpsertDto: z.ZodObject<{
|
|
@@ -396,6 +488,7 @@ export declare const _FindingSpecUpsertDto: z.ZodObject<{
|
|
|
396
488
|
eventType: z.ZodString;
|
|
397
489
|
score: z.ZodOptional<z.ZodNumber>;
|
|
398
490
|
severity: z.ZodNativeEnum<typeof FindingSeverity>;
|
|
491
|
+
outcome: z.ZodOptional<z.ZodNativeEnum<typeof FindingOutcome>>;
|
|
399
492
|
insights: z.ZodOptional<z.ZodObject<{
|
|
400
493
|
meta: z.ZodOptional<z.ZodObject<{
|
|
401
494
|
kind: z.ZodNativeEnum<typeof FindingKind>;
|
|
@@ -495,7 +588,6 @@ export declare const _FindingSpecUpsertDto: z.ZodObject<{
|
|
|
495
588
|
} | undefined;
|
|
496
589
|
}>>;
|
|
497
590
|
expireAfterDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
498
|
-
outcome: z.ZodOptional<z.ZodNativeEnum<typeof FindingOutcome>>;
|
|
499
591
|
}, "strip", z.ZodTypeAny, {
|
|
500
592
|
name: string;
|
|
501
593
|
displayValue: string;
|
|
@@ -509,6 +601,7 @@ export declare const _FindingSpecUpsertDto: z.ZodObject<{
|
|
|
509
601
|
updatedAt?: string | undefined;
|
|
510
602
|
deletedAt?: string | null | undefined;
|
|
511
603
|
score?: number | undefined;
|
|
604
|
+
outcome?: FindingOutcome | undefined;
|
|
512
605
|
insights?: {
|
|
513
606
|
meta?: {
|
|
514
607
|
displayValue: string;
|
|
@@ -530,7 +623,6 @@ export declare const _FindingSpecUpsertDto: z.ZodObject<{
|
|
|
530
623
|
} | undefined;
|
|
531
624
|
} | undefined;
|
|
532
625
|
expireAfterDays?: number | null | undefined;
|
|
533
|
-
outcome?: FindingOutcome | undefined;
|
|
534
626
|
}, {
|
|
535
627
|
name: string;
|
|
536
628
|
displayValue: string;
|
|
@@ -544,6 +636,7 @@ export declare const _FindingSpecUpsertDto: z.ZodObject<{
|
|
|
544
636
|
updatedAt?: string | undefined;
|
|
545
637
|
deletedAt?: string | null | undefined;
|
|
546
638
|
score?: number | undefined;
|
|
639
|
+
outcome?: FindingOutcome | undefined;
|
|
547
640
|
insights?: {
|
|
548
641
|
meta?: {
|
|
549
642
|
displayValue: string;
|
|
@@ -565,7 +658,6 @@ export declare const _FindingSpecUpsertDto: z.ZodObject<{
|
|
|
565
658
|
} | undefined;
|
|
566
659
|
} | undefined;
|
|
567
660
|
expireAfterDays?: number | null | undefined;
|
|
568
|
-
outcome?: FindingOutcome | undefined;
|
|
569
661
|
}>;
|
|
570
662
|
export type FindingSpecUpsertDto = z.infer<typeof _FindingSpecUpsertDto>;
|
|
571
663
|
export declare const _FindingSummaryDto: z.ZodObject<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._CustomFindingPayload = exports._FindingSummaryDto = exports._FindingSpecUpsertDto = exports._FindingSpecDto = exports._FindingSpecInsights = exports._FindingBucketSummaryDto = exports._FindingBucketDto = void 0;
|
|
3
|
+
exports._CustomFindingPayload = exports._FindingSummaryDto = exports._FindingSpecUpsertDto = exports._FindingSpecDto = exports._FindingSpecInsights = exports._FindingBucketSummaryDto = exports._FindingDtoSchema = exports._FindingBucketDto = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const base_dto_1 = require("./base.dto");
|
|
6
6
|
const enums_1 = require("./enums");
|
|
@@ -11,6 +11,31 @@ exports._FindingBucketDto = zod_1.z.object({
|
|
|
11
11
|
/** Severity of the bucket */
|
|
12
12
|
score: zod_1.z.number(),
|
|
13
13
|
});
|
|
14
|
+
/**
|
|
15
|
+
* Zod schema for the finding-level keys (BaseDto + FindingUpsertDto).
|
|
16
|
+
* Used to derive template variable paths for Custom Content dynamic variables.
|
|
17
|
+
*/
|
|
18
|
+
// TODO: Use this schema to infer an exported type for the finding entity.
|
|
19
|
+
exports._FindingDtoSchema = base_dto_1._BaseDto.merge(zod_1.z.object({
|
|
20
|
+
discoveredAt: zod_1.z.string().optional(),
|
|
21
|
+
closedAt: zod_1.z.string().optional(),
|
|
22
|
+
category: zod_1.z.string(),
|
|
23
|
+
kind: zod_1.z.string(),
|
|
24
|
+
status: zod_1.z.string(),
|
|
25
|
+
severity: zod_1.z.string(),
|
|
26
|
+
outcome: zod_1.z.string().optional(),
|
|
27
|
+
numberOfEngagements: zod_1.z.number(),
|
|
28
|
+
displayValue: zod_1.z.string(),
|
|
29
|
+
description: zod_1.z.string().optional(),
|
|
30
|
+
cid: zod_1.z.string(),
|
|
31
|
+
pid: zod_1.z.string(),
|
|
32
|
+
aid: zod_1.z.string().nullable().optional(),
|
|
33
|
+
uid: zod_1.z.string().nullable().optional(),
|
|
34
|
+
scid: zod_1.z.string().nullable().optional(),
|
|
35
|
+
fsid: zod_1.z.string().nullable().optional(),
|
|
36
|
+
verificationCount: zod_1.z.number().optional(),
|
|
37
|
+
bucket: exports._FindingBucketDto.optional(),
|
|
38
|
+
}));
|
|
14
39
|
exports._FindingBucketSummaryDto = zod_1.z.object({
|
|
15
40
|
id: zod_1.z.string(),
|
|
16
41
|
uid: zod_1.z.string(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findings.dto.js","sourceRoot":"","sources":["../../../src/dto/findings.dto.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAEtB,yCAA6E;AAC7E,mCAAkF;AAClF,mCAAuE;AAY1D,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,iBAAiB;IACjB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,6BAA6B;IAC7B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"findings.dto.js","sourceRoot":"","sources":["../../../src/dto/findings.dto.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAEtB,yCAA6E;AAC7E,mCAAkF;AAClF,mCAAuE;AAY1D,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,iBAAiB;IACjB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,6BAA6B;IAC7B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAGH;;;GAGG;AACH,0EAA0E;AAC7D,QAAA,iBAAiB,GAAG,mBAAQ,CAAC,KAAK,CAC7C,OAAC,CAAC,MAAM,CAAC;IACP,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE;IAC/B,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;IACxB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ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C,MAAM,CAAC;IAC5C,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;IACrB;;OAEG;IACH,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B;;OAEG;IACH,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B;;OAEG;IACH,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7C,wCAAwC;IACxC,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B;;;OAGG;IACH,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC;;OAEG;IACH,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC/G,CAAC,CAAC"}
|
|
@@ -89,8 +89,8 @@ export declare const _FindingsInsightsDto: z.ZodObject<{
|
|
|
89
89
|
description: string;
|
|
90
90
|
kind: FindingKind;
|
|
91
91
|
title: string;
|
|
92
|
-
severity: FindingSeverity;
|
|
93
92
|
category: Category;
|
|
93
|
+
severity: FindingSeverity;
|
|
94
94
|
number_of_engagements: number;
|
|
95
95
|
active_engagements: {
|
|
96
96
|
status: "SUCCESS" | "RUNNING" | "ERROR" | "CANCELLED" | "EXPIRED";
|
|
@@ -139,8 +139,8 @@ export declare const _FindingsInsightsDto: z.ZodObject<{
|
|
|
139
139
|
description: string;
|
|
140
140
|
kind: FindingKind;
|
|
141
141
|
title: string;
|
|
142
|
-
severity: FindingSeverity;
|
|
143
142
|
category: Category;
|
|
143
|
+
severity: FindingSeverity;
|
|
144
144
|
number_of_engagements: number;
|
|
145
145
|
active_engagements: {
|
|
146
146
|
status: "SUCCESS" | "RUNNING" | "ERROR" | "CANCELLED" | "EXPIRED";
|
|
@@ -133,6 +133,7 @@ export declare const _PlatformFindingSpecDto: z.ZodObject<z.objectUtil.extendSha
|
|
|
133
133
|
description?: unknown;
|
|
134
134
|
cid?: string | null | undefined;
|
|
135
135
|
score?: number | undefined;
|
|
136
|
+
outcome?: import("..").FindingOutcome | undefined;
|
|
136
137
|
insights?: {
|
|
137
138
|
meta?: {
|
|
138
139
|
displayValue: string;
|
|
@@ -154,7 +155,6 @@ export declare const _PlatformFindingSpecDto: z.ZodObject<z.objectUtil.extendSha
|
|
|
154
155
|
} | undefined;
|
|
155
156
|
} | undefined;
|
|
156
157
|
expireAfterDays?: number | null | undefined;
|
|
157
|
-
outcome?: import("..").FindingOutcome | undefined;
|
|
158
158
|
}, {
|
|
159
159
|
name: string;
|
|
160
160
|
id: string;
|
|
@@ -169,6 +169,7 @@ export declare const _PlatformFindingSpecDto: z.ZodObject<z.objectUtil.extendSha
|
|
|
169
169
|
description?: unknown;
|
|
170
170
|
cid?: string | null | undefined;
|
|
171
171
|
score?: number | undefined;
|
|
172
|
+
outcome?: import("..").FindingOutcome | undefined;
|
|
172
173
|
insights?: {
|
|
173
174
|
meta?: {
|
|
174
175
|
displayValue: string;
|
|
@@ -190,7 +191,6 @@ export declare const _PlatformFindingSpecDto: z.ZodObject<z.objectUtil.extendSha
|
|
|
190
191
|
} | undefined;
|
|
191
192
|
} | undefined;
|
|
192
193
|
expireAfterDays?: number | null | undefined;
|
|
193
|
-
outcome?: import("..").FindingOutcome | undefined;
|
|
194
194
|
}>;
|
|
195
195
|
export type PlatformFindingSpecDto = z.infer<typeof _PlatformFindingSpecDto>;
|
|
196
196
|
export declare const _PlatformFindingSpecUpsertDto: z.ZodObject<z.objectUtil.extendShape<{
|
|
@@ -206,6 +206,7 @@ export declare const _PlatformFindingSpecUpsertDto: z.ZodObject<z.objectUtil.ext
|
|
|
206
206
|
eventType: z.ZodString;
|
|
207
207
|
score: z.ZodOptional<z.ZodNumber>;
|
|
208
208
|
severity: z.ZodNativeEnum<typeof import("..").FindingSeverity>;
|
|
209
|
+
outcome: z.ZodOptional<z.ZodNativeEnum<typeof import("..").FindingOutcome>>;
|
|
209
210
|
insights: z.ZodOptional<z.ZodObject<{
|
|
210
211
|
meta: z.ZodOptional<z.ZodObject<{
|
|
211
212
|
kind: z.ZodNativeEnum<typeof import("..").FindingKind>;
|
|
@@ -305,7 +306,6 @@ export declare const _PlatformFindingSpecUpsertDto: z.ZodObject<z.objectUtil.ext
|
|
|
305
306
|
} | undefined;
|
|
306
307
|
}>>;
|
|
307
308
|
expireAfterDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
308
|
-
outcome: z.ZodOptional<z.ZodNativeEnum<typeof import("..").FindingOutcome>>;
|
|
309
309
|
}, {
|
|
310
310
|
tid: z.ZodString;
|
|
311
311
|
}>, "strip", z.ZodTypeAny, {
|
|
@@ -322,6 +322,7 @@ export declare const _PlatformFindingSpecUpsertDto: z.ZodObject<z.objectUtil.ext
|
|
|
322
322
|
updatedAt?: string | undefined;
|
|
323
323
|
deletedAt?: string | null | undefined;
|
|
324
324
|
score?: number | undefined;
|
|
325
|
+
outcome?: import("..").FindingOutcome | undefined;
|
|
325
326
|
insights?: {
|
|
326
327
|
meta?: {
|
|
327
328
|
displayValue: string;
|
|
@@ -343,7 +344,6 @@ export declare const _PlatformFindingSpecUpsertDto: z.ZodObject<z.objectUtil.ext
|
|
|
343
344
|
} | undefined;
|
|
344
345
|
} | undefined;
|
|
345
346
|
expireAfterDays?: number | null | undefined;
|
|
346
|
-
outcome?: import("..").FindingOutcome | undefined;
|
|
347
347
|
}, {
|
|
348
348
|
name: string;
|
|
349
349
|
tid: string;
|
|
@@ -358,6 +358,7 @@ export declare const _PlatformFindingSpecUpsertDto: z.ZodObject<z.objectUtil.ext
|
|
|
358
358
|
updatedAt?: string | undefined;
|
|
359
359
|
deletedAt?: string | null | undefined;
|
|
360
360
|
score?: number | undefined;
|
|
361
|
+
outcome?: import("..").FindingOutcome | undefined;
|
|
361
362
|
insights?: {
|
|
362
363
|
meta?: {
|
|
363
364
|
displayValue: string;
|
|
@@ -379,6 +380,5 @@ export declare const _PlatformFindingSpecUpsertDto: z.ZodObject<z.objectUtil.ext
|
|
|
379
380
|
} | undefined;
|
|
380
381
|
} | undefined;
|
|
381
382
|
expireAfterDays?: number | null | undefined;
|
|
382
|
-
outcome?: import("..").FindingOutcome | undefined;
|
|
383
383
|
}>;
|
|
384
384
|
export type PlatformFindingSpecUpsertDto = z.infer<typeof _PlatformFindingSpecUpsertDto>;
|
|
@@ -20,8 +20,8 @@ export declare const _PlatformWebhookProviderDto: import("zod").ZodObject<import
|
|
|
20
20
|
createdAt: string;
|
|
21
21
|
updatedAt: string;
|
|
22
22
|
deletedAt: string | null;
|
|
23
|
-
enabled: boolean;
|
|
24
23
|
pid: string;
|
|
24
|
+
enabled: boolean;
|
|
25
25
|
supportedEvents: string[];
|
|
26
26
|
description?: string | null | undefined;
|
|
27
27
|
timeout?: number | null | undefined;
|
|
@@ -33,8 +33,8 @@ export declare const _PlatformWebhookProviderDto: import("zod").ZodObject<import
|
|
|
33
33
|
createdAt: string;
|
|
34
34
|
updatedAt: string;
|
|
35
35
|
deletedAt: string | null;
|
|
36
|
-
enabled: boolean;
|
|
37
36
|
pid: string;
|
|
37
|
+
enabled: boolean;
|
|
38
38
|
supportedEvents: string[];
|
|
39
39
|
description?: string | null | undefined;
|
|
40
40
|
timeout?: number | null | undefined;
|
|
@@ -48,16 +48,16 @@ export declare const _PlatformWebhookProviderUpsertDto: import("zod").ZodObject<
|
|
|
48
48
|
createdAt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
49
49
|
updatedAt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
50
50
|
deletedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
51
|
+
pid: import("zod").ZodString;
|
|
51
52
|
timeout: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
52
53
|
enabled: import("zod").ZodBoolean;
|
|
53
54
|
displayName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
54
|
-
pid: import("zod").ZodString;
|
|
55
55
|
supportedEvents: import("zod").ZodArray<import("zod").ZodString, "many">;
|
|
56
56
|
defaultSecret: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
57
57
|
retryAttempts: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
58
58
|
}, "strip", import("zod").ZodTypeAny, {
|
|
59
|
-
enabled: boolean;
|
|
60
59
|
pid: string;
|
|
60
|
+
enabled: boolean;
|
|
61
61
|
supportedEvents: string[];
|
|
62
62
|
description?: string | null | undefined;
|
|
63
63
|
id?: string | undefined;
|
|
@@ -69,8 +69,8 @@ export declare const _PlatformWebhookProviderUpsertDto: import("zod").ZodObject<
|
|
|
69
69
|
defaultSecret?: string | null | undefined;
|
|
70
70
|
retryAttempts?: number | null | undefined;
|
|
71
71
|
}, {
|
|
72
|
-
enabled: boolean;
|
|
73
72
|
pid: string;
|
|
73
|
+
enabled: boolean;
|
|
74
74
|
supportedEvents: string[];
|
|
75
75
|
description?: string | null | undefined;
|
|
76
76
|
id?: string | undefined;
|
|
@@ -18,8 +18,8 @@ export declare const _WebhookProviderDto: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
18
18
|
createdAt: string;
|
|
19
19
|
updatedAt: string;
|
|
20
20
|
deletedAt: string | null;
|
|
21
|
-
enabled: boolean;
|
|
22
21
|
pid: string;
|
|
22
|
+
enabled: boolean;
|
|
23
23
|
supportedEvents: string[];
|
|
24
24
|
description?: string | null | undefined;
|
|
25
25
|
timeout?: number | null | undefined;
|
|
@@ -31,8 +31,8 @@ export declare const _WebhookProviderDto: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
31
31
|
createdAt: string;
|
|
32
32
|
updatedAt: string;
|
|
33
33
|
deletedAt: string | null;
|
|
34
|
-
enabled: boolean;
|
|
35
34
|
pid: string;
|
|
35
|
+
enabled: boolean;
|
|
36
36
|
supportedEvents: string[];
|
|
37
37
|
description?: string | null | undefined;
|
|
38
38
|
timeout?: number | null | undefined;
|
|
@@ -46,16 +46,16 @@ export declare const _WebhookProviderUpsertDto: z.ZodObject<{
|
|
|
46
46
|
createdAt: z.ZodOptional<z.ZodString>;
|
|
47
47
|
updatedAt: z.ZodOptional<z.ZodString>;
|
|
48
48
|
deletedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
pid: z.ZodString;
|
|
49
50
|
timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
50
51
|
enabled: z.ZodBoolean;
|
|
51
52
|
displayName: z.ZodOptional<z.ZodString>;
|
|
52
|
-
pid: z.ZodString;
|
|
53
53
|
supportedEvents: z.ZodArray<z.ZodString, "many">;
|
|
54
54
|
defaultSecret: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
55
|
retryAttempts: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
56
56
|
}, "strip", z.ZodTypeAny, {
|
|
57
|
-
enabled: boolean;
|
|
58
57
|
pid: string;
|
|
58
|
+
enabled: boolean;
|
|
59
59
|
supportedEvents: string[];
|
|
60
60
|
description?: string | null | undefined;
|
|
61
61
|
id?: string | undefined;
|
|
@@ -67,8 +67,8 @@ export declare const _WebhookProviderUpsertDto: z.ZodObject<{
|
|
|
67
67
|
defaultSecret?: string | null | undefined;
|
|
68
68
|
retryAttempts?: number | null | undefined;
|
|
69
69
|
}, {
|
|
70
|
-
enabled: boolean;
|
|
71
70
|
pid: string;
|
|
71
|
+
enabled: boolean;
|
|
72
72
|
supportedEvents: string[];
|
|
73
73
|
description?: string | null | undefined;
|
|
74
74
|
id?: string | undefined;
|
|
@@ -7,4 +7,14 @@ export declare const fillJsonPathTemplate: (raw: string, meta: unknown) => strin
|
|
|
7
7
|
* @note Ensure that meta object does not contain any information that should not be exposed to end users
|
|
8
8
|
*/
|
|
9
9
|
export declare const fillDynamicPropertyTemplate: (rawTemplateString: string, meta: unknown) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Builds the context for dynamic template variables. Exposes the finding and its sub-entities
|
|
12
|
+
* (user, asset, provider, meta) so that any property can be referenced in templates, e.g.
|
|
13
|
+
* {{user.firstName}}, {{finding.displayValue}}, {{meta._vulnerability.cve}}.
|
|
14
|
+
*
|
|
15
|
+
* - Sub-entities can be used without the "finding." prefix (e.g. {{user.firstName}}).
|
|
16
|
+
* - Legacy aliases are preserved: user.email (from user.emails[0]), asset.serialNumber
|
|
17
|
+
* (from meta._asset.sn), asset.macAddress (from meta._asset.macs[0]).
|
|
18
|
+
* - Arrays resolved in templates use the first element (see getTemplateValue).
|
|
19
|
+
*/
|
|
10
20
|
export declare const buildDynamicVariablesContext: (finding: FindingDto) => Map<string, unknown>;
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.buildDynamicVariablesContext = exports.fillDynamicPropertyTemplate = exports.fillJsonPathTemplate = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const constants_1 = require("./constants");
|
|
9
8
|
const JSON_PATH_PATTERN = /(\$\.(?:(?:[a-zA-Z0-9_]+)(?:\.[a-zA-Z0-9_]+)*)?)/g;
|
|
10
9
|
const DYNAMIC_PROPERTY_PATTERN = /\{\{([^}]+)\}\}/g;
|
|
11
10
|
// @deprecated : consider using fillDynamicPropertyTemplate
|
|
@@ -25,6 +24,17 @@ const fillJsonPathTemplate = (raw, meta) => {
|
|
|
25
24
|
return result;
|
|
26
25
|
};
|
|
27
26
|
exports.fillJsonPathTemplate = fillJsonPathTemplate;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a value from meta at the given path. When the resolved value is an array,
|
|
29
|
+
* returns the first element (for backwards compatibility with paths like user.emails[0]).
|
|
30
|
+
*/
|
|
31
|
+
const getTemplateValue = (meta, path) => {
|
|
32
|
+
const value = lodash_1.default.get(meta, path, undefined);
|
|
33
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
34
|
+
return value[0];
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
28
38
|
/**
|
|
29
39
|
* @param rawTemplateString Template string with placeholders in the format of {{path.to.value}}
|
|
30
40
|
* @param meta object containing the values to replace the placeholders
|
|
@@ -37,10 +47,10 @@ const fillDynamicPropertyTemplate = (rawTemplateString, meta) => {
|
|
|
37
47
|
if (matches) {
|
|
38
48
|
matches.forEach(placeholder => {
|
|
39
49
|
const path = placeholder.slice(2, -2).trim();
|
|
40
|
-
const value =
|
|
50
|
+
const value = getTemplateValue(meta, path);
|
|
41
51
|
if (lodash_1.default.isString(value) || lodash_1.default.isNumber(value) || lodash_1.default.isBoolean(value)) {
|
|
42
52
|
// primitive value type is replaced as is
|
|
43
|
-
result = result.replace(placeholder, value);
|
|
53
|
+
result = result.replace(placeholder, String(value));
|
|
44
54
|
}
|
|
45
55
|
else if (lodash_1.default.isObject(value) || lodash_1.default.isArray(value)) {
|
|
46
56
|
// object and array values are stringified
|
|
@@ -55,31 +65,47 @@ const fillDynamicPropertyTemplate = (rawTemplateString, meta) => {
|
|
|
55
65
|
return result;
|
|
56
66
|
};
|
|
57
67
|
exports.fillDynamicPropertyTemplate = fillDynamicPropertyTemplate;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Builds the context for dynamic template variables. Exposes the finding and its sub-entities
|
|
70
|
+
* (user, asset, provider, meta) so that any property can be referenced in templates, e.g.
|
|
71
|
+
* {{user.firstName}}, {{finding.displayValue}}, {{meta._vulnerability.cve}}.
|
|
72
|
+
*
|
|
73
|
+
* - Sub-entities can be used without the "finding." prefix (e.g. {{user.firstName}}).
|
|
74
|
+
* - Legacy aliases are preserved: user.email (from user.emails[0]), asset.serialNumber
|
|
75
|
+
* (from meta._asset.sn), asset.macAddress (from meta._asset.macs[0]).
|
|
76
|
+
* - Arrays resolved in templates use the first element (see getTemplateValue).
|
|
77
|
+
*/
|
|
66
78
|
const buildDynamicVariablesContext = (finding) => {
|
|
79
|
+
var _a, _b;
|
|
67
80
|
const entityMap = new Map();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
// Full finding at "finding" so {{finding.displayValue}}, {{finding.discoveredAt}}, etc. work
|
|
82
|
+
entityMap.set('finding', finding);
|
|
83
|
+
// User: full object + legacy alias "email" from user.emails[0]
|
|
84
|
+
const userEntity = finding.user
|
|
85
|
+
? {
|
|
86
|
+
...finding.user,
|
|
87
|
+
...(Array.isArray(finding.user.emails) && {
|
|
88
|
+
email: finding.user.emails[0],
|
|
89
|
+
}),
|
|
74
90
|
}
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
: {};
|
|
92
|
+
entityMap.set('user', userEntity);
|
|
93
|
+
// Asset: full object + legacy keys from meta (serialNumber, macAddress)
|
|
94
|
+
const assetEntity = finding.asset
|
|
95
|
+
? {
|
|
96
|
+
...finding.asset,
|
|
97
|
+
...(lodash_1.default.get(finding, 'meta._asset.sn') !== undefined && {
|
|
98
|
+
serialNumber: lodash_1.default.get(finding, 'meta._asset.sn'),
|
|
99
|
+
}),
|
|
100
|
+
...(lodash_1.default.get(finding, 'meta._asset.macs[0]') !== undefined && {
|
|
101
|
+
macAddress: lodash_1.default.get(finding, 'meta._asset.macs[0]'),
|
|
102
|
+
}),
|
|
77
103
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
104
|
+
: {};
|
|
105
|
+
entityMap.set('asset', assetEntity);
|
|
106
|
+
// Provider and meta: pass through when present
|
|
107
|
+
entityMap.set('provider', (_a = finding.provider) !== null && _a !== void 0 ? _a : {});
|
|
108
|
+
entityMap.set('meta', (_b = finding.meta) !== null && _b !== void 0 ? _b : {});
|
|
83
109
|
return entityMap;
|
|
84
110
|
};
|
|
85
111
|
exports.buildDynamicVariablesContext = buildDynamicVariablesContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentTemplateService.js","sourceRoot":"","sources":["../../../src/services/ContentTemplateService.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;
|
|
1
|
+
{"version":3,"file":"ContentTemplateService.js","sourceRoot":"","sources":["../../../src/services/ContentTemplateService.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAGvB,MAAM,iBAAiB,GAAG,mDAAmD,CAAC;AAC9E,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAEpD,2DAA2D;AACpD,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,IAAa,EAAE,EAAE;IACjE,MAAM,eAAe,GAAG,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrD,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,IAAI,eAAe,EAAE,CAAC;QACpB,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,KAAK,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YACnC,IAAI,CAAC,gBAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;YACD,MAAM,GAAG,MAAM,CAAC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ACpD,YAAY,EAAE,gBAAC,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC;aAC/C,CAAC;YACF,GAAG,CAAC,gBAAC,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAqB,CAAC,KAAK,SAAS,IAAI;gBACzD,UAAU,EAAE,gBAAC,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAqB,CAAC;aAClD,CAAC;SACH;QACH,CAAC,CAAC,EAAE,CAAC;IACP,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAEpC,+CAA+C;IAC/C,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,MAAA,OAAO,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC;IAClD,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,MAAA,OAAO,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC;IAE1C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AApCW,QAAA,4BAA4B,gCAoCvC"}
|
package/package.json
CHANGED
package/src/dto/findings.dto.ts
CHANGED
|
@@ -22,6 +22,34 @@ export const _FindingBucketDto = z.object({
|
|
|
22
22
|
});
|
|
23
23
|
export type FindingBucketDto = z.infer<typeof _FindingBucketDto>;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Zod schema for the finding-level keys (BaseDto + FindingUpsertDto).
|
|
27
|
+
* Used to derive template variable paths for Custom Content dynamic variables.
|
|
28
|
+
*/
|
|
29
|
+
// TODO: Use this schema to infer an exported type for the finding entity.
|
|
30
|
+
export const _FindingDtoSchema = _BaseDto.merge(
|
|
31
|
+
z.object({
|
|
32
|
+
discoveredAt: z.string().optional(),
|
|
33
|
+
closedAt: z.string().optional(),
|
|
34
|
+
category: z.string(),
|
|
35
|
+
kind: z.string(),
|
|
36
|
+
status: z.string(),
|
|
37
|
+
severity: z.string(),
|
|
38
|
+
outcome: z.string().optional(),
|
|
39
|
+
numberOfEngagements: z.number(),
|
|
40
|
+
displayValue: z.string(),
|
|
41
|
+
description: z.string().optional(),
|
|
42
|
+
cid: z.string(),
|
|
43
|
+
pid: z.string(),
|
|
44
|
+
aid: z.string().nullable().optional(),
|
|
45
|
+
uid: z.string().nullable().optional(),
|
|
46
|
+
scid: z.string().nullable().optional(),
|
|
47
|
+
fsid: z.string().nullable().optional(),
|
|
48
|
+
verificationCount: z.number().optional(),
|
|
49
|
+
bucket: _FindingBucketDto.optional(),
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
|
|
25
53
|
export type FindingUpsertDto = BaseUpsertDto & {
|
|
26
54
|
/** Date the finding was discoverd by the integration */
|
|
27
55
|
discoveredAt?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import {DYNAMIC_VARIABLES} from './constants';
|
|
3
2
|
import {FindingDto} from '../dto';
|
|
3
|
+
|
|
4
4
|
const JSON_PATH_PATTERN = /(\$\.(?:(?:[a-zA-Z0-9_]+)(?:\.[a-zA-Z0-9_]+)*)?)/g;
|
|
5
5
|
const DYNAMIC_PROPERTY_PATTERN = /\{\{([^}]+)\}\}/g;
|
|
6
6
|
|
|
@@ -21,6 +21,18 @@ export const fillJsonPathTemplate = (raw: string, meta: unknown) => {
|
|
|
21
21
|
return result;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Resolves a value from meta at the given path. When the resolved value is an array,
|
|
26
|
+
* returns the first element (for backwards compatibility with paths like user.emails[0]).
|
|
27
|
+
*/
|
|
28
|
+
const getTemplateValue = (meta: unknown, path: string): unknown => {
|
|
29
|
+
const value: unknown = _.get(meta, path, undefined);
|
|
30
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
31
|
+
return value[0];
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
|
|
24
36
|
/**
|
|
25
37
|
* @param rawTemplateString Template string with placeholders in the format of {{path.to.value}}
|
|
26
38
|
* @param meta object containing the values to replace the placeholders
|
|
@@ -33,10 +45,10 @@ export const fillDynamicPropertyTemplate = (rawTemplateString: string, meta: unk
|
|
|
33
45
|
if (matches) {
|
|
34
46
|
matches.forEach(placeholder => {
|
|
35
47
|
const path = placeholder.slice(2, -2).trim();
|
|
36
|
-
const value =
|
|
48
|
+
const value = getTemplateValue(meta, path);
|
|
37
49
|
if (_.isString(value) || _.isNumber(value) || _.isBoolean(value)) {
|
|
38
50
|
// primitive value type is replaced as is
|
|
39
|
-
result = result.replace(placeholder, value);
|
|
51
|
+
result = result.replace(placeholder, String(value));
|
|
40
52
|
} else if (_.isObject(value) || _.isArray(value)) {
|
|
41
53
|
// object and array values are stringified
|
|
42
54
|
result = result.replace(placeholder, JSON.stringify(value, null, 2));
|
|
@@ -49,39 +61,50 @@ export const fillDynamicPropertyTemplate = (rawTemplateString: string, meta: unk
|
|
|
49
61
|
return result;
|
|
50
62
|
};
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return entityData;
|
|
64
|
-
};
|
|
65
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Builds the context for dynamic template variables. Exposes the finding and its sub-entities
|
|
66
|
+
* (user, asset, provider, meta) so that any property can be referenced in templates, e.g.
|
|
67
|
+
* {{user.firstName}}, {{finding.displayValue}}, {{meta._vulnerability.cve}}.
|
|
68
|
+
*
|
|
69
|
+
* - Sub-entities can be used without the "finding." prefix (e.g. {{user.firstName}}).
|
|
70
|
+
* - Legacy aliases are preserved: user.email (from user.emails[0]), asset.serialNumber
|
|
71
|
+
* (from meta._asset.sn), asset.macAddress (from meta._asset.macs[0]).
|
|
72
|
+
* - Arrays resolved in templates use the first element (see getTemplateValue).
|
|
73
|
+
*/
|
|
66
74
|
export const buildDynamicVariablesContext = (finding: FindingDto): Map<string, unknown> => {
|
|
67
|
-
const entityMap
|
|
75
|
+
const entityMap = new Map<string, unknown>();
|
|
68
76
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const entityProperties = DYNAMIC_VARIABLES.ALLOWED_ENTITY_KEYS[entityKey as keyof typeof DYNAMIC_VARIABLES.ALLOWED_ENTITY_KEYS];
|
|
77
|
+
// Full finding at "finding" so {{finding.displayValue}}, {{finding.discoveredAt}}, etc. work
|
|
78
|
+
entityMap.set('finding', finding);
|
|
72
79
|
|
|
73
|
-
|
|
80
|
+
// User: full object + legacy alias "email" from user.emails[0]
|
|
81
|
+
const userEntity = finding.user
|
|
82
|
+
? {
|
|
83
|
+
...finding.user,
|
|
84
|
+
...(Array.isArray((finding.user as {emails?: string[]}).emails) && {
|
|
85
|
+
email: (finding.user as {emails: string[]}).emails[0],
|
|
86
|
+
}),
|
|
87
|
+
}
|
|
88
|
+
: {};
|
|
89
|
+
entityMap.set('user', userEntity);
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
// Asset: full object + legacy keys from meta (serialNumber, macAddress)
|
|
92
|
+
const assetEntity = finding.asset
|
|
93
|
+
? {
|
|
94
|
+
...finding.asset,
|
|
95
|
+
...(_.get(finding, 'meta._asset.sn') !== undefined && {
|
|
96
|
+
serialNumber: _.get(finding, 'meta._asset.sn'),
|
|
97
|
+
}),
|
|
98
|
+
...(_.get(finding, 'meta._asset.macs[0]') !== undefined && {
|
|
99
|
+
macAddress: _.get(finding, 'meta._asset.macs[0]'),
|
|
100
|
+
}),
|
|
101
|
+
}
|
|
102
|
+
: {};
|
|
103
|
+
entityMap.set('asset', assetEntity);
|
|
82
104
|
|
|
83
|
-
|
|
84
|
-
}
|
|
105
|
+
// Provider and meta: pass through when present
|
|
106
|
+
entityMap.set('provider', finding.provider ?? {});
|
|
107
|
+
entityMap.set('meta', finding.meta ?? {});
|
|
85
108
|
|
|
86
109
|
return entityMap;
|
|
87
110
|
};
|