@ampsec/platform-client 70.2.0 → 70.3.1
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/coverage.dto.d.ts +12 -12
- package/build/src/dto/customActions.dto.d.ts +7 -7
- package/build/src/dto/enums/findingKind.d.ts +13 -13
- package/build/src/dto/enums/findingKind.js +25 -24
- package/build/src/dto/enums/findingKind.js.map +1 -1
- package/build/src/dto/findings.dto.d.ts +25 -7
- package/build/src/dto/findings.dto.js +4 -3
- package/build/src/dto/findings.dto.js.map +1 -1
- package/build/src/dto/flows.dto.d.ts +23 -23
- package/build/src/dto/platform/platform.customActions.dto.d.ts +5 -5
- package/build/src/dto/platform/platform.findings.dto.d.ts +14 -0
- package/build/src/dto/platform/platform.flows.dto.d.ts +14 -14
- 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.saasAssets.dto.d.ts +6 -6
- 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/dto/saasAssets.dto.d.ts +16 -16
- package/build/src/dto/users.dto.d.ts +2 -2
- 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/contentful.service.d.ts +6 -6
- 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/enums/findingKind.ts +28 -26
- package/src/dto/findings.dto.ts +4 -2
- 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
package/src/dto/findings.dto.ts
CHANGED
|
@@ -94,7 +94,7 @@ export type FindingBucketSummaryDto = z.infer<typeof _FindingBucketSummaryDto>;
|
|
|
94
94
|
// export type PendingFindingFilter = z.infer<typeof _PendingFindingFilter>;
|
|
95
95
|
|
|
96
96
|
const _FindingSpecDescription = z.unknown();
|
|
97
|
-
const _FindingSpecInsights = z.object({
|
|
97
|
+
export const _FindingSpecInsights = z.object({
|
|
98
98
|
meta: z
|
|
99
99
|
.object({
|
|
100
100
|
kind: z.nativeEnum(FindingKind),
|
|
@@ -116,11 +116,14 @@ const _FindingSpecInsights = z.object({
|
|
|
116
116
|
$has: z.boolean(),
|
|
117
117
|
})
|
|
118
118
|
.optional(),
|
|
119
|
+
severity: z.nativeEnum(FindingSeverity).optional(),
|
|
119
120
|
findingCondition: z.record(z.string(), z.union([z.boolean(), z.string(), z.number(), z.undefined()])),
|
|
120
121
|
remediatedCondition: z.record(z.string(), z.union([z.boolean(), z.string(), z.number(), z.undefined()])).optional(),
|
|
121
122
|
})
|
|
122
123
|
.optional(),
|
|
123
124
|
});
|
|
125
|
+
export type FindingSpecInsights = z.infer<typeof _FindingSpecInsights>;
|
|
126
|
+
|
|
124
127
|
export const _FindingSpecDto = _BaseDto.extend({
|
|
125
128
|
cid: z.string().nullable().optional(),
|
|
126
129
|
name: z.string(),
|
|
@@ -135,7 +138,6 @@ export const _FindingSpecDto = _BaseDto.extend({
|
|
|
135
138
|
score: z.number().optional(),
|
|
136
139
|
});
|
|
137
140
|
|
|
138
|
-
export type FindingSpecInsights = z.infer<typeof _FindingSpecInsights>;
|
|
139
141
|
export type FindingSpecDto = z.infer<typeof _FindingSpecDto>;
|
|
140
142
|
|
|
141
143
|
export const _FindingSpecUpsertDto = _FindingSpecDto.partial(UPSERT_DTO_MASK);
|
|
@@ -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
|
+
}
|