@cloud-copilot/iam-simulate 0.1.5 → 0.1.7
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/dist/cjs/ConditionKeys.d.ts +19 -0
- package/dist/cjs/ConditionKeys.d.ts.map +1 -0
- package/dist/cjs/ConditionKeys.js +27 -0
- package/dist/cjs/ConditionKeys.js.map +1 -0
- package/dist/cjs/SCPAnalysis.d.ts +6 -0
- package/dist/cjs/SCPAnalysis.d.ts.map +1 -0
- package/dist/cjs/SCPAnalysis.js +3 -0
- package/dist/cjs/SCPAnalysis.js.map +1 -0
- package/dist/cjs/context_keys/findContextKeys.d.ts +19 -0
- package/dist/cjs/context_keys/findContextKeys.d.ts.map +1 -0
- package/dist/cjs/context_keys/findContextKeys.js +57 -0
- package/dist/cjs/context_keys/findContextKeys.js.map +1 -0
- package/dist/cjs/core_engine/coreSimulatorEngine.d.ts +39 -0
- package/dist/cjs/core_engine/coreSimulatorEngine.d.ts.map +1 -1
- package/dist/cjs/core_engine/coreSimulatorEngine.js +56 -0
- package/dist/cjs/core_engine/coreSimulatorEngine.js.map +1 -1
- package/dist/cjs/evaluate.d.ts +1 -0
- package/dist/cjs/evaluate.d.ts.map +1 -1
- package/dist/cjs/global_conditions/globalConditionKeys.d.ts +9 -1
- package/dist/cjs/global_conditions/globalConditionKeys.d.ts.map +1 -1
- package/dist/cjs/global_conditions/globalConditionKeys.js +78 -50
- package/dist/cjs/global_conditions/globalConditionKeys.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +10 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/principal/principal.d.ts +9 -1
- package/dist/cjs/principal/principal.d.ts.map +1 -1
- package/dist/cjs/principal/principal.js +17 -0
- package/dist/cjs/principal/principal.js.map +1 -1
- package/dist/cjs/request/requestPrincipal.d.ts.map +1 -1
- package/dist/cjs/request/requestPrincipal.js.map +1 -1
- package/dist/cjs/services/DefaultServiceAuthorizer.d.ts +30 -1
- package/dist/cjs/services/DefaultServiceAuthorizer.d.ts.map +1 -1
- package/dist/cjs/services/DefaultServiceAuthorizer.js +93 -7
- package/dist/cjs/services/DefaultServiceAuthorizer.js.map +1 -1
- package/dist/cjs/services/ServiceAuthorizer.d.ts +3 -0
- package/dist/cjs/services/ServiceAuthorizer.d.ts.map +1 -1
- package/dist/cjs/simulation_engine/contextKeys.d.ts +9 -1
- package/dist/cjs/simulation_engine/contextKeys.d.ts.map +1 -1
- package/dist/cjs/simulation_engine/contextKeys.js +27 -40
- package/dist/cjs/simulation_engine/contextKeys.js.map +1 -1
- package/dist/cjs/simulation_engine/simulation.d.ts +12 -1
- package/dist/cjs/simulation_engine/simulation.d.ts.map +1 -1
- package/dist/cjs/simulation_engine/simulationEngine.d.ts +15 -0
- package/dist/cjs/simulation_engine/simulationEngine.d.ts.map +1 -1
- package/dist/cjs/simulation_engine/simulationEngine.js +126 -15
- package/dist/cjs/simulation_engine/simulationEngine.js.map +1 -1
- package/dist/cjs/simulation_engine/unsafeSimulationEngine.d.ts +1 -1
- package/dist/cjs/simulation_engine/unsafeSimulationEngine.d.ts.map +1 -1
- package/dist/cjs/simulation_engine/unsafeSimulationEngine.js +13 -4
- package/dist/cjs/simulation_engine/unsafeSimulationEngine.js.map +1 -1
- package/dist/cjs/util.d.ts +69 -0
- package/dist/cjs/util.d.ts.map +1 -1
- package/dist/cjs/util.js +166 -0
- package/dist/cjs/util.js.map +1 -1
- package/dist/esm/ConditionKeys.d.ts +19 -0
- package/dist/esm/ConditionKeys.d.ts.map +1 -0
- package/dist/esm/ConditionKeys.js +23 -0
- package/dist/esm/ConditionKeys.js.map +1 -0
- package/dist/esm/SCPAnalysis.d.ts +6 -0
- package/dist/esm/SCPAnalysis.d.ts.map +1 -0
- package/dist/esm/SCPAnalysis.js +2 -0
- package/dist/esm/SCPAnalysis.js.map +1 -0
- package/dist/esm/context_keys/findContextKeys.d.ts +19 -0
- package/dist/esm/context_keys/findContextKeys.d.ts.map +1 -0
- package/dist/esm/context_keys/findContextKeys.js +53 -0
- package/dist/esm/context_keys/findContextKeys.js.map +1 -0
- package/dist/esm/core_engine/coreSimulatorEngine.d.ts +39 -0
- package/dist/esm/core_engine/coreSimulatorEngine.d.ts.map +1 -1
- package/dist/esm/core_engine/coreSimulatorEngine.js +54 -0
- package/dist/esm/core_engine/coreSimulatorEngine.js.map +1 -1
- package/dist/esm/evaluate.d.ts +1 -0
- package/dist/esm/evaluate.d.ts.map +1 -1
- package/dist/esm/global_conditions/globalConditionKeys.d.ts +9 -1
- package/dist/esm/global_conditions/globalConditionKeys.d.ts.map +1 -1
- package/dist/esm/global_conditions/globalConditionKeys.js +76 -50
- package/dist/esm/global_conditions/globalConditionKeys.js.map +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/principal/principal.d.ts +9 -1
- package/dist/esm/principal/principal.d.ts.map +1 -1
- package/dist/esm/principal/principal.js +16 -0
- package/dist/esm/principal/principal.js.map +1 -1
- package/dist/esm/request/requestPrincipal.d.ts.map +1 -1
- package/dist/esm/request/requestPrincipal.js.map +1 -1
- package/dist/esm/services/DefaultServiceAuthorizer.d.ts +30 -1
- package/dist/esm/services/DefaultServiceAuthorizer.d.ts.map +1 -1
- package/dist/esm/services/DefaultServiceAuthorizer.js +93 -7
- package/dist/esm/services/DefaultServiceAuthorizer.js.map +1 -1
- package/dist/esm/services/ServiceAuthorizer.d.ts +3 -0
- package/dist/esm/services/ServiceAuthorizer.d.ts.map +1 -1
- package/dist/esm/simulation_engine/contextKeys.d.ts +9 -1
- package/dist/esm/simulation_engine/contextKeys.d.ts.map +1 -1
- package/dist/esm/simulation_engine/contextKeys.js +28 -40
- package/dist/esm/simulation_engine/contextKeys.js.map +1 -1
- package/dist/esm/simulation_engine/simulation.d.ts +12 -1
- package/dist/esm/simulation_engine/simulation.d.ts.map +1 -1
- package/dist/esm/simulation_engine/simulationEngine.d.ts +15 -0
- package/dist/esm/simulation_engine/simulationEngine.d.ts.map +1 -1
- package/dist/esm/simulation_engine/simulationEngine.js +126 -16
- package/dist/esm/simulation_engine/simulationEngine.js.map +1 -1
- package/dist/esm/simulation_engine/unsafeSimulationEngine.d.ts +1 -1
- package/dist/esm/simulation_engine/unsafeSimulationEngine.d.ts.map +1 -1
- package/dist/esm/simulation_engine/unsafeSimulationEngine.js +13 -4
- package/dist/esm/simulation_engine/unsafeSimulationEngine.js.map +1 -1
- package/dist/esm/util.d.ts +69 -0
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/esm/util.js +158 -0
- package/dist/esm/util.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/util.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ResourceType } from '@cloud-copilot/iam-data';
|
|
2
|
+
import { ConditionKeyType } from './ConditionKeys.js';
|
|
1
3
|
import { AwsRequest } from './request/request.js';
|
|
2
4
|
interface StringReplaceOptions {
|
|
3
5
|
replaceWildcards: boolean;
|
|
@@ -20,6 +22,12 @@ export interface ArnParts {
|
|
|
20
22
|
resourceType: string | undefined;
|
|
21
23
|
resourcePath: string | undefined;
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Split an ARN into its parts
|
|
27
|
+
*
|
|
28
|
+
* @param arn the arn to split
|
|
29
|
+
* @returns the parts of the ARN
|
|
30
|
+
*/
|
|
23
31
|
export declare function splitArnParts(arn: string): ArnParts;
|
|
24
32
|
/**
|
|
25
33
|
* Splits a resource into two segments. The first segment is the product segment and the second segment is the resource id segment.
|
|
@@ -43,5 +51,66 @@ export declare function isDefined<T>(value: T | undefined): value is T;
|
|
|
43
51
|
* @returns if the value is not defined or null
|
|
44
52
|
*/
|
|
45
53
|
export declare function isNotDefined<T>(value: T | undefined): value is undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if an action is a wildcard only action
|
|
56
|
+
*
|
|
57
|
+
* @param service the service the action belongs to
|
|
58
|
+
* @param action the action to check if it is a wildcard only action
|
|
59
|
+
* @returns if the action is a wildcard only action
|
|
60
|
+
* @throws an error if the service or action does not exist
|
|
61
|
+
*/
|
|
62
|
+
export declare function isWildcardOnlyAction(service: string, action: string): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Get the the possible reource types for an action and resource
|
|
65
|
+
*
|
|
66
|
+
* @param service the service the action belongs to
|
|
67
|
+
* @param action the action to get the resource type for
|
|
68
|
+
* @param resource the resource type matching the action, if any
|
|
69
|
+
* @throws an error if the service or action does not exist, or if the action is a wildcard only action
|
|
70
|
+
*/
|
|
71
|
+
export declare function getResourceTypesForAction(service: string, action: string, resource: string): Promise<ResourceType[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Convert a resource pattern from iam-data to a regex pattern
|
|
74
|
+
*
|
|
75
|
+
* @param pattern the pattern to convert to a regex
|
|
76
|
+
* @returns the regex pattern
|
|
77
|
+
*/
|
|
78
|
+
export declare function convertResourcePatternToRegex(pattern: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Lowercase all strings in an array
|
|
81
|
+
*
|
|
82
|
+
* @param strings the strings to lowercase
|
|
83
|
+
* @returns the lowercased strings
|
|
84
|
+
*/
|
|
85
|
+
export declare function lowerCaseAll(strings: string[]): string[];
|
|
86
|
+
/**
|
|
87
|
+
* Check the capitalization of a context key and return the correct capitalization
|
|
88
|
+
*
|
|
89
|
+
* @param contextKey the condition key to check
|
|
90
|
+
* @returns if the condition key is an array type
|
|
91
|
+
*/
|
|
92
|
+
export declare function normalizeContextKeyCase(contextKey: string): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Get the type of a context key
|
|
95
|
+
*
|
|
96
|
+
* @param contextKey - The string condition key to get the type for
|
|
97
|
+
* @returns The type of the condition key
|
|
98
|
+
* @throws an error if the condition key is not found
|
|
99
|
+
*/
|
|
100
|
+
export declare function typeForContextKey(contextKey: string): Promise<ConditionKeyType>;
|
|
101
|
+
/**
|
|
102
|
+
* Gets the IAM variables from a string
|
|
103
|
+
*
|
|
104
|
+
* @param value the string to get the variables from
|
|
105
|
+
* @returns the variables in the string, if any
|
|
106
|
+
*/
|
|
107
|
+
export declare function getVariablesFromString(value: string): string[];
|
|
108
|
+
/**
|
|
109
|
+
* Check if a context key actually exists
|
|
110
|
+
*
|
|
111
|
+
* @param key The context key to check
|
|
112
|
+
* @returns true if the context key is valid, false otherwise
|
|
113
|
+
*/
|
|
114
|
+
export declare function isActualContextKey(key: string): Promise<boolean>;
|
|
46
115
|
export {};
|
|
47
116
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/cjs/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAIjD,UAAU,oBAAoB;IAC5B,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAMD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,MAAM,CA4DlI;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6G,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACjK,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAIjD,UAAU,oBAAoB;IAC5B,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAMD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,OAAO,CA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AE,CAExD;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBjF;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAarF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAY9D;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBtE"}
|
package/dist/cjs/util.js
CHANGED
|
@@ -5,6 +5,16 @@ exports.splitArnParts = splitArnParts;
|
|
|
5
5
|
exports.getResourceSegments = getResourceSegments;
|
|
6
6
|
exports.isDefined = isDefined;
|
|
7
7
|
exports.isNotDefined = isNotDefined;
|
|
8
|
+
exports.isWildcardOnlyAction = isWildcardOnlyAction;
|
|
9
|
+
exports.getResourceTypesForAction = getResourceTypesForAction;
|
|
10
|
+
exports.convertResourcePatternToRegex = convertResourcePatternToRegex;
|
|
11
|
+
exports.lowerCaseAll = lowerCaseAll;
|
|
12
|
+
exports.normalizeContextKeyCase = normalizeContextKeyCase;
|
|
13
|
+
exports.typeForContextKey = typeForContextKey;
|
|
14
|
+
exports.getVariablesFromString = getVariablesFromString;
|
|
15
|
+
exports.isActualContextKey = isActualContextKey;
|
|
16
|
+
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
17
|
+
const globalConditionKeys_js_1 = require("./global_conditions/globalConditionKeys.js");
|
|
8
18
|
const matchesNothing = new RegExp('a^');
|
|
9
19
|
const defaultStringReplaceOptions = {
|
|
10
20
|
replaceWildcards: true
|
|
@@ -104,12 +114,26 @@ function getContextSingleValue(request, contextKeyName) {
|
|
|
104
114
|
}
|
|
105
115
|
return undefined;
|
|
106
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the replacement value for a string
|
|
119
|
+
*
|
|
120
|
+
* @param rawString the string to replace the value in
|
|
121
|
+
* @param wildcard the value to replace the wildcard with
|
|
122
|
+
* @param replaceWildcards if the wildcard or raw string should be used
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
107
125
|
function replacementValue(rawString, wildcard, replaceWildcards) {
|
|
108
126
|
if (replaceWildcards) {
|
|
109
127
|
return wildcard;
|
|
110
128
|
}
|
|
111
129
|
return rawString;
|
|
112
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Split an ARN into its parts
|
|
133
|
+
*
|
|
134
|
+
* @param arn the arn to split
|
|
135
|
+
* @returns the parts of the ARN
|
|
136
|
+
*/
|
|
113
137
|
function splitArnParts(arn) {
|
|
114
138
|
const parts = arn.split(':');
|
|
115
139
|
const partition = parts.at(1);
|
|
@@ -177,4 +201,146 @@ function isDefined(value) {
|
|
|
177
201
|
function isNotDefined(value) {
|
|
178
202
|
return !isDefined(value);
|
|
179
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Checks if an action is a wildcard only action
|
|
206
|
+
*
|
|
207
|
+
* @param service the service the action belongs to
|
|
208
|
+
* @param action the action to check if it is a wildcard only action
|
|
209
|
+
* @returns if the action is a wildcard only action
|
|
210
|
+
* @throws an error if the service or action does not exist
|
|
211
|
+
*/
|
|
212
|
+
async function isWildcardOnlyAction(service, action) {
|
|
213
|
+
const actionDetails = await (0, iam_data_1.iamActionDetails)(service, action);
|
|
214
|
+
return actionDetails.resourceTypes.length === 0;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get the the possible reource types for an action and resource
|
|
218
|
+
*
|
|
219
|
+
* @param service the service the action belongs to
|
|
220
|
+
* @param action the action to get the resource type for
|
|
221
|
+
* @param resource the resource type matching the action, if any
|
|
222
|
+
* @throws an error if the service or action does not exist, or if the action is a wildcard only action
|
|
223
|
+
*/
|
|
224
|
+
async function getResourceTypesForAction(service, action, resource) {
|
|
225
|
+
const actionDetails = await (0, iam_data_1.iamActionDetails)(service, action);
|
|
226
|
+
if (actionDetails.resourceTypes.length === 0) {
|
|
227
|
+
throw new Error(`${service}:${action} does not have any resource types`);
|
|
228
|
+
}
|
|
229
|
+
const matchingResourceTypes = [];
|
|
230
|
+
for (const rt of actionDetails.resourceTypes) {
|
|
231
|
+
const resourceType = await (0, iam_data_1.iamResourceTypeDetails)(service, rt.name);
|
|
232
|
+
const pattern = convertResourcePatternToRegex(resourceType.arn);
|
|
233
|
+
const match = resource.match(new RegExp(pattern));
|
|
234
|
+
if (match) {
|
|
235
|
+
matchingResourceTypes.push(resourceType);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return matchingResourceTypes;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Convert a resource pattern from iam-data to a regex pattern
|
|
242
|
+
*
|
|
243
|
+
* @param pattern the pattern to convert to a regex
|
|
244
|
+
* @returns the regex pattern
|
|
245
|
+
*/
|
|
246
|
+
function convertResourcePatternToRegex(pattern) {
|
|
247
|
+
const regex = pattern.replace(/\$\{.*?\}/g, (match) => {
|
|
248
|
+
const name = match.substring(2, match.length - 1);
|
|
249
|
+
const camelName = name.at(0)?.toLowerCase() + name.substring(1);
|
|
250
|
+
return `(?<${camelName}>(.*?))`;
|
|
251
|
+
});
|
|
252
|
+
return `^${regex}$`;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Lowercase all strings in an array
|
|
256
|
+
*
|
|
257
|
+
* @param strings the strings to lowercase
|
|
258
|
+
* @returns the lowercased strings
|
|
259
|
+
*/
|
|
260
|
+
function lowerCaseAll(strings) {
|
|
261
|
+
return strings.map(s => s.toLowerCase());
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Check the capitalization of a context key and return the correct capitalization
|
|
265
|
+
*
|
|
266
|
+
* @param contextKey the condition key to check
|
|
267
|
+
* @returns if the condition key is an array type
|
|
268
|
+
*/
|
|
269
|
+
async function normalizeContextKeyCase(contextKey) {
|
|
270
|
+
const [service, key] = contextKey.split(":");
|
|
271
|
+
const serviceExists = await (0, iam_data_1.iamServiceExists)(service);
|
|
272
|
+
if (serviceExists) {
|
|
273
|
+
const serviceKeyExists = await (0, iam_data_1.iamConditionKeyExists)(service, contextKey);
|
|
274
|
+
if (serviceKeyExists) {
|
|
275
|
+
const keyDetails = await (0, iam_data_1.iamConditionKeyDetails)(service, contextKey);
|
|
276
|
+
return keyDetails.key;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const globalConditionKey = (0, globalConditionKeys_js_1.getGlobalConditionKey)(contextKey);
|
|
280
|
+
if (globalConditionKey) {
|
|
281
|
+
return globalConditionKey.key;
|
|
282
|
+
}
|
|
283
|
+
throw new Error(`Context key ${contextKey} not found`);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get the type of a context key
|
|
287
|
+
*
|
|
288
|
+
* @param contextKey - The string condition key to get the type for
|
|
289
|
+
* @returns The type of the condition key
|
|
290
|
+
* @throws an error if the condition key is not found
|
|
291
|
+
*/
|
|
292
|
+
async function typeForContextKey(contextKey) {
|
|
293
|
+
const [service, key] = contextKey.split(":");
|
|
294
|
+
const serviceKeyExists = await (0, iam_data_1.iamConditionKeyExists)(service, contextKey);
|
|
295
|
+
if (serviceKeyExists) {
|
|
296
|
+
const keyDetails = await (0, iam_data_1.iamConditionKeyDetails)(service, contextKey);
|
|
297
|
+
return keyDetails.type;
|
|
298
|
+
}
|
|
299
|
+
const globalConditionKey = (0, globalConditionKeys_js_1.getGlobalConditionKey)(contextKey);
|
|
300
|
+
if (globalConditionKey) {
|
|
301
|
+
return globalConditionKey.dataType;
|
|
302
|
+
}
|
|
303
|
+
throw new Error(`Condition key ${contextKey} not found`);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Gets the IAM variables from a string
|
|
307
|
+
*
|
|
308
|
+
* @param value the string to get the variables from
|
|
309
|
+
* @returns the variables in the string, if any
|
|
310
|
+
*/
|
|
311
|
+
function getVariablesFromString(value) {
|
|
312
|
+
const matches = value.match(/\$\{.*?\}/g);
|
|
313
|
+
if (matches) {
|
|
314
|
+
return matches.map((m) => {
|
|
315
|
+
const inBrackets = m.slice(2, -1);
|
|
316
|
+
if (inBrackets.includes(',')) {
|
|
317
|
+
return inBrackets.split(',')[0].trim();
|
|
318
|
+
}
|
|
319
|
+
return inBrackets;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
return [];
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Check if a context key actually exists
|
|
326
|
+
*
|
|
327
|
+
* @param key The context key to check
|
|
328
|
+
* @returns true if the context key is valid, false otherwise
|
|
329
|
+
*/
|
|
330
|
+
async function isActualContextKey(key) {
|
|
331
|
+
if ((0, globalConditionKeys_js_1.globalConditionKeyExists)(key)) {
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
const parts = key.split(":");
|
|
335
|
+
if (parts.length !== 2) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
const [service, action] = parts;
|
|
339
|
+
const serviceExists = await (0, iam_data_1.iamServiceExists)(service);
|
|
340
|
+
if (!serviceExists) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
const actionExists = await (0, iam_data_1.iamConditionKeyExists)(service, key);
|
|
344
|
+
return actionExists;
|
|
345
|
+
}
|
|
180
346
|
//# sourceMappingURL=util.js.map
|
package/dist/cjs/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";;AAuBA,0DA4DC;AA8DD,sCAyBC;AASD,kDAgBC;AAQD,8BAEC;AAQD,oCAEC;AAUD,oDAGC;AAUD,8DAiBC;AAQD,sEAOC;AAQD,oCAEC;AAQD,0DAgBC;AASD,8CAaC;AAQD,wDAYC;AAQD,gDAiBC;AA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AAE,CAAA;AACX,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,IAAG,IAAA,iDAAwB,EAAC,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAG,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;IAChC,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAgB,EAAC,OAAO,CAAC,CAAC;IAEtD,IAAG,CAAC,aAAa,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,gCAAqB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC/D,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BaseConditionKeyType = 'String' | 'ARN' | 'Numeric' | 'Bool' | 'Date' | 'IPAddress' | 'Binary';
|
|
2
|
+
export type ArrayConditionKeyType = `ArrayOf${BaseConditionKeyType}`;
|
|
3
|
+
export type ConditionKeyType = BaseConditionKeyType | ArrayConditionKeyType;
|
|
4
|
+
/**
|
|
5
|
+
* Check if a condition key is an array types
|
|
6
|
+
*
|
|
7
|
+
* @param key the condition key type to check
|
|
8
|
+
* @returns true if the key is an array type, otherwise false
|
|
9
|
+
*/
|
|
10
|
+
export declare function isConditionKeyArray(key: ConditionKeyType): key is ArrayConditionKeyType;
|
|
11
|
+
/**
|
|
12
|
+
* Get the BaseConditionKeyType from an ArrayConditionKeyType
|
|
13
|
+
*
|
|
14
|
+
* @param key the ArrayConditionKeyType to get the base type from
|
|
15
|
+
* @returns the base type of the array key
|
|
16
|
+
* @throws if the key is not an array type
|
|
17
|
+
*/
|
|
18
|
+
export declare function getBaseConditionKeyType(key: ArrayConditionKeyType): BaseConditionKeyType;
|
|
19
|
+
//# sourceMappingURL=ConditionKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionKeys.d.ts","sourceRoot":"","sources":["../../src/ConditionKeys.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;AAC1G,MAAM,MAAM,qBAAqB,GAAG,UAAU,oBAAoB,EAAE,CAAA;AACpE,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAE3E;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,GAAG,GAAG,IAAI,qBAAqB,CAEvF;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,qBAAqB,GAAG,oBAAoB,CAKxF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a condition key is an array types
|
|
3
|
+
*
|
|
4
|
+
* @param key the condition key type to check
|
|
5
|
+
* @returns true if the key is an array type, otherwise false
|
|
6
|
+
*/
|
|
7
|
+
export function isConditionKeyArray(key) {
|
|
8
|
+
return key.startsWith('ArrayOf');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get the BaseConditionKeyType from an ArrayConditionKeyType
|
|
12
|
+
*
|
|
13
|
+
* @param key the ArrayConditionKeyType to get the base type from
|
|
14
|
+
* @returns the base type of the array key
|
|
15
|
+
* @throws if the key is not an array type
|
|
16
|
+
*/
|
|
17
|
+
export function getBaseConditionKeyType(key) {
|
|
18
|
+
if (!isConditionKeyArray(key)) {
|
|
19
|
+
throw new Error(`Expected ArrayConditionType, got ${key}`);
|
|
20
|
+
}
|
|
21
|
+
return key.slice(7);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ConditionKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionKeys.js","sourceRoot":"","sources":["../../src/ConditionKeys.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAqB;IACvD,OAAO,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAA0B;IAChE,IAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,EAAE,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAyB,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SCPAnalysis.d.ts","sourceRoot":"","sources":["../../src/SCPAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SCPAnalysis.js","sourceRoot":"","sources":["../../src/SCPAnalysis.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Policy } from "@cloud-copilot/iam-policy";
|
|
2
|
+
/**
|
|
3
|
+
* Find all the context keys in a list of policies
|
|
4
|
+
*
|
|
5
|
+
* @param policies - The list of policies to search
|
|
6
|
+
* @returns The list of valid and invalid context keys found in the policies
|
|
7
|
+
*/
|
|
8
|
+
export declare function findContextKeys(policies: Policy[]): Promise<{
|
|
9
|
+
validKeys: string[];
|
|
10
|
+
invalidKeys: string[];
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Get the context variables used in a policy
|
|
14
|
+
*
|
|
15
|
+
* @param policy - The policy to extract variables from
|
|
16
|
+
* @returns The list of variables used in the policy
|
|
17
|
+
*/
|
|
18
|
+
export declare function getContextKeysFromPolicy(policy: Policy): string[];
|
|
19
|
+
//# sourceMappingURL=findContextKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findContextKeys.d.ts","sourceRoot":"","sources":["../../../src/context_keys/findContextKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAGnD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAqBjH;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBjE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getVariablesFromString, isActualContextKey, normalizeContextKeyCase } from "../util.js";
|
|
2
|
+
/**
|
|
3
|
+
* Find all the context keys in a list of policies
|
|
4
|
+
*
|
|
5
|
+
* @param policies - The list of policies to search
|
|
6
|
+
* @returns The list of valid and invalid context keys found in the policies
|
|
7
|
+
*/
|
|
8
|
+
export async function findContextKeys(policies) {
|
|
9
|
+
const rawKeys = new Set();
|
|
10
|
+
for (const policy of policies) {
|
|
11
|
+
getContextKeysFromPolicy(policy).forEach(v => rawKeys.add(v));
|
|
12
|
+
}
|
|
13
|
+
const validKeys = new Set();
|
|
14
|
+
const invalidKeys = new Set();
|
|
15
|
+
for (const key of rawKeys) {
|
|
16
|
+
const valid = await isActualContextKey(key);
|
|
17
|
+
if (valid) {
|
|
18
|
+
const normalizedKey = await normalizeContextKeyCase(key);
|
|
19
|
+
validKeys.add(normalizedKey);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
invalidKeys.add(key);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
validKeys: Array.from(validKeys),
|
|
27
|
+
invalidKeys: Array.from(invalidKeys)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the context variables used in a policy
|
|
32
|
+
*
|
|
33
|
+
* @param policy - The policy to extract variables from
|
|
34
|
+
* @returns The list of variables used in the policy
|
|
35
|
+
*/
|
|
36
|
+
export function getContextKeysFromPolicy(policy) {
|
|
37
|
+
const variables = [];
|
|
38
|
+
for (const statement of policy.statements()) {
|
|
39
|
+
if (statement.isResourceStatement()) {
|
|
40
|
+
statement.resources().forEach(r => {
|
|
41
|
+
variables.push(...getVariablesFromString(r.value()));
|
|
42
|
+
});
|
|
43
|
+
for (const condition of statement.conditions()) {
|
|
44
|
+
variables.push(condition.conditionKey());
|
|
45
|
+
condition.conditionValues().forEach(v => {
|
|
46
|
+
variables.push(...getVariablesFromString(v));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return variables;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=findContextKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findContextKeys.js","sourceRoot":"","sources":["../../../src/context_keys/findContextKeys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAEjG;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAkB;IACtD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAI,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC7B,wBAAwB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE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AAC,EAAE;oBACtC,SAAS,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { Policy } from "@cloud-copilot/iam-policy";
|
|
2
2
|
import { EvaluationResult } from "../evaluate.js";
|
|
3
3
|
import { AwsRequest } from "../request/request.js";
|
|
4
|
+
import { SCPAnalysis } from "../SCPAnalysis.js";
|
|
4
5
|
import { ServiceAuthorizer } from "../services/ServiceAuthorizer.js";
|
|
5
6
|
import { StatementAnalysis } from "../StatementAnalysis.js";
|
|
7
|
+
/**
|
|
8
|
+
* A set of service control policies for each level of an organization tree
|
|
9
|
+
*/
|
|
10
|
+
export interface ServiceControlPolicies {
|
|
11
|
+
/**
|
|
12
|
+
* The organization identifier for the organizational unit these policies apply to.
|
|
13
|
+
*/
|
|
14
|
+
orgIdentifier: string;
|
|
15
|
+
/**
|
|
16
|
+
* The policies that apply to this organizational unit.
|
|
17
|
+
*/
|
|
18
|
+
policies: Policy[];
|
|
19
|
+
}
|
|
6
20
|
/**
|
|
7
21
|
* A reqest to authorize a service action.
|
|
8
22
|
*/
|
|
@@ -15,6 +29,15 @@ export interface AuthorizationRequest {
|
|
|
15
29
|
* The identity policies that are applicable to the principal making the request.
|
|
16
30
|
*/
|
|
17
31
|
identityPolicies: Policy[];
|
|
32
|
+
/**
|
|
33
|
+
* The service control policies that apply to the principal making the request. In
|
|
34
|
+
* order of the orgnaization hierarchy. So the root ou SCPS should be first.
|
|
35
|
+
*/
|
|
36
|
+
serviceControlPolicies: ServiceControlPolicies[];
|
|
37
|
+
/**
|
|
38
|
+
* The resource policy that applies to the resource being accessed.
|
|
39
|
+
*/
|
|
40
|
+
resourcePolicy: Policy | undefined;
|
|
18
41
|
}
|
|
19
42
|
/**
|
|
20
43
|
* Authorizes a request.
|
|
@@ -41,4 +64,20 @@ export declare function getServiceAuthorizer(request: AuthorizationRequest): Ser
|
|
|
41
64
|
* @returns an array of statement analysis results
|
|
42
65
|
*/
|
|
43
66
|
export declare function analyzeIdentityPolicies(identityPolicies: Policy[], request: AwsRequest): StatementAnalysis[];
|
|
67
|
+
/**
|
|
68
|
+
* Analyzes a set of service control policies and the statements within them.
|
|
69
|
+
*
|
|
70
|
+
* @param serviceControlPolicies the service control policies to analyze
|
|
71
|
+
* @param request the request to analyze against
|
|
72
|
+
* @returns an array of SCP analysis results
|
|
73
|
+
*/
|
|
74
|
+
export declare function analyzeServiceControlPolicies(serviceControlPolicies: ServiceControlPolicies[], request: AwsRequest): SCPAnalysis[];
|
|
75
|
+
/**
|
|
76
|
+
* Analyze a resource policy and return the results
|
|
77
|
+
*
|
|
78
|
+
* @param resourcePolicy the resource policy to analyze
|
|
79
|
+
* @param request the request to analyze against
|
|
80
|
+
* @returns an array of statement analysis results
|
|
81
|
+
*/
|
|
82
|
+
export declare function analyzeResourcePolicy(resourcePolicy: Policy, request: AwsRequest): StatementAnalysis[];
|
|
44
83
|
//# sourceMappingURL=coreSimulatorEngine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreSimulatorEngine.d.ts","sourceRoot":"","sources":["../../../src/core_engine/coreSimulatorEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAGnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"coreSimulatorEngine.d.ts","sourceRoot":"","sources":["../../../src/core_engine/coreSimulatorEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAGnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,OAAO,EAAE,UAAU,CAAC;IAEpB;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAE1B;;;OAGG;IACH,sBAAsB,EAAE,sBAAsB,EAAE,CAAA;IAEhD;;OAEG;IACH,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAID;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB,CAYzE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,iBAAiB,CAMrF;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,GAAG,iBAAiB,EAAE,CAe5G;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,EAAE,OAAO,EAAE,UAAU,GAAG,WAAW,EAAE,CAsBlI;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,iBAAiB,EAAE,CAatG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { requestMatchesStatementActions } from "../action/action.js";
|
|
2
2
|
import { requestMatchesConditions } from "../condition/condition.js";
|
|
3
|
+
import { requestMatchesStatementPrincipals } from "../principal/principal.js";
|
|
3
4
|
import { requestMatchesStatementResources } from "../resource/resource.js";
|
|
4
5
|
import { DefaultServiceAuthorizer } from "../services/DefaultServiceAuthorizer.js";
|
|
5
6
|
const serviceEngines = {};
|
|
@@ -13,10 +14,14 @@ const serviceEngines = {};
|
|
|
13
14
|
*/
|
|
14
15
|
export function authorize(request) {
|
|
15
16
|
const identityAnalysis = analyzeIdentityPolicies(request.identityPolicies, request.request);
|
|
17
|
+
const scpAnalysis = analyzeServiceControlPolicies(request.serviceControlPolicies, request.request);
|
|
16
18
|
const serviceAuthorizer = getServiceAuthorizer(request);
|
|
19
|
+
const resourceAnalysis = request.resourcePolicy ? analyzeResourcePolicy(request.resourcePolicy, request.request) : [];
|
|
17
20
|
return serviceAuthorizer.authorize({
|
|
18
21
|
request: request.request,
|
|
19
22
|
identityStatements: identityAnalysis,
|
|
23
|
+
scpAnalysis,
|
|
24
|
+
resourceAnalysis
|
|
20
25
|
});
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
@@ -55,4 +60,53 @@ export function analyzeIdentityPolicies(identityPolicies, request) {
|
|
|
55
60
|
}
|
|
56
61
|
return analysis;
|
|
57
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Analyzes a set of service control policies and the statements within them.
|
|
65
|
+
*
|
|
66
|
+
* @param serviceControlPolicies the service control policies to analyze
|
|
67
|
+
* @param request the request to analyze against
|
|
68
|
+
* @returns an array of SCP analysis results
|
|
69
|
+
*/
|
|
70
|
+
export function analyzeServiceControlPolicies(serviceControlPolicies, request) {
|
|
71
|
+
const analysis = [];
|
|
72
|
+
for (const controlPolicy of serviceControlPolicies) {
|
|
73
|
+
const ouAnalysis = {
|
|
74
|
+
orgIdentifier: controlPolicy.orgIdentifier,
|
|
75
|
+
statementAnalysis: [],
|
|
76
|
+
};
|
|
77
|
+
for (const policy of controlPolicy.policies) {
|
|
78
|
+
for (const statement of policy.statements()) {
|
|
79
|
+
ouAnalysis.statementAnalysis.push({
|
|
80
|
+
statement,
|
|
81
|
+
resourceMatch: requestMatchesStatementResources(request, statement),
|
|
82
|
+
actionMatch: requestMatchesStatementActions(request, statement),
|
|
83
|
+
conditionMatch: requestMatchesConditions(request, statement.conditions()),
|
|
84
|
+
principalMatch: 'Match',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
analysis.push(ouAnalysis);
|
|
89
|
+
}
|
|
90
|
+
return analysis;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Analyze a resource policy and return the results
|
|
94
|
+
*
|
|
95
|
+
* @param resourcePolicy the resource policy to analyze
|
|
96
|
+
* @param request the request to analyze against
|
|
97
|
+
* @returns an array of statement analysis results
|
|
98
|
+
*/
|
|
99
|
+
export function analyzeResourcePolicy(resourcePolicy, request) {
|
|
100
|
+
const analysis = [];
|
|
101
|
+
for (const statement of resourcePolicy.statements()) {
|
|
102
|
+
analysis.push({
|
|
103
|
+
statement,
|
|
104
|
+
resourceMatch: requestMatchesStatementResources(request, statement),
|
|
105
|
+
actionMatch: requestMatchesStatementActions(request, statement),
|
|
106
|
+
conditionMatch: requestMatchesConditions(request, statement.conditions()),
|
|
107
|
+
principalMatch: requestMatchesStatementPrincipals(request, statement),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return analysis;
|
|
111
|
+
}
|
|
58
112
|
//# sourceMappingURL=coreSimulatorEngine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreSimulatorEngine.js","sourceRoot":"","sources":["../../../src/core_engine/coreSimulatorEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"coreSimulatorEngine.js","sourceRoot":"","sources":["../../../src/core_engine/coreSimulatorEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,E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AAI,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,cAAsB,EAAE,OAAmB;IAC/E,MAAM,QAAQ,GAAwB,EAAE,CAAC;IACzC,KAAI,MAAM,SAAS,IAAI,cAAc,CAAC,UAAU,EAAE,EAAE,CAAC;QACnD,QAAQ,CAAC,IAAI,CAAC;YACZ,SAAS;YACT,aAAa,EAAE,gCAAgC,CAAC,OAAO,EAAE,SAAS,CAAC;YACnE,WAAW,EAAE,8BAA8B,CAAC,OAAO,EAAE,SAAS,CAAC;YAC/D,cAAc,EAAE,wBAAwB,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC;YACzE,cAAc,EAAE,iCAAiC,CAAC,OAAO,EAAE,SAAS,CAAC;SACtE,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/esm/evaluate.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export type EvaluationResult = 'Allowed' | 'ExplicitlyDenied' | 'AllowedWithConditions' | 'ImplicitlyDenied' | 'Unknown';
|
|
2
|
+
export type ResourceEvaluationResult = 'NotApplicable' | 'Allowed' | 'ExplicitlyDenied' | 'AllowedForAccount' | 'DeniedForAccount' | 'ImplicityDenied';
|
|
2
3
|
//# sourceMappingURL=evaluate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/evaluate.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,kBAAkB,GAAG,uBAAuB,GAAG,kBAAkB,GAAG,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/evaluate.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,kBAAkB,GAAG,uBAAuB,GAAG,kBAAkB,GAAG,SAAS,CAAC;AACzH,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG,SAAS,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { ConditionKeyType } from "../ConditionKeys.js";
|
|
1
2
|
interface GlobalConditionKey {
|
|
2
3
|
key: string;
|
|
3
4
|
category: string;
|
|
4
|
-
dataType:
|
|
5
|
+
dataType: ConditionKeyType;
|
|
5
6
|
}
|
|
6
7
|
export declare function getGlobalConditionKey(key: string): GlobalConditionKey | undefined;
|
|
8
|
+
export declare function globalConditionKeyExists(key: string): boolean;
|
|
7
9
|
export declare function getGlobalConditionKeysByCategory(category: string): GlobalConditionKey[];
|
|
10
|
+
/**
|
|
11
|
+
* Get all the global condition keys as lower case strings
|
|
12
|
+
*
|
|
13
|
+
* @returns a list of all the global condition keys
|
|
14
|
+
*/
|
|
15
|
+
export declare function allGlobalConditionKeys(): string[];
|
|
8
16
|
export {};
|
|
9
17
|
//# sourceMappingURL=globalConditionKeys.d.ts.map
|