@ampsec/platform-client 70.2.0 → 70.3.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/platform/platform.ops.dto.d.ts +95 -0
- package/build/src/dto/platform/platform.ops.dto.js +20 -0
- package/build/src/dto/platform/platform.ops.dto.js.map +1 -0
- package/build/src/dto/platform/platform.tenants.dto.d.ts +1234 -0
- package/build/src/dto/platform/platform.tenants.dto.js +96 -0
- package/build/src/dto/platform/platform.tenants.dto.js.map +1 -1
- package/build/src/services/AmpSdk.d.ts +3 -2
- package/build/src/services/AmpSdk.js +2 -1
- package/build/src/services/AmpSdk.js.map +1 -1
- package/build/src/services/rest/TenantsService.d.ts +27 -0
- package/build/src/services/rest/TenantsService.js +69 -0
- package/build/src/services/rest/TenantsService.js.map +1 -0
- package/package.json +1 -1
- package/src/dto/platform/platform.ops.dto.ts +22 -0
- package/src/dto/platform/platform.tenants.dto.ts +110 -0
- package/src/services/AmpSdk.ts +3 -4
- package/src/services/rest/TenantsService.ts +69 -0
|
@@ -1,3 +1,99 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._TenantCountReportDto = exports._FlowsCountReport = exports._NotificationsCountReport = exports._FindingsCountReport = exports._SaasCompCountReport = exports._UserCountReport = exports._AssetCountReport = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
const flows_dto_1 = require("../flows.dto");
|
|
7
|
+
// TODO add "missing from" reports to better understand coverage gaps
|
|
8
|
+
exports._AssetCountReport = zod_1.z.object({
|
|
9
|
+
byType: zod_1.z.object({ assetType: zod_1.z.nativeEnum(enums_1.GlobalAssetType), total: zod_1.z.number() }).array(),
|
|
10
|
+
// TODO byConnector: z.object({cid: z.string(), active: z.number(), inactive: z.number(), total: z.number()}).array(),
|
|
11
|
+
byConnector: zod_1.z.object({ cid: zod_1.z.string(), assetType: zod_1.z.nativeEnum(enums_1.GlobalAssetType), total: zod_1.z.number() }).array(),
|
|
12
|
+
totalAssets: zod_1.z.number(),
|
|
13
|
+
totalSaasAssets: zod_1.z.number(),
|
|
14
|
+
totalStagedAssets: zod_1.z.number(),
|
|
15
|
+
links: zod_1.z.object({
|
|
16
|
+
withUsers: zod_1.z.number(),
|
|
17
|
+
withoutUsers: zod_1.z.number(),
|
|
18
|
+
withVulns: zod_1.z.number(),
|
|
19
|
+
withoutVulns: zod_1.z.number(),
|
|
20
|
+
withUserAssignedVulns: zod_1.z.number(),
|
|
21
|
+
withOrphanedVulns: zod_1.z.number(),
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
exports._UserCountReport = zod_1.z.object({
|
|
25
|
+
byConnectorStatus: zod_1.z.object({ cid: zod_1.z.string(), userType: zod_1.z.nativeEnum(enums_1.GlobalUserType), total: zod_1.z.number() }).array(),
|
|
26
|
+
byType: zod_1.z.object({ userType: zod_1.z.nativeEnum(enums_1.GlobalUserType), total: zod_1.z.number() }).array(),
|
|
27
|
+
totalUsers: zod_1.z.number(),
|
|
28
|
+
totalSaasUsers: zod_1.z.number(),
|
|
29
|
+
totalStagedUsers: zod_1.z.number(),
|
|
30
|
+
links: zod_1.z.object({
|
|
31
|
+
withDevices: zod_1.z.number(),
|
|
32
|
+
withoutDevices: zod_1.z.number(),
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
exports._SaasCompCountReport = zod_1.z.object({
|
|
36
|
+
byConnectorKind: zod_1.z.object({ cid: zod_1.z.string(), kind: zod_1.z.string(), total: zod_1.z.number() }).array(),
|
|
37
|
+
totalSaasComps: zod_1.z.number(),
|
|
38
|
+
totalStagedSaasComps: zod_1.z.number(),
|
|
39
|
+
links: zod_1.z.object({
|
|
40
|
+
withUsers: zod_1.z.number(),
|
|
41
|
+
withoutUsers: zod_1.z.number(),
|
|
42
|
+
withDevices: zod_1.z.number(),
|
|
43
|
+
withoutDevices: zod_1.z.number(),
|
|
44
|
+
orphaned: zod_1.z.number(),
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
const _RecentFindingSummaryReport = zod_1.z.object({
|
|
48
|
+
openWithUser: zod_1.z.number(),
|
|
49
|
+
openWithoutUser: zod_1.z.number(),
|
|
50
|
+
closedWithUser: zod_1.z.number(),
|
|
51
|
+
closedWithoutUser: zod_1.z.number(),
|
|
52
|
+
});
|
|
53
|
+
exports._FindingsCountReport = zod_1.z.object({
|
|
54
|
+
connectorKindSeverityStatus: zod_1.z
|
|
55
|
+
.object({
|
|
56
|
+
cid: zod_1.z.string().nullable(),
|
|
57
|
+
kind: zod_1.z.union([zod_1.z.nativeEnum(enums_1.FindingKind), zod_1.z.string()]),
|
|
58
|
+
severity: zod_1.z.nativeEnum(enums_1.FindingSeverity),
|
|
59
|
+
status: zod_1.z.nativeEnum(enums_1.FindingStatus),
|
|
60
|
+
total: zod_1.z.number(),
|
|
61
|
+
})
|
|
62
|
+
.array(),
|
|
63
|
+
total: _RecentFindingSummaryReport,
|
|
64
|
+
total90d: _RecentFindingSummaryReport,
|
|
65
|
+
pending: zod_1.z.number(),
|
|
66
|
+
links: zod_1.z.object({
|
|
67
|
+
withUsers: zod_1.z.number(),
|
|
68
|
+
withoutUsers: zod_1.z.number(),
|
|
69
|
+
withDevices: zod_1.z.number(),
|
|
70
|
+
withoutDevices: zod_1.z.number(),
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
exports._NotificationsCountReport = zod_1.z.object({
|
|
74
|
+
total: zod_1.z.number(),
|
|
75
|
+
total7d: zod_1.z.number(),
|
|
76
|
+
total30d: zod_1.z.number(),
|
|
77
|
+
total90d: zod_1.z.number(),
|
|
78
|
+
});
|
|
79
|
+
const _FlowStatusSummaryReport = zod_1.z.object({
|
|
80
|
+
active: zod_1.z.number(),
|
|
81
|
+
closed: zod_1.z.number(),
|
|
82
|
+
});
|
|
83
|
+
exports._FlowsCountReport = zod_1.z.object({
|
|
84
|
+
specsByStatusTrigger: zod_1.z.object({ status: zod_1.z.nativeEnum(flows_dto_1.FlowSpecStatusKind), trigger: zod_1.z.string(), total: zod_1.z.number() }).array(),
|
|
85
|
+
statesByBucketStatus: zod_1.z.object({ status: zod_1.z.string(), bucket: zod_1.z.union([zod_1.z.nativeEnum(enums_1.FindingKind), zod_1.z.string()]), total: zod_1.z.number() }).array(),
|
|
86
|
+
total: _FlowStatusSummaryReport,
|
|
87
|
+
total7d: _FlowStatusSummaryReport,
|
|
88
|
+
total30d: _FlowStatusSummaryReport,
|
|
89
|
+
total90d: _FlowStatusSummaryReport,
|
|
90
|
+
});
|
|
91
|
+
exports._TenantCountReportDto = zod_1.z.object({
|
|
92
|
+
users: exports._UserCountReport,
|
|
93
|
+
assets: exports._AssetCountReport,
|
|
94
|
+
saasComp: exports._SaasCompCountReport,
|
|
95
|
+
findings: exports._FindingsCountReport,
|
|
96
|
+
notifications: exports._NotificationsCountReport,
|
|
97
|
+
flows: exports._FlowsCountReport,
|
|
98
|
+
});
|
|
3
99
|
//# sourceMappingURL=platform.tenants.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.tenants.dto.js","sourceRoot":"","sources":["../../../../src/dto/platform/platform.tenants.dto.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"platform.tenants.dto.js","sourceRoot":"","sources":["../../../../src/dto/platform/platform.tenants.dto.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAEtB,oCAAsG;AACtG,4CAAgD;AAMhD,qEAAqE;AAExD,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,EAAC,SAAS,EAAE,OAAC,CAAC,UAAU,CAAC,uBAAe,CAAC,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,EAAC,CAAC,CAAC,KAAK,EAAE;IACvF,sHAAsH;IACtH,WAAW,EAAE,OAAC,CAAC,MAAM,C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B,EAAE,OAAC,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,UAAU,CAAC,mBAAW,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,EAAC,CAAC,CAAC,KAAK,EAAE;IACzI,KAAK,EAAE,wBAAwB;IAC/B,OAAO,EAAE,wBAAwB;IACjC,QAAQ,EAAE,wBAAwB;IAClC,QAAQ,EAAE,wBAAwB;CACnC,CAAC,CAAC;AAGU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,wBAAgB;IACvB,MAAM,EAAE,yBAAiB;IACzB,QAAQ,EAAE,4BAAoB;IAC9B,QAAQ,EAAE,4BAAoB;IAC9B,aAAa,EAAE,iCAAyB;IACxC,KAAK,EAAE,yBAAiB;CACzB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlatformActionExecutionDto, PlatformActionExecutionUpsertDto, PlatformCustomActionDto, PlatformCustomActionUpsertDto, PlatformCustomScoreCohortDto, PlatformCustomScoreCohortUpsertDto, PlatformCustomScoreValueDto, PlatformCustomScoreValueUpsertDto, PlatformFindingSpecDto, PlatformFindingSpecUpsertDto, PlatformFlowSpecDto, PlatformFlowSpecUpsertDto, PlatformFlowStateDto, PlatformFlowStateUpsertDto, PlatformJobExecutionStateDto, PlatformJobExecutionStateUpsertDto, PlatformJobSpecDto, PlatformJobSpecUpsertDto, PlatformNotificationDto, PlatformNotificationUpsertDto, PlatformProviderUpsertDto, PlatformReportResultDto, PlatformReportResultUpsertDto, PlatformRiskContributorDto, PlatformRiskContributorUpsertDto, PlatformSaasComponentDto, PlatformSaasComponentUpsertDto, PlatformStagedSaasAssetDto, PlatformStagedSaasAssetUpsertDto, PlatformStagedSaasUserDto, PlatformStagedSaasUserUpsertDto, PlatformTokenDto, PlatformTokenUpsertDto, ProviderDto
|
|
1
|
+
import { PlatformActionExecutionDto, PlatformActionExecutionUpsertDto, PlatformCustomActionDto, PlatformCustomActionUpsertDto, PlatformCustomScoreCohortDto, PlatformCustomScoreCohortUpsertDto, PlatformCustomScoreValueDto, PlatformCustomScoreValueUpsertDto, PlatformFindingSpecDto, PlatformFindingSpecUpsertDto, PlatformFlowSpecDto, PlatformFlowSpecUpsertDto, PlatformFlowStateDto, PlatformFlowStateUpsertDto, PlatformJobExecutionStateDto, PlatformJobExecutionStateUpsertDto, PlatformJobSpecDto, PlatformJobSpecUpsertDto, PlatformNotificationDto, PlatformNotificationUpsertDto, PlatformProviderUpsertDto, PlatformReportResultDto, PlatformReportResultUpsertDto, PlatformRiskContributorDto, PlatformRiskContributorUpsertDto, PlatformSaasComponentDto, PlatformSaasComponentUpsertDto, PlatformStagedSaasAssetDto, PlatformStagedSaasAssetUpsertDto, PlatformStagedSaasUserDto, PlatformStagedSaasUserUpsertDto, PlatformTokenDto, PlatformTokenUpsertDto, ProviderDto } from '../dto';
|
|
2
2
|
import { AmpEntityService, AmpSdkAssetService, AmpSdkTenantService, AmpSdkUserService, TruncatableAmpEntityService } from './entity.service';
|
|
3
3
|
import { AmpRestClientOptions, RestClient } from './rest';
|
|
4
4
|
import { EnumService } from './rest/EnumService';
|
|
@@ -8,6 +8,7 @@ import { ContentfulService } from './contentful.service';
|
|
|
8
8
|
import { FindingsInsightsService } from './findingsInsights.service';
|
|
9
9
|
import { PlatformConnectorService } from './connector.platform.service';
|
|
10
10
|
import { PlatformAgentService } from './AgentsService';
|
|
11
|
+
import { TenantsService } from './rest/TenantsService';
|
|
11
12
|
import { FindingsService } from './findings.service';
|
|
12
13
|
export type AmpSdkOptions = AmpRestClientOptions;
|
|
13
14
|
/**
|
|
@@ -47,7 +48,7 @@ export declare class AmpSdkServices {
|
|
|
47
48
|
readonly stagedSaaSComponents: TruncatableAmpEntityService<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>;
|
|
48
49
|
readonly stagedSaaSUsers: TruncatableAmpEntityService<PlatformStagedSaasUserUpsertDto, PlatformStagedSaasUserDto>;
|
|
49
50
|
readonly settings: AmpSdkSettingsService;
|
|
50
|
-
readonly tenants:
|
|
51
|
+
readonly tenants: TenantsService;
|
|
51
52
|
readonly tokens: AmpSdkTenantService<PlatformTokenUpsertDto, PlatformTokenDto>;
|
|
52
53
|
readonly users: AmpSdkUserService;
|
|
53
54
|
constructor(rest: RestClient);
|
|
@@ -11,6 +11,7 @@ const contentful_service_1 = require("./contentful.service");
|
|
|
11
11
|
const findingsInsights_service_1 = require("./findingsInsights.service");
|
|
12
12
|
const connector_platform_service_1 = require("./connector.platform.service");
|
|
13
13
|
const AgentsService_1 = require("./AgentsService");
|
|
14
|
+
const TenantsService_1 = require("./rest/TenantsService");
|
|
14
15
|
const findings_service_1 = require("./findings.service");
|
|
15
16
|
/**
|
|
16
17
|
* AMP API
|
|
@@ -50,7 +51,7 @@ class AmpSdkServices {
|
|
|
50
51
|
this.stagedSaaSComponents = new entity_service_1.TruncatableAmpEntityServiceImpl(rest, constants_1.KIND.STAGED_SAAS_COMPONENTS, constants_1.TARGET_API_PLATFORM);
|
|
51
52
|
this.stagedSaaSUsers = new entity_service_1.TruncatableAmpEntityServiceImpl(rest, constants_1.KIND.STAGED_SAAS_USERS, constants_1.TARGET_API_PLATFORM);
|
|
52
53
|
this.settings = new settings_service_1.AmpSdkSettingsService(rest);
|
|
53
|
-
this.tenants = new
|
|
54
|
+
this.tenants = new TenantsService_1.TenantsService(rest, constants_1.TARGET_API_PLATFORM);
|
|
54
55
|
this.tokens = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.TOKENS, constants_1.TARGET_API_PLATFORM);
|
|
55
56
|
this.users = new entity_service_1.AmpSdkUserService(rest, constants_1.TARGET_API_PLATFORM);
|
|
56
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AmpSdk.js","sourceRoot":"","sources":["../../../src/services/AmpSdk.ts"],"names":[],"mappings":";;;AAsCA,qDAQ0B;AAC1B,iCAA0E;AAC1E,2CAAsD;AACtD,oDAAmE;AACnE,yDAAyD;AACzD,6DAA+J;AAC/J,6DAAuD;AACvD,yEAAmE;AACnE,6EAAsE;AACtE,mDAAqD;AACrD,0DAAqD;AACrD,yDAAmD;AAInD;;;;;;;;GAQG;AACH,MAAa,cAAc;IAgCzB,YAAY,IAAgB;QAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,qCAAoB,CAA+D,IAAI,EAAE,gBAAI,CAAC,gBAAgB,EAAE,+BAAmB,CAAC,CAAC;QACjK,IAAI,CAAC,MAAM,GAAG,IAAI,oCAAoB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,mCAAkB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAC/D,IAAI,CAAC,UAAU,GAAG,IAAI,qDAAwB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,IAAI,sCAAiB,EAAE,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,IAAI,qCAAoB,CAAyD,IAAI,EAAE,gBAAI,CAAC,cAAc,EAAE,+BAAmB,CAAC,CAAC;QACtJ,IAAI,CAAC,kBAAkB,GAAG,IAAI,qCAAoB,CAAmE,IAAI,EAAE,gBAAI,CAAC,oBAAoB,EAAE,+BAAmB,CAAC,CAAC;QAC3K,IAAI,CAAC,iBAAiB,GAAG,IAAI,qCAAoB,CAAiE,IAAI,EAAE,gBAAI,CAAC,mBAAmB,EAAE,+BAAmB,CAAC,CAAC;QACvK,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAkB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ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AAE,+BAAmB,CAAC,CAAC;QACxE,IAAI,CAAC,cAAc,GAAG,IAAI,+CAA0B,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAChF,IAAI,CAAC,SAAS,GAAG,IAAI,0CAAqB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QACtE,IAAI,CAAC,gBAAgB,GAAG,IAAI,gDAA+B,CAA+D,IAAI,EAAE,gBAAI,CAAC,kBAAkB,EAAE,+BAAmB,CAAC,CAAC;QAC9K,IAAI,CAAC,oBAAoB,GAAG,IAAI,gDAA+B,CAC7D,IAAI,EACJ,gBAAI,CAAC,sBAAsB,EAC3B,+BAAmB,CACpB,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,IAAI,gDAA+B,CAA6D,IAAI,EAAE,gBAAI,CAAC,iBAAiB,EAAE,+BAAmB,CAAC,CAAC;QAE1K,IAAI,CAAC,QAAQ,GAAG,IAAI,wCAAqB,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,GAAG,IAAI,qCAAoB,CAA2C,IAAI,EAAE,gBAAI,CAAC,MAAM,EAAE,+BAAmB,CAAC,CAAC;QACzH,IAAI,CAAC,KAAK,GAAG,IAAI,kCAAiB,CAAC,IAAI,EAAE,+BAAmB,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAsB;QACpC,MAAM,IAAI,GAAG,IAAA,uBAAgB,EAAC,OAAO,CAAC,CAAC;QACvC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AA1ED,wCA0EC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TenantCountReportDto, TenantDto, TenantUpsertDto } from '../../dto';
|
|
2
|
+
import { TargetApi } from '../constants';
|
|
3
|
+
import { AmpEntityServiceImpl } from '../entity.service';
|
|
4
|
+
import { RestClient } from './RestClient';
|
|
5
|
+
import { OpsRpcResult } from '../../dto/platform/platform.ops.dto';
|
|
6
|
+
export declare class TenantsService extends AmpEntityServiceImpl<TenantUpsertDto, TenantDto> {
|
|
7
|
+
constructor(rest: RestClient, targetApi?: TargetApi);
|
|
8
|
+
countReport(tid: string): Promise<TenantCountReportDto>;
|
|
9
|
+
/**
|
|
10
|
+
* !!! WARNING !!! 🚨 💀 🚨 💀 🚨 💀 🚨 💀
|
|
11
|
+
* This method will permanently HARD delete any soft deleted tenant data, including the tenant itsself. There is no UNDO!
|
|
12
|
+
*
|
|
13
|
+
* @param tid Tenant id to clean
|
|
14
|
+
* @returns void
|
|
15
|
+
* @deprecated do not use this function... unless you REALLY mean it! Note: this is more of a warning than true deprecation.
|
|
16
|
+
*/
|
|
17
|
+
hardDelete(tid: string): Promise<OpsRpcResult>;
|
|
18
|
+
/**
|
|
19
|
+
* !!! WARNING !!! 🚨 💀 🚨 💀 🚨 💀 🚨 💀
|
|
20
|
+
* This method will permanently HARD delete a tenant and associated data. There is no UNDO!
|
|
21
|
+
*
|
|
22
|
+
* @param tid Tenant id to delete
|
|
23
|
+
* @returns void
|
|
24
|
+
* @deprecated Use truncate instead... unless you REALLY mean it! Note: this is more of a warning than true deprecation.
|
|
25
|
+
*/
|
|
26
|
+
removeTenant(tid: string): Promise<OpsRpcResult>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TenantsService = void 0;
|
|
4
|
+
const dto_1 = require("../../dto");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const entity_service_1 = require("../entity.service");
|
|
7
|
+
const platform_ops_dto_1 = require("../../dto/platform/platform.ops.dto");
|
|
8
|
+
class TenantsService extends entity_service_1.AmpEntityServiceImpl {
|
|
9
|
+
constructor(rest, targetApi = 'api') {
|
|
10
|
+
super(rest, constants_1.KIND.TENANTS, targetApi);
|
|
11
|
+
}
|
|
12
|
+
countReport(tid) {
|
|
13
|
+
const url = `/${this.targetApi}/v1/${this.kind}/${tid}/count_report`;
|
|
14
|
+
return this.rest
|
|
15
|
+
.call({
|
|
16
|
+
url,
|
|
17
|
+
method: 'GET',
|
|
18
|
+
})
|
|
19
|
+
.then(res => dto_1._TenantCountReportDto.parse(res.data));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* !!! WARNING !!! 🚨 💀 🚨 💀 🚨 💀 🚨 💀
|
|
23
|
+
* This method will permanently HARD delete any soft deleted tenant data, including the tenant itsself. There is no UNDO!
|
|
24
|
+
*
|
|
25
|
+
* @param tid Tenant id to clean
|
|
26
|
+
* @returns void
|
|
27
|
+
* @deprecated do not use this function... unless you REALLY mean it! Note: this is more of a warning than true deprecation.
|
|
28
|
+
*/
|
|
29
|
+
hardDelete(tid) {
|
|
30
|
+
const url = `/${this.targetApi}/v1/ops/rpc`;
|
|
31
|
+
return this.rest
|
|
32
|
+
.call({
|
|
33
|
+
url,
|
|
34
|
+
method: 'POST',
|
|
35
|
+
data: {
|
|
36
|
+
op: 'hardDelete',
|
|
37
|
+
input: {
|
|
38
|
+
tid,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
.then(res => platform_ops_dto_1._OpsRpcResult.parse(res.data));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* !!! WARNING !!! 🚨 💀 🚨 💀 🚨 💀 🚨 💀
|
|
46
|
+
* This method will permanently HARD delete a tenant and associated data. There is no UNDO!
|
|
47
|
+
*
|
|
48
|
+
* @param tid Tenant id to delete
|
|
49
|
+
* @returns void
|
|
50
|
+
* @deprecated Use truncate instead... unless you REALLY mean it! Note: this is more of a warning than true deprecation.
|
|
51
|
+
*/
|
|
52
|
+
removeTenant(tid) {
|
|
53
|
+
const url = `/${this.targetApi}/v1/ops/rpc`;
|
|
54
|
+
return this.rest
|
|
55
|
+
.call({
|
|
56
|
+
url,
|
|
57
|
+
method: 'POST',
|
|
58
|
+
data: {
|
|
59
|
+
op: 'removeTenant',
|
|
60
|
+
input: {
|
|
61
|
+
tid,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
.then(res => platform_ops_dto_1._OpsRpcResult.parse(res.data));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.TenantsService = TenantsService;
|
|
69
|
+
//# sourceMappingURL=TenantsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TenantsService.js","sourceRoot":"","sources":["../../../../src/services/rest/TenantsService.ts"],"names":[],"mappings":";;;AAAA,mCAAkG;AAClG,4CAA6C;AAC7C,sDAAuD;AAEvD,0EAAgF;AAEhF,MAAa,cAAe,SAAQ,qCAAgD;IAClF,YAAY,IAAgB,EAAE,YAAuB,KAAK;QACxD,KAAK,CAAC,IAAI,EAAE,gBAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,WAAW,CAAC,GAAW;QACrB,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,IAAI,GAAG,eAAe,CAAC;QACrE,OAAO,IAAI,CAAC,IAAI;aACb,IAAI,CAAC;YACJ,GAAG;YACH,MAAM,EAAE,KAAK;SACd,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,2BAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CAAC,GAAW;QACpB,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,SAAS,aAAa,CAAC;QAC5C,OAAO,IAAI,CAAC,IAAI;aACb,IAAI,CAAC;YACJ,GAAG;YACH,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,EAAE,EAAE,YAAY;gBAChB,KAAK,EAAE;oBACL,GAAG;iBACJ;aACF;SACF,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,gCAAa,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;OAOG;IACH,YAAY,CAAC,GAAW;QACtB,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,SAAS,aAAa,CAAC;QAC5C,OAAO,IAAI,CAAC,IAAI;aACb,IAAI,CAAC;YACJ,GAAG;YACH,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,EAAE,EAAE,cAAc;gBAClB,KAAK,EAAE;oBACL,GAAG;iBACJ;aACF;SACF,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,gCAAa,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;CACF;AA9DD,wCA8DC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
|
|
3
|
+
export const _SuccessOpsRpcResult = z.object({
|
|
4
|
+
success: z.literal(true),
|
|
5
|
+
input: z.unknown(),
|
|
6
|
+
output: z.unknown(),
|
|
7
|
+
});
|
|
8
|
+
export type SuccessOpsRpcResult = z.infer<typeof _SuccessOpsRpcResult>;
|
|
9
|
+
|
|
10
|
+
export const _FailureOpsRpcResult = z.object({
|
|
11
|
+
success: z.literal(false),
|
|
12
|
+
input: z.unknown(),
|
|
13
|
+
error: z.object({
|
|
14
|
+
message: z.string(),
|
|
15
|
+
stack: z.string().optional(),
|
|
16
|
+
ctx: z.unknown().optional(),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
export type FailureOpsRpcResult = z.infer<typeof _FailureOpsRpcResult>;
|
|
20
|
+
|
|
21
|
+
export const _OpsRpcResult = _SuccessOpsRpcResult.or(_FailureOpsRpcResult);
|
|
22
|
+
export type OpsRpcResult = z.infer<typeof _OpsRpcResult>;
|
|
@@ -1,5 +1,115 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
1
2
|
import {TenantDto, TenantUpsertDto} from '../tenants.dto';
|
|
3
|
+
import {FindingKind, FindingSeverity, FindingStatus, GlobalAssetType, GlobalUserType} from '../enums';
|
|
4
|
+
import {FlowSpecStatusKind} from '../flows.dto';
|
|
2
5
|
|
|
3
6
|
export type PlatformTenantUpsertDto = TenantUpsertDto;
|
|
4
7
|
|
|
5
8
|
export type PlatformTenantDto = TenantDto;
|
|
9
|
+
|
|
10
|
+
// TODO add "missing from" reports to better understand coverage gaps
|
|
11
|
+
|
|
12
|
+
export const _AssetCountReport = z.object({
|
|
13
|
+
byType: z.object({assetType: z.nativeEnum(GlobalAssetType), total: z.number()}).array(),
|
|
14
|
+
// TODO byConnector: z.object({cid: z.string(), active: z.number(), inactive: z.number(), total: z.number()}).array(),
|
|
15
|
+
byConnector: z.object({cid: z.string(), assetType: z.nativeEnum(GlobalAssetType), total: z.number()}).array(),
|
|
16
|
+
totalAssets: z.number(),
|
|
17
|
+
totalSaasAssets: z.number(),
|
|
18
|
+
totalStagedAssets: z.number(),
|
|
19
|
+
links: z.object({
|
|
20
|
+
withUsers: z.number(),
|
|
21
|
+
withoutUsers: z.number(),
|
|
22
|
+
withVulns: z.number(),
|
|
23
|
+
withoutVulns: z.number(),
|
|
24
|
+
withUserAssignedVulns: z.number(),
|
|
25
|
+
withOrphanedVulns: z.number(),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
export type AssetCountReport = z.infer<typeof _AssetCountReport>;
|
|
29
|
+
|
|
30
|
+
export const _UserCountReport = z.object({
|
|
31
|
+
byConnectorStatus: z.object({cid: z.string(), userType: z.nativeEnum(GlobalUserType), total: z.number()}).array(),
|
|
32
|
+
byType: z.object({userType: z.nativeEnum(GlobalUserType), total: z.number()}).array(),
|
|
33
|
+
totalUsers: z.number(),
|
|
34
|
+
totalSaasUsers: z.number(),
|
|
35
|
+
totalStagedUsers: z.number(),
|
|
36
|
+
links: z.object({
|
|
37
|
+
withDevices: z.number(),
|
|
38
|
+
withoutDevices: z.number(),
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
export type UserCountReport = z.infer<typeof _UserCountReport>;
|
|
42
|
+
|
|
43
|
+
export const _SaasCompCountReport = z.object({
|
|
44
|
+
byConnectorKind: z.object({cid: z.string(), kind: z.string(), total: z.number()}).array(),
|
|
45
|
+
totalSaasComps: z.number(),
|
|
46
|
+
totalStagedSaasComps: z.number(),
|
|
47
|
+
links: z.object({
|
|
48
|
+
withUsers: z.number(),
|
|
49
|
+
withoutUsers: z.number(),
|
|
50
|
+
withDevices: z.number(),
|
|
51
|
+
withoutDevices: z.number(),
|
|
52
|
+
orphaned: z.number(),
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
export type SaasCompCountReport = z.infer<typeof _SaasCompCountReport>;
|
|
56
|
+
|
|
57
|
+
const _RecentFindingSummaryReport = z.object({
|
|
58
|
+
openWithUser: z.number(),
|
|
59
|
+
openWithoutUser: z.number(),
|
|
60
|
+
closedWithUser: z.number(),
|
|
61
|
+
closedWithoutUser: z.number(),
|
|
62
|
+
});
|
|
63
|
+
export const _FindingsCountReport = z.object({
|
|
64
|
+
connectorKindSeverityStatus: z
|
|
65
|
+
.object({
|
|
66
|
+
cid: z.string().nullable(),
|
|
67
|
+
kind: z.union([z.nativeEnum(FindingKind), z.string()]),
|
|
68
|
+
severity: z.nativeEnum(FindingSeverity),
|
|
69
|
+
status: z.nativeEnum(FindingStatus),
|
|
70
|
+
total: z.number(),
|
|
71
|
+
})
|
|
72
|
+
.array(),
|
|
73
|
+
total: _RecentFindingSummaryReport,
|
|
74
|
+
total90d: _RecentFindingSummaryReport,
|
|
75
|
+
pending: z.number(),
|
|
76
|
+
links: z.object({
|
|
77
|
+
withUsers: z.number(),
|
|
78
|
+
withoutUsers: z.number(),
|
|
79
|
+
withDevices: z.number(),
|
|
80
|
+
withoutDevices: z.number(),
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
export type FindingsCountReport = z.infer<typeof _FindingsCountReport>;
|
|
84
|
+
|
|
85
|
+
export const _NotificationsCountReport = z.object({
|
|
86
|
+
total: z.number(),
|
|
87
|
+
total7d: z.number(),
|
|
88
|
+
total30d: z.number(),
|
|
89
|
+
total90d: z.number(),
|
|
90
|
+
});
|
|
91
|
+
export type NotificationsCountReport = z.infer<typeof _NotificationsCountReport>;
|
|
92
|
+
|
|
93
|
+
const _FlowStatusSummaryReport = z.object({
|
|
94
|
+
active: z.number(),
|
|
95
|
+
closed: z.number(),
|
|
96
|
+
});
|
|
97
|
+
export const _FlowsCountReport = z.object({
|
|
98
|
+
specsByStatusTrigger: z.object({status: z.nativeEnum(FlowSpecStatusKind), trigger: z.string(), total: z.number()}).array(),
|
|
99
|
+
statesByBucketStatus: z.object({status: z.string(), bucket: z.union([z.nativeEnum(FindingKind), z.string()]), total: z.number()}).array(),
|
|
100
|
+
total: _FlowStatusSummaryReport,
|
|
101
|
+
total7d: _FlowStatusSummaryReport,
|
|
102
|
+
total30d: _FlowStatusSummaryReport,
|
|
103
|
+
total90d: _FlowStatusSummaryReport,
|
|
104
|
+
});
|
|
105
|
+
export type FlowsCountReport = z.infer<typeof _FlowsCountReport>;
|
|
106
|
+
|
|
107
|
+
export const _TenantCountReportDto = z.object({
|
|
108
|
+
users: _UserCountReport,
|
|
109
|
+
assets: _AssetCountReport,
|
|
110
|
+
saasComp: _SaasCompCountReport,
|
|
111
|
+
findings: _FindingsCountReport,
|
|
112
|
+
notifications: _NotificationsCountReport,
|
|
113
|
+
flows: _FlowsCountReport,
|
|
114
|
+
});
|
|
115
|
+
export type TenantCountReportDto = z.infer<typeof _TenantCountReportDto>;
|
package/src/services/AmpSdk.ts
CHANGED
|
@@ -35,8 +35,6 @@ import {
|
|
|
35
35
|
PlatformTokenDto,
|
|
36
36
|
PlatformTokenUpsertDto,
|
|
37
37
|
ProviderDto,
|
|
38
|
-
TenantDto,
|
|
39
|
-
TenantUpsertDto,
|
|
40
38
|
} from '../dto';
|
|
41
39
|
import {
|
|
42
40
|
AmpEntityService,
|
|
@@ -56,6 +54,7 @@ import {ContentfulService} from './contentful.service';
|
|
|
56
54
|
import {FindingsInsightsService} from './findingsInsights.service';
|
|
57
55
|
import {PlatformConnectorService} from './connector.platform.service';
|
|
58
56
|
import {PlatformAgentService} from './AgentsService';
|
|
57
|
+
import {TenantsService} from './rest/TenantsService';
|
|
59
58
|
import {FindingsService} from './findings.service';
|
|
60
59
|
|
|
61
60
|
export type AmpSdkOptions = AmpRestClientOptions;
|
|
@@ -97,7 +96,7 @@ export class AmpSdkServices {
|
|
|
97
96
|
readonly stagedSaaSComponents: TruncatableAmpEntityService<PlatformSaasComponentUpsertDto, PlatformSaasComponentDto>;
|
|
98
97
|
readonly stagedSaaSUsers: TruncatableAmpEntityService<PlatformStagedSaasUserUpsertDto, PlatformStagedSaasUserDto>;
|
|
99
98
|
readonly settings: AmpSdkSettingsService;
|
|
100
|
-
readonly tenants:
|
|
99
|
+
readonly tenants: TenantsService;
|
|
101
100
|
readonly tokens: AmpSdkTenantService<PlatformTokenUpsertDto, PlatformTokenDto>;
|
|
102
101
|
readonly users: AmpSdkUserService;
|
|
103
102
|
|
|
@@ -134,7 +133,7 @@ export class AmpSdkServices {
|
|
|
134
133
|
this.stagedSaaSUsers = new TruncatableAmpEntityServiceImpl<PlatformStagedSaasUserUpsertDto, PlatformStagedSaasUserDto>(rest, KIND.STAGED_SAAS_USERS, TARGET_API_PLATFORM);
|
|
135
134
|
|
|
136
135
|
this.settings = new AmpSdkSettingsService(rest);
|
|
137
|
-
this.tenants = new
|
|
136
|
+
this.tenants = new TenantsService(rest, TARGET_API_PLATFORM);
|
|
138
137
|
this.tokens = new AmpEntityServiceImpl<PlatformTokenUpsertDto, PlatformTokenDto>(rest, KIND.TOKENS, TARGET_API_PLATFORM);
|
|
139
138
|
this.users = new AmpSdkUserService(rest, TARGET_API_PLATFORM);
|
|
140
139
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {TenantCountReportDto, TenantDto, TenantUpsertDto, _TenantCountReportDto} from '../../dto';
|
|
2
|
+
import {KIND, TargetApi} from '../constants';
|
|
3
|
+
import {AmpEntityServiceImpl} from '../entity.service';
|
|
4
|
+
import {RestClient} from './RestClient';
|
|
5
|
+
import {OpsRpcResult, _OpsRpcResult} from '../../dto/platform/platform.ops.dto';
|
|
6
|
+
|
|
7
|
+
export class TenantsService extends AmpEntityServiceImpl<TenantUpsertDto, TenantDto> {
|
|
8
|
+
constructor(rest: RestClient, targetApi: TargetApi = 'api') {
|
|
9
|
+
super(rest, KIND.TENANTS, targetApi);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
countReport(tid: string): Promise<TenantCountReportDto> {
|
|
13
|
+
const url = `/${this.targetApi}/v1/${this.kind}/${tid}/count_report`;
|
|
14
|
+
return this.rest
|
|
15
|
+
.call({
|
|
16
|
+
url,
|
|
17
|
+
method: 'GET',
|
|
18
|
+
})
|
|
19
|
+
.then(res => _TenantCountReportDto.parse(res.data));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* !!! WARNING !!! 🚨 💀 🚨 💀 🚨 💀 🚨 💀
|
|
24
|
+
* This method will permanently HARD delete any soft deleted tenant data, including the tenant itsself. There is no UNDO!
|
|
25
|
+
*
|
|
26
|
+
* @param tid Tenant id to clean
|
|
27
|
+
* @returns void
|
|
28
|
+
* @deprecated do not use this function... unless you REALLY mean it! Note: this is more of a warning than true deprecation.
|
|
29
|
+
*/
|
|
30
|
+
hardDelete(tid: string): Promise<OpsRpcResult> {
|
|
31
|
+
const url = `/${this.targetApi}/v1/ops/rpc`;
|
|
32
|
+
return this.rest
|
|
33
|
+
.call({
|
|
34
|
+
url,
|
|
35
|
+
method: 'POST',
|
|
36
|
+
data: {
|
|
37
|
+
op: 'hardDelete',
|
|
38
|
+
input: {
|
|
39
|
+
tid,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
.then(res => _OpsRpcResult.parse(res.data));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* !!! WARNING !!! 🚨 💀 🚨 💀 🚨 💀 🚨 💀
|
|
48
|
+
* This method will permanently HARD delete a tenant and associated data. There is no UNDO!
|
|
49
|
+
*
|
|
50
|
+
* @param tid Tenant id to delete
|
|
51
|
+
* @returns void
|
|
52
|
+
* @deprecated Use truncate instead... unless you REALLY mean it! Note: this is more of a warning than true deprecation.
|
|
53
|
+
*/
|
|
54
|
+
removeTenant(tid: string): Promise<OpsRpcResult> {
|
|
55
|
+
const url = `/${this.targetApi}/v1/ops/rpc`;
|
|
56
|
+
return this.rest
|
|
57
|
+
.call({
|
|
58
|
+
url,
|
|
59
|
+
method: 'POST',
|
|
60
|
+
data: {
|
|
61
|
+
op: 'removeTenant',
|
|
62
|
+
input: {
|
|
63
|
+
tid,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
.then(res => _OpsRpcResult.parse(res.data));
|
|
68
|
+
}
|
|
69
|
+
}
|