@ampsec/platform-client 62.22.0 → 62.24.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/customScores.dto.js +1 -1
- package/build/src/dto/customScores.dto.js.map +1 -1
- package/build/src/dto/enums/category.d.ts +2 -1
- package/build/src/dto/enums/category.js +1 -0
- package/build/src/dto/enums/category.js.map +1 -1
- package/build/src/dto/enums/findingKind.d.ts +21 -0
- package/build/src/dto/enums/findingKind.js +71 -1
- package/build/src/dto/enums/findingKind.js.map +1 -1
- package/build/src/dto/enums/saasComponentKind.d.ts +2 -1
- package/build/src/dto/enums/saasComponentKind.js +2 -0
- package/build/src/dto/enums/saasComponentKind.js.map +1 -1
- package/build/src/dto/findings.dto.d.ts +67 -41
- package/build/src/dto/findings.dto.js +17 -5
- package/build/src/dto/findings.dto.js.map +1 -1
- package/build/src/dto/index.d.ts +1 -0
- package/build/src/dto/index.js +1 -0
- package/build/src/dto/index.js.map +1 -1
- package/build/src/dto/platform/index.d.ts +1 -0
- package/build/src/dto/platform/index.js +1 -0
- package/build/src/dto/platform/index.js.map +1 -1
- package/build/src/dto/platform/platform.findings.dto.d.ts +46 -40
- package/build/src/dto/platform/platform.tokens.dto.d.ts +53 -0
- package/build/src/dto/platform/platform.tokens.dto.js +8 -0
- package/build/src/dto/platform/platform.tokens.dto.js.map +1 -0
- package/build/src/dto/saasComponents.dto.d.ts +1 -1
- package/build/src/dto/tokens.dto.d.ts +47 -0
- package/build/src/dto/tokens.dto.js +11 -0
- package/build/src/dto/tokens.dto.js.map +1 -0
- package/build/src/services/AmpApi.d.ts +2 -1
- package/build/src/services/AmpApi.js +1 -0
- package/build/src/services/AmpApi.js.map +1 -1
- package/build/src/services/AmpSdk.d.ts +2 -1
- package/build/src/services/AmpSdk.js +1 -0
- package/build/src/services/AmpSdk.js.map +1 -1
- package/build/src/services/ContentTemplateService.d.ts +1 -0
- package/build/src/services/ContentTemplateService.js +25 -0
- package/build/src/services/ContentTemplateService.js.map +1 -0
- package/build/src/services/constants.d.ts +1 -0
- package/build/src/services/constants.js +1 -0
- package/build/src/services/constants.js.map +1 -1
- package/build/src/services/contentful.service.d.ts +272 -1
- package/build/src/services/contentful.service.js +197 -2
- package/build/src/services/contentful.service.js.map +1 -1
- package/build/src/services/index.d.ts +1 -0
- package/build/src/services/index.js +1 -0
- package/build/src/services/index.js.map +1 -1
- package/package.json +2 -2
- package/src/dto/customScores.dto.ts +1 -1
- package/src/dto/enums/category.ts +1 -0
- package/src/dto/enums/findingKind.ts +71 -0
- package/src/dto/enums/saasComponentKind.ts +3 -0
- package/src/dto/findings.dto.ts +36 -22
- package/src/dto/index.ts +1 -0
- package/src/dto/platform/index.ts +1 -0
- package/src/dto/platform/platform.tokens.dto.ts +9 -0
- package/src/dto/saasComponents.dto.ts +1 -1
- package/src/dto/tokens.dto.ts +11 -0
- package/src/services/AmpApi.ts +3 -0
- package/src/services/AmpSdk.ts +4 -0
- package/src/services/ContentTemplateService.ts +18 -0
- package/src/services/constants.ts +1 -0
- package/src/services/contentful.service.ts +238 -1
- package/src/services/index.ts +1 -0
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import type { Entry, EntrySkeletonType, EntryFieldTypes, EntryCollection, ContentfulClientApi } from 'contentful/dist/types';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use ContentService and MessageTemplateContent instead
|
|
5
|
+
*/
|
|
2
6
|
export type MessageTemplate = EntrySkeletonType & {
|
|
3
7
|
contentTypeId: 'messageTemplate';
|
|
4
8
|
fields: {
|
|
@@ -9,6 +13,8 @@ export type MessageTemplate = EntrySkeletonType & {
|
|
|
9
13
|
};
|
|
10
14
|
};
|
|
11
15
|
/**
|
|
16
|
+
* @deprecated Use ContentService instead
|
|
17
|
+
*
|
|
12
18
|
* ContentfulService
|
|
13
19
|
*
|
|
14
20
|
* This client is a wrapper around the Contentful REST API meant to be used by
|
|
@@ -30,6 +36,271 @@ export declare class ContentfulService {
|
|
|
30
36
|
*/
|
|
31
37
|
constructor();
|
|
32
38
|
getMessageTemplates: () => Promise<EntryCollection<MessageTemplate>>;
|
|
33
|
-
getContentfulEntries: <T extends EntrySkeletonType>(contentType: string, include?: number) => Promise<EntryCollection<T>>;
|
|
39
|
+
getContentfulEntries: <T extends EntrySkeletonType>(contentType: string, include?: number, skip?: number, limit?: number) => Promise<EntryCollection<T>>;
|
|
34
40
|
getContentfulEntry: <T extends EntrySkeletonType>(entryId: string) => Promise<Entry<T>>;
|
|
35
41
|
}
|
|
42
|
+
export declare enum ContentType {
|
|
43
|
+
MESSAGE_TEMPLATE = "messageTemplate",
|
|
44
|
+
BACKEND_CONTENT = "backendContent",
|
|
45
|
+
SERVICE_PROFILE = "serviceProfile",
|
|
46
|
+
INTEGRATION = "integration",
|
|
47
|
+
INTEGRATION_DOMAIN = "integrationDomain",
|
|
48
|
+
FINDING = "finding",
|
|
49
|
+
SECURITY_HUB_I18N = "securityHubI18n"
|
|
50
|
+
}
|
|
51
|
+
export type ContentOptions = {
|
|
52
|
+
include?: number;
|
|
53
|
+
serviceFilter?: string | string[];
|
|
54
|
+
useCaseFilter?: string | string[];
|
|
55
|
+
};
|
|
56
|
+
declare const _BackendContent: z.ZodObject<{
|
|
57
|
+
key: z.ZodString;
|
|
58
|
+
value: z.ZodString;
|
|
59
|
+
serviceFilter: z.ZodArray<z.ZodString, "many">;
|
|
60
|
+
useCaseFilter: z.ZodArray<z.ZodString, "many">;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
value: string;
|
|
63
|
+
key: string;
|
|
64
|
+
serviceFilter: string[];
|
|
65
|
+
useCaseFilter: string[];
|
|
66
|
+
}, {
|
|
67
|
+
value: string;
|
|
68
|
+
key: string;
|
|
69
|
+
serviceFilter: string[];
|
|
70
|
+
useCaseFilter: string[];
|
|
71
|
+
}>;
|
|
72
|
+
export type BackendContent = z.infer<typeof _BackendContent>;
|
|
73
|
+
declare const _ServiceProfile: z.ZodObject<{
|
|
74
|
+
serviceKey: z.ZodString;
|
|
75
|
+
displayValue: z.ZodString;
|
|
76
|
+
logo: z.ZodString;
|
|
77
|
+
aliases: z.ZodArray<z.ZodString, "many">;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
displayValue: string;
|
|
80
|
+
serviceKey: string;
|
|
81
|
+
logo: string;
|
|
82
|
+
aliases: string[];
|
|
83
|
+
}, {
|
|
84
|
+
displayValue: string;
|
|
85
|
+
serviceKey: string;
|
|
86
|
+
logo: string;
|
|
87
|
+
aliases: string[];
|
|
88
|
+
}>;
|
|
89
|
+
export type ServiceProfile = z.infer<typeof _ServiceProfile>;
|
|
90
|
+
declare const _IntegrationDomain: z.ZodObject<{
|
|
91
|
+
name: z.ZodString;
|
|
92
|
+
domain: z.ZodString;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
name: string;
|
|
95
|
+
domain: string;
|
|
96
|
+
}, {
|
|
97
|
+
name: string;
|
|
98
|
+
domain: string;
|
|
99
|
+
}>;
|
|
100
|
+
export type IntegrationDomain = z.infer<typeof _IntegrationDomain>;
|
|
101
|
+
declare const _FindingContent: z.ZodObject<{
|
|
102
|
+
kind: z.ZodString;
|
|
103
|
+
title: z.ZodString;
|
|
104
|
+
displayText: z.ZodOptional<z.ZodString>;
|
|
105
|
+
timeToComplete: z.ZodOptional<z.ZodString>;
|
|
106
|
+
instructions: z.ZodType<EntryFieldTypes.RichText, z.ZodTypeDef, EntryFieldTypes.RichText>;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
title: string;
|
|
109
|
+
kind: string;
|
|
110
|
+
instructions: EntryFieldTypes.RichText;
|
|
111
|
+
displayText?: string | undefined;
|
|
112
|
+
timeToComplete?: string | undefined;
|
|
113
|
+
}, {
|
|
114
|
+
title: string;
|
|
115
|
+
kind: string;
|
|
116
|
+
instructions: EntryFieldTypes.RichText;
|
|
117
|
+
displayText?: string | undefined;
|
|
118
|
+
timeToComplete?: string | undefined;
|
|
119
|
+
}>;
|
|
120
|
+
export type FindingContent = z.infer<typeof _FindingContent>;
|
|
121
|
+
declare const _Integration: z.ZodObject<{
|
|
122
|
+
name: z.ZodString;
|
|
123
|
+
providerKey: z.ZodString;
|
|
124
|
+
logo: z.ZodString;
|
|
125
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
126
|
+
tileDescription: z.ZodString;
|
|
127
|
+
overview: z.ZodString;
|
|
128
|
+
installationInstructions: z.ZodType<EntryFieldTypes.RichText, z.ZodTypeDef, EntryFieldTypes.RichText>;
|
|
129
|
+
termsOfUseLink: z.ZodOptional<z.ZodString>;
|
|
130
|
+
privacyStatementLink: z.ZodOptional<z.ZodString>;
|
|
131
|
+
supportLink: z.ZodOptional<z.ZodString>;
|
|
132
|
+
formTextKeys: z.ZodUnknown;
|
|
133
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodOptional<z.ZodString>, "many">>;
|
|
134
|
+
overviewLong: z.ZodString;
|
|
135
|
+
installModalDynamicTabs: z.ZodUnknown;
|
|
136
|
+
overviewRichText: z.ZodType<EntryFieldTypes.RichText, z.ZodTypeDef, EntryFieldTypes.RichText>;
|
|
137
|
+
findings: z.ZodObject<{
|
|
138
|
+
kind: z.ZodString;
|
|
139
|
+
title: z.ZodString;
|
|
140
|
+
displayText: z.ZodOptional<z.ZodString>;
|
|
141
|
+
timeToComplete: z.ZodOptional<z.ZodString>;
|
|
142
|
+
instructions: z.ZodType<EntryFieldTypes.RichText, z.ZodTypeDef, EntryFieldTypes.RichText>;
|
|
143
|
+
}, "strip", z.ZodTypeAny, {
|
|
144
|
+
title: string;
|
|
145
|
+
kind: string;
|
|
146
|
+
instructions: EntryFieldTypes.RichText;
|
|
147
|
+
displayText?: string | undefined;
|
|
148
|
+
timeToComplete?: string | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
title: string;
|
|
151
|
+
kind: string;
|
|
152
|
+
instructions: EntryFieldTypes.RichText;
|
|
153
|
+
displayText?: string | undefined;
|
|
154
|
+
timeToComplete?: string | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
domains: z.ZodArray<z.ZodObject<{
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
domain: z.ZodString;
|
|
159
|
+
}, "strip", z.ZodTypeAny, {
|
|
160
|
+
name: string;
|
|
161
|
+
domain: string;
|
|
162
|
+
}, {
|
|
163
|
+
name: string;
|
|
164
|
+
domain: string;
|
|
165
|
+
}>, "many">;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
name: string;
|
|
168
|
+
findings: {
|
|
169
|
+
title: string;
|
|
170
|
+
kind: string;
|
|
171
|
+
instructions: EntryFieldTypes.RichText;
|
|
172
|
+
displayText?: string | undefined;
|
|
173
|
+
timeToComplete?: string | undefined;
|
|
174
|
+
};
|
|
175
|
+
tags: (string | undefined)[];
|
|
176
|
+
logo: string;
|
|
177
|
+
providerKey: string;
|
|
178
|
+
tileDescription: string;
|
|
179
|
+
overview: string;
|
|
180
|
+
installationInstructions: EntryFieldTypes.RichText;
|
|
181
|
+
overviewLong: string;
|
|
182
|
+
overviewRichText: EntryFieldTypes.RichText;
|
|
183
|
+
domains: {
|
|
184
|
+
name: string;
|
|
185
|
+
domain: string;
|
|
186
|
+
}[];
|
|
187
|
+
icon?: string | undefined;
|
|
188
|
+
termsOfUseLink?: string | undefined;
|
|
189
|
+
privacyStatementLink?: string | undefined;
|
|
190
|
+
supportLink?: string | undefined;
|
|
191
|
+
formTextKeys?: unknown;
|
|
192
|
+
installModalDynamicTabs?: unknown;
|
|
193
|
+
}, {
|
|
194
|
+
name: string;
|
|
195
|
+
findings: {
|
|
196
|
+
title: string;
|
|
197
|
+
kind: string;
|
|
198
|
+
instructions: EntryFieldTypes.RichText;
|
|
199
|
+
displayText?: string | undefined;
|
|
200
|
+
timeToComplete?: string | undefined;
|
|
201
|
+
};
|
|
202
|
+
logo: string;
|
|
203
|
+
providerKey: string;
|
|
204
|
+
tileDescription: string;
|
|
205
|
+
overview: string;
|
|
206
|
+
installationInstructions: EntryFieldTypes.RichText;
|
|
207
|
+
overviewLong: string;
|
|
208
|
+
overviewRichText: EntryFieldTypes.RichText;
|
|
209
|
+
domains: {
|
|
210
|
+
name: string;
|
|
211
|
+
domain: string;
|
|
212
|
+
}[];
|
|
213
|
+
icon?: string | undefined;
|
|
214
|
+
termsOfUseLink?: string | undefined;
|
|
215
|
+
privacyStatementLink?: string | undefined;
|
|
216
|
+
supportLink?: string | undefined;
|
|
217
|
+
formTextKeys?: unknown;
|
|
218
|
+
tags?: (string | undefined)[] | undefined;
|
|
219
|
+
installModalDynamicTabs?: unknown;
|
|
220
|
+
}>;
|
|
221
|
+
export type Integration = z.infer<typeof _Integration>;
|
|
222
|
+
declare const _I18nContent: z.ZodObject<{
|
|
223
|
+
key: z.ZodString;
|
|
224
|
+
value: z.ZodString;
|
|
225
|
+
useCaseFilter: z.ZodArray<z.ZodString, "many">;
|
|
226
|
+
}, "strip", z.ZodTypeAny, {
|
|
227
|
+
value: string;
|
|
228
|
+
key: string;
|
|
229
|
+
useCaseFilter: string[];
|
|
230
|
+
}, {
|
|
231
|
+
value: string;
|
|
232
|
+
key: string;
|
|
233
|
+
useCaseFilter: string[];
|
|
234
|
+
}>;
|
|
235
|
+
export type I18nContent = z.infer<typeof _I18nContent>;
|
|
236
|
+
declare const _MessageTemplateContent: z.ZodObject<{
|
|
237
|
+
id: z.ZodString;
|
|
238
|
+
body: z.ZodString;
|
|
239
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
240
|
+
}, "strip", z.ZodTypeAny, {
|
|
241
|
+
id: string;
|
|
242
|
+
body: string;
|
|
243
|
+
subject?: string | undefined;
|
|
244
|
+
}, {
|
|
245
|
+
id: string;
|
|
246
|
+
body: string;
|
|
247
|
+
subject?: string | undefined;
|
|
248
|
+
}>;
|
|
249
|
+
export type MessageTemplateContent = z.infer<typeof _MessageTemplateContent>;
|
|
250
|
+
export declare class ContentService {
|
|
251
|
+
private readonly contentfulService;
|
|
252
|
+
private constructor();
|
|
253
|
+
getEntries: (contentType: ContentType, options: ContentOptions) => Promise<unknown[]>;
|
|
254
|
+
getBackendContent: (options?: ContentOptions) => Promise<BackendContent[]>;
|
|
255
|
+
getMessageTemplates: () => Promise<MessageTemplateContent[]>;
|
|
256
|
+
getIntegrationDomains: (options?: ContentOptions) => Promise<IntegrationDomain[]>;
|
|
257
|
+
private mapIntegrationDomain;
|
|
258
|
+
getFindings: (options?: ContentOptions) => Promise<FindingContent[]>;
|
|
259
|
+
private mapFindings;
|
|
260
|
+
getIntegrations: (options?: ContentOptions) => Promise<Integration[]>;
|
|
261
|
+
getServiceProfiles: (options?: ContentOptions) => Promise<ServiceProfile[]>;
|
|
262
|
+
getI18nContent: (options?: ContentOptions) => Promise<I18nContent[]>;
|
|
263
|
+
static instance(): ContentService;
|
|
264
|
+
}
|
|
265
|
+
export declare class I18nContentService {
|
|
266
|
+
private readonly contentService;
|
|
267
|
+
private content;
|
|
268
|
+
private isInitialized;
|
|
269
|
+
private constructor();
|
|
270
|
+
init: () => Promise<I18nContentService>;
|
|
271
|
+
refresh: () => Promise<I18nContentService>;
|
|
272
|
+
/**
|
|
273
|
+
* Example Usage:
|
|
274
|
+
* ```ts
|
|
275
|
+
* const i18n = await i18nContentService.instance();
|
|
276
|
+
* await i18n.init();
|
|
277
|
+
* const value = i18n.g('LOADING', 'Loading...');
|
|
278
|
+
* ```
|
|
279
|
+
* @param key
|
|
280
|
+
* @param defaultValue
|
|
281
|
+
* @returns
|
|
282
|
+
*/
|
|
283
|
+
g: (key: string, defaultValue?: string) => string;
|
|
284
|
+
/**
|
|
285
|
+
* Example Usage:
|
|
286
|
+
* ```ts
|
|
287
|
+
* const i18n = await I18nContentService.instance();
|
|
288
|
+
* await i18n.init();
|
|
289
|
+
* const t = i18n.getLookupFunction();
|
|
290
|
+
* const value = t('LOADING', 'Loading...');
|
|
291
|
+
* // or more simply
|
|
292
|
+
* return <div>{t('Loading...')}</div>
|
|
293
|
+
* // Note this can be use to extend functionality of a Typography component, e.g.
|
|
294
|
+
* const MyTypography = (props: {children: string}) => <Typography>{t(props.children)}</Typography>
|
|
295
|
+
* return <MyTypography>Loading...</MyTypography>
|
|
296
|
+
* ```
|
|
297
|
+
* @returns
|
|
298
|
+
*/
|
|
299
|
+
getLookupFunction: () => (key: string, defaultValue?: string) => string;
|
|
300
|
+
private static _instance;
|
|
301
|
+
static instance(_options?: {
|
|
302
|
+
locale?: 'en';
|
|
303
|
+
useCaseFilter?: string | string[];
|
|
304
|
+
}): I18nContentService;
|
|
305
|
+
}
|
|
306
|
+
export {};
|
|
@@ -22,10 +22,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ContentfulService = void 0;
|
|
29
|
+
exports.I18nContentService = exports.ContentService = exports.ContentType = exports.ContentfulService = void 0;
|
|
30
|
+
const zod_1 = require("zod");
|
|
27
31
|
const contentful = __importStar(require("contentful"));
|
|
32
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
28
33
|
/**
|
|
34
|
+
* @deprecated Use ContentService instead
|
|
35
|
+
*
|
|
29
36
|
* ContentfulService
|
|
30
37
|
*
|
|
31
38
|
* This client is a wrapper around the Contentful REST API meant to be used by
|
|
@@ -49,12 +56,14 @@ class ContentfulService {
|
|
|
49
56
|
const messageTemplates = await this.getContentfulEntries('messageTemplate', 0);
|
|
50
57
|
return messageTemplates;
|
|
51
58
|
};
|
|
52
|
-
this.getContentfulEntries = async (contentType, include) => {
|
|
59
|
+
this.getContentfulEntries = async (contentType, include, skip, limit) => {
|
|
53
60
|
if (!this.contentfulClient) {
|
|
54
61
|
throw new Error('Contenful client not initialized because of missing configurations: CONTENTFUL_SPACE_ID and CONTENTFUL_ACCESS_TOKEN must be set in the environment');
|
|
55
62
|
}
|
|
56
63
|
const entries = await this.contentfulClient.getEntries({
|
|
57
64
|
content_type: contentType,
|
|
65
|
+
skip,
|
|
66
|
+
limit,
|
|
58
67
|
...(include ? { include } : {}),
|
|
59
68
|
});
|
|
60
69
|
return entries;
|
|
@@ -78,4 +87,190 @@ class ContentfulService {
|
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
exports.ContentfulService = ContentfulService;
|
|
90
|
+
var ContentType;
|
|
91
|
+
(function (ContentType) {
|
|
92
|
+
ContentType["MESSAGE_TEMPLATE"] = "messageTemplate";
|
|
93
|
+
ContentType["BACKEND_CONTENT"] = "backendContent";
|
|
94
|
+
ContentType["SERVICE_PROFILE"] = "serviceProfile";
|
|
95
|
+
ContentType["INTEGRATION"] = "integration";
|
|
96
|
+
ContentType["INTEGRATION_DOMAIN"] = "integrationDomain";
|
|
97
|
+
ContentType["FINDING"] = "finding";
|
|
98
|
+
ContentType["SECURITY_HUB_I18N"] = "securityHubI18n";
|
|
99
|
+
})(ContentType || (exports.ContentType = ContentType = {}));
|
|
100
|
+
const ContentfulRichText = zod_1.z.any();
|
|
101
|
+
const _BackendContent = zod_1.z.object({
|
|
102
|
+
key: zod_1.z.string(),
|
|
103
|
+
value: zod_1.z.string(),
|
|
104
|
+
serviceFilter: zod_1.z.array(zod_1.z.string()),
|
|
105
|
+
useCaseFilter: zod_1.z.array(zod_1.z.string()),
|
|
106
|
+
});
|
|
107
|
+
const _ServiceProfile = zod_1.z.object({
|
|
108
|
+
serviceKey: zod_1.z.string(),
|
|
109
|
+
displayValue: zod_1.z.string(),
|
|
110
|
+
logo: zod_1.z.string(),
|
|
111
|
+
aliases: zod_1.z.array(zod_1.z.string()),
|
|
112
|
+
});
|
|
113
|
+
const _IntegrationDomain = zod_1.z.object({
|
|
114
|
+
name: zod_1.z.string(),
|
|
115
|
+
domain: zod_1.z.string(),
|
|
116
|
+
});
|
|
117
|
+
const _FindingContent = zod_1.z.object({
|
|
118
|
+
kind: zod_1.z.string(),
|
|
119
|
+
title: zod_1.z.string(),
|
|
120
|
+
displayText: zod_1.z.string().optional(),
|
|
121
|
+
timeToComplete: zod_1.z.string().optional(),
|
|
122
|
+
instructions: ContentfulRichText,
|
|
123
|
+
});
|
|
124
|
+
const _Integration = zod_1.z.object({
|
|
125
|
+
name: zod_1.z.string(),
|
|
126
|
+
providerKey: zod_1.z.string(),
|
|
127
|
+
logo: zod_1.z.string(),
|
|
128
|
+
icon: zod_1.z.string().optional(),
|
|
129
|
+
tileDescription: zod_1.z.string(),
|
|
130
|
+
overview: zod_1.z.string(),
|
|
131
|
+
installationInstructions: ContentfulRichText,
|
|
132
|
+
termsOfUseLink: zod_1.z.string().optional(),
|
|
133
|
+
privacyStatementLink: zod_1.z.string().optional(),
|
|
134
|
+
supportLink: zod_1.z.string().optional(),
|
|
135
|
+
formTextKeys: zod_1.z.unknown(),
|
|
136
|
+
tags: zod_1.z.array(zod_1.z.string().optional()).default([]),
|
|
137
|
+
overviewLong: zod_1.z.string(),
|
|
138
|
+
installModalDynamicTabs: zod_1.z.unknown(),
|
|
139
|
+
overviewRichText: ContentfulRichText,
|
|
140
|
+
findings: _FindingContent,
|
|
141
|
+
domains: zod_1.z.array(_IntegrationDomain),
|
|
142
|
+
});
|
|
143
|
+
const _I18nContent = zod_1.z.object({
|
|
144
|
+
key: zod_1.z.string(),
|
|
145
|
+
value: zod_1.z.string(),
|
|
146
|
+
useCaseFilter: zod_1.z.array(zod_1.z.string()),
|
|
147
|
+
});
|
|
148
|
+
const _MessageTemplateContent = zod_1.z.object({
|
|
149
|
+
id: zod_1.z.string(),
|
|
150
|
+
body: zod_1.z.string(),
|
|
151
|
+
subject: zod_1.z.string().optional(),
|
|
152
|
+
});
|
|
153
|
+
class ContentService {
|
|
154
|
+
constructor(contentfulService) {
|
|
155
|
+
this.contentfulService = contentfulService;
|
|
156
|
+
this.getEntries = async (contentType, options) => {
|
|
157
|
+
const entries = [];
|
|
158
|
+
let hasMore = true;
|
|
159
|
+
let skip = 0;
|
|
160
|
+
while (hasMore) {
|
|
161
|
+
const rawEntries = await this.contentfulService.getContentfulEntries(contentType, options.include, skip, 100);
|
|
162
|
+
entries.push(...rawEntries.items.map(entry => entry.fields));
|
|
163
|
+
skip += 100;
|
|
164
|
+
hasMore = rawEntries.skip + rawEntries.limit < rawEntries.total;
|
|
165
|
+
}
|
|
166
|
+
return entries;
|
|
167
|
+
};
|
|
168
|
+
this.getBackendContent = async (options) => {
|
|
169
|
+
const rawEntries = await this.getEntries(ContentType.BACKEND_CONTENT, options || {});
|
|
170
|
+
const entries = rawEntries.map(entry => _BackendContent.parse(entry));
|
|
171
|
+
return entries;
|
|
172
|
+
};
|
|
173
|
+
this.getMessageTemplates = async () => {
|
|
174
|
+
const rawEntries = await this.contentfulService.getMessageTemplates();
|
|
175
|
+
const entries = rawEntries.items.map(entry => _MessageTemplateContent.parse(entry.fields));
|
|
176
|
+
return entries;
|
|
177
|
+
};
|
|
178
|
+
this.getIntegrationDomains = async (options) => {
|
|
179
|
+
const rawEntries = await this.getEntries(ContentType.INTEGRATION_DOMAIN, options || {});
|
|
180
|
+
const entries = rawEntries.map(this.mapIntegrationDomain);
|
|
181
|
+
return entries;
|
|
182
|
+
};
|
|
183
|
+
this.mapIntegrationDomain = (entry) => _IntegrationDomain.parse(entry);
|
|
184
|
+
this.getFindings = async (options) => {
|
|
185
|
+
const rawEntries = await this.getEntries(ContentType.FINDING, options || {});
|
|
186
|
+
const entries = rawEntries.map(this.mapFindings);
|
|
187
|
+
return entries;
|
|
188
|
+
};
|
|
189
|
+
this.mapFindings = (entry) => _FindingContent.parse(entry);
|
|
190
|
+
this.getIntegrations = async (options) => {
|
|
191
|
+
const rawEntries = await this.getEntries(ContentType.INTEGRATION, options || {});
|
|
192
|
+
const entries = rawEntries.map(entry => {
|
|
193
|
+
const logoUrl = lodash_1.default.get(entry, 'logo.fields.file.url');
|
|
194
|
+
lodash_1.default.set(entry, 'logo', logoUrl ? 'https:' + logoUrl : '');
|
|
195
|
+
const iconUrl = lodash_1.default.get(entry, 'icon.fields.file.url');
|
|
196
|
+
lodash_1.default.set(entry, 'icon', iconUrl ? 'https:' + iconUrl : '');
|
|
197
|
+
lodash_1.default.set(entry, 'domains', lodash_1.default.get(entry, 'domains', []).map(e => this.mapIntegrationDomain(lodash_1.default.get(e, 'fields'))));
|
|
198
|
+
lodash_1.default.set(entry, 'findings', lodash_1.default.get(entry, 'findings', []).map(e => this.mapFindings(lodash_1.default.get(e, 'fields'))));
|
|
199
|
+
return _Integration.parse(entry);
|
|
200
|
+
});
|
|
201
|
+
return entries;
|
|
202
|
+
};
|
|
203
|
+
this.getServiceProfiles = async (options) => {
|
|
204
|
+
const rawEntries = await this.getEntries(ContentType.SERVICE_PROFILE, options || {});
|
|
205
|
+
const entries = rawEntries.map(entry => {
|
|
206
|
+
const logoUrl = lodash_1.default.get(entry, 'logo.fields.file.url');
|
|
207
|
+
lodash_1.default.set(entry, 'logo', logoUrl ? 'https:' + logoUrl : '');
|
|
208
|
+
return _ServiceProfile.parse(entry);
|
|
209
|
+
});
|
|
210
|
+
return entries;
|
|
211
|
+
};
|
|
212
|
+
this.getI18nContent = async (options) => {
|
|
213
|
+
const rawEntries = await this.getEntries(ContentType.SECURITY_HUB_I18N, options || {});
|
|
214
|
+
const entries = rawEntries.map(entry => _I18nContent.parse(entry));
|
|
215
|
+
return entries;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
static instance() {
|
|
219
|
+
return new ContentService(new ContentfulService());
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
exports.ContentService = ContentService;
|
|
223
|
+
class I18nContentService {
|
|
224
|
+
constructor(contentService) {
|
|
225
|
+
this.contentService = contentService;
|
|
226
|
+
this.content = {};
|
|
227
|
+
this.init = async () => this.isInitialized;
|
|
228
|
+
this.refresh = async () => {
|
|
229
|
+
const content = await this.contentService.getI18nContent();
|
|
230
|
+
this.content = lodash_1.default.keyBy(content, 'key');
|
|
231
|
+
return this;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Example Usage:
|
|
235
|
+
* ```ts
|
|
236
|
+
* const i18n = await i18nContentService.instance();
|
|
237
|
+
* await i18n.init();
|
|
238
|
+
* const value = i18n.g('LOADING', 'Loading...');
|
|
239
|
+
* ```
|
|
240
|
+
* @param key
|
|
241
|
+
* @param defaultValue
|
|
242
|
+
* @returns
|
|
243
|
+
*/
|
|
244
|
+
this.g = (key, defaultValue) => {
|
|
245
|
+
return lodash_1.default.get(this.content, [key, 'value'], defaultValue || key);
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Example Usage:
|
|
249
|
+
* ```ts
|
|
250
|
+
* const i18n = await I18nContentService.instance();
|
|
251
|
+
* await i18n.init();
|
|
252
|
+
* const t = i18n.getLookupFunction();
|
|
253
|
+
* const value = t('LOADING', 'Loading...');
|
|
254
|
+
* // or more simply
|
|
255
|
+
* return <div>{t('Loading...')}</div>
|
|
256
|
+
* // Note this can be use to extend functionality of a Typography component, e.g.
|
|
257
|
+
* const MyTypography = (props: {children: string}) => <Typography>{t(props.children)}</Typography>
|
|
258
|
+
* return <MyTypography>Loading...</MyTypography>
|
|
259
|
+
* ```
|
|
260
|
+
* @returns
|
|
261
|
+
*/
|
|
262
|
+
this.getLookupFunction = () => this.g;
|
|
263
|
+
this.isInitialized = this.refresh().then(service => {
|
|
264
|
+
console.debug('i18nContentService initialized');
|
|
265
|
+
return service;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
static instance(_options) {
|
|
269
|
+
if (!I18nContentService._instance) {
|
|
270
|
+
I18nContentService._instance = new I18nContentService(ContentService.instance());
|
|
271
|
+
}
|
|
272
|
+
return I18nContentService._instance;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
exports.I18nContentService = I18nContentService;
|
|
81
276
|
//# sourceMappingURL=contentful.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentful.service.js","sourceRoot":"","sources":["../../../src/services/contentful.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contentful.service.js","sourceRoot":"","sources":["../../../src/services/contentful.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAsB;AAEtB,uDAAyC;AACzC,oDAAuB;AAevB;;;;;;;;;;;IAWI;AACJ,MAAa,iBAAiB;IAE5B;;;;;;;OAOG;IACH;QAWA,wBAAmB,GAAG,KAAK,IAA+C,EAAE;YAC1E,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAkB,iBAAiB,EAAE,CAAC,CAAC,CAAC;YAChG,OAAO,gBAAgB,CAAC;QAC1B,CAAC,CAAC;QAEF,yBAAoB,GAAG,KAAK,EAA+B,WAAmB,EAAE,OAAgB,EAAE,IAAa,EAAE,KAAc,EAA+B,EAAE;YAC9J,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,oJAAoJ,CAAC,CAAC;YACxK,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAI;gBACxD,YAAY,EAAE,WAAW;gBACzB,IAAI;gBACJ,KAAK;gBACL,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9B,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;QAEF,uBAAkB,GAAG,KAAK,EAA+B,OAAe,EAAqB,EAAE;YAC7F,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,oJAAoJ,CAAC,CAAC;YACxK,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CA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YAClC,kBAAkB,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,kBAAkB,CAAC,SAAS,CAAC;IACtC,CAAC;CACF;AAzDD,gDAyDC"}
|
|
@@ -2,6 +2,7 @@ export * from './AmpApi';
|
|
|
2
2
|
export * from './EngageApi';
|
|
3
3
|
export * from './AmpSdk';
|
|
4
4
|
export * from './constants';
|
|
5
|
+
export * from './ContentTemplateService';
|
|
5
6
|
export * from './data.service';
|
|
6
7
|
export * from './entity.service';
|
|
7
8
|
export * from './findingsInsights.service';
|
|
@@ -18,6 +18,7 @@ __exportStar(require("./AmpApi"), exports);
|
|
|
18
18
|
__exportStar(require("./EngageApi"), exports);
|
|
19
19
|
__exportStar(require("./AmpSdk"), exports);
|
|
20
20
|
__exportStar(require("./constants"), exports);
|
|
21
|
+
__exportStar(require("./ContentTemplateService"), exports);
|
|
21
22
|
__exportStar(require("./data.service"), exports);
|
|
22
23
|
__exportStar(require("./entity.service"), exports);
|
|
23
24
|
__exportStar(require("./findingsInsights.service"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,mDAAiC;AACjC,6DAA2C;AAC3C,qDAAmC;AACnC,mDAAiC;AACjC,yCAAuB;AACvB,uDAAqC;AACrC,qDAAmC;AACnC,0CAAwB;AACxB,uDAAqC;AACrC,yDAAuC;AACvC,oDAAkC;AAClC,uDAAqC;AACrC,uDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2DAAyC;AACzC,iDAA+B;AAC/B,mDAAiC;AACjC,6DAA2C;AAC3C,qDAAmC;AACnC,mDAAiC;AACjC,yCAAuB;AACvB,uDAAqC;AACrC,qDAAmC;AACnC,0CAAwB;AACxB,uDAAqC;AACrC,yDAAuC;AACvC,oDAAkC;AAClC,uDAAqC;AACrC,uDAAqC"}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ export const _CustomScoreValueUpsertDto = _CustomScoreValueDto.partial(UPSERT_DT
|
|
|
12
12
|
export type CustomScoreValueUpsertDto = z.infer<typeof _CustomScoreValueUpsertDto>;
|
|
13
13
|
|
|
14
14
|
export const _CustomScoreCohortDto = _BaseDto.extend({
|
|
15
|
-
cohort: _AmplifierCohortDto,
|
|
15
|
+
cohort: _AmplifierCohortDto || z.array(_AmplifierCohortDto),
|
|
16
16
|
multiplier: z.number(),
|
|
17
17
|
});
|
|
18
18
|
export type CustomScoreCohortDto = z.infer<typeof _CustomScoreCohortDto>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {Category} from './category';
|
|
2
2
|
import {FindingOutcome} from './finding.outcome';
|
|
3
3
|
import {FindingSeverity} from './finding.severity';
|
|
4
|
+
import {SaasComponentKind} from './saasComponentKind';
|
|
4
5
|
|
|
5
6
|
export enum FindingKind {
|
|
6
7
|
// ALL
|
|
@@ -107,3 +108,73 @@ export const lookupFindingDisplayValueByKind = (kind: string): string => {
|
|
|
107
108
|
return kind.toLowerCase();
|
|
108
109
|
}
|
|
109
110
|
};
|
|
111
|
+
|
|
112
|
+
export const generateInsights = (category: string, kind: string) => {
|
|
113
|
+
type Condition = Record<string, boolean | string | number | undefined>;
|
|
114
|
+
const insights = {
|
|
115
|
+
meta: {
|
|
116
|
+
kind: kind as FindingKind,
|
|
117
|
+
severity: lookupFindingSeverityByKind(kind) as FindingSeverity,
|
|
118
|
+
displayValue: lookupFindingDisplayValueByKind(kind),
|
|
119
|
+
},
|
|
120
|
+
rule: {
|
|
121
|
+
category: category as Category,
|
|
122
|
+
kind: '' as SaasComponentKind,
|
|
123
|
+
aid: {$has: false},
|
|
124
|
+
uid: {$has: false},
|
|
125
|
+
findingCondition: {} as Condition,
|
|
126
|
+
remediatedCondition: {} as Condition,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
if (category === Category.EDR || category === Category.VULNERABILITY) {
|
|
130
|
+
insights.rule.aid = {$has: true};
|
|
131
|
+
} else {
|
|
132
|
+
insights.rule.uid = {$has: true};
|
|
133
|
+
}
|
|
134
|
+
const setCondition = (key: string, value: boolean) => {
|
|
135
|
+
insights.rule.findingCondition[key] = value;
|
|
136
|
+
insights.rule.remediatedCondition[key] = !value;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
switch (kind) {
|
|
140
|
+
case FindingKind.WEB_GATEWAY_NOT_ACTIVE:
|
|
141
|
+
setCondition('meta._findings.loggedIn', false);
|
|
142
|
+
insights.rule.kind = SaasComponentKind.WEB_GATEWAY_SESSION;
|
|
143
|
+
break;
|
|
144
|
+
case FindingKind.VULNERABILITY_OUT_OF_SLA:
|
|
145
|
+
setCondition('meta._findings.overdue', true);
|
|
146
|
+
insights.rule.kind = SaasComponentKind.VULNERABILITY;
|
|
147
|
+
break;
|
|
148
|
+
case FindingKind.TRAINING_OVERDUE:
|
|
149
|
+
setCondition('meta._findings.overdue', true);
|
|
150
|
+
insights.rule.kind = SaasComponentKind.TRAINING_ASSIGNMENT;
|
|
151
|
+
break;
|
|
152
|
+
case FindingKind.FAILED_PHISHING:
|
|
153
|
+
setCondition('meta._findings.failedPhishing', true);
|
|
154
|
+
insights.rule.kind = SaasComponentKind.PHISHING_RESULT;
|
|
155
|
+
break;
|
|
156
|
+
case FindingKind.DEVICE_NOT_MANAGED:
|
|
157
|
+
setCondition('meta._findings.active', false);
|
|
158
|
+
insights.rule.kind = SaasComponentKind.EDR_CONFIG;
|
|
159
|
+
break;
|
|
160
|
+
case FindingKind.MFA_NOT_ENABLED:
|
|
161
|
+
setCondition('meta._findings.enabled', false);
|
|
162
|
+
insights.rule.kind = SaasComponentKind.MFA_CONFIG;
|
|
163
|
+
break;
|
|
164
|
+
case FindingKind.IS_EXECUTIVE:
|
|
165
|
+
setCondition('meta._findings.isExecutive', true);
|
|
166
|
+
insights.rule.kind = SaasComponentKind.GROUP_MEMBERSHIP;
|
|
167
|
+
break;
|
|
168
|
+
case FindingKind.HAS_PRODUCTION_ACCESS:
|
|
169
|
+
setCondition('meta._findings.hasProdAccess', true);
|
|
170
|
+
insights.rule.kind = SaasComponentKind.GROUP_MEMBERSHIP;
|
|
171
|
+
break;
|
|
172
|
+
case FindingKind.HAS_PRIVILEGED_ACCESS:
|
|
173
|
+
setCondition('meta._findings.hasPrivilegedAccess', true);
|
|
174
|
+
insights.rule.kind = SaasComponentKind.GROUP_MEMBERSHIP;
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
return insights;
|
|
180
|
+
};
|