@actsecurity/iam-utils 0.1.82
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/LICENSE.txt +661 -0
- package/README.md +5 -0
- package/dist/cjs/actions.d.ts +9 -0
- package/dist/cjs/actions.d.ts.map +1 -0
- package/dist/cjs/actions.js +65 -0
- package/dist/cjs/actions.js.map +1 -0
- package/dist/cjs/arn.d.ts +48 -0
- package/dist/cjs/arn.d.ts.map +1 -0
- package/dist/cjs/arn.js +67 -0
- package/dist/cjs/arn.js.map +1 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/principals.d.ts +58 -0
- package/dist/cjs/principals.d.ts.map +1 -0
- package/dist/cjs/principals.js +93 -0
- package/dist/cjs/principals.js.map +1 -0
- package/dist/cjs/resourceInfoContextKeys.d.ts +19 -0
- package/dist/cjs/resourceInfoContextKeys.d.ts.map +1 -0
- package/dist/cjs/resourceInfoContextKeys.js +54 -0
- package/dist/cjs/resourceInfoContextKeys.js.map +1 -0
- package/dist/cjs/resourcePatterns.d.ts +9 -0
- package/dist/cjs/resourcePatterns.d.ts.map +1 -0
- package/dist/cjs/resourcePatterns.js +19 -0
- package/dist/cjs/resourcePatterns.js.map +1 -0
- package/dist/cjs/resourceTypes.d.ts +30 -0
- package/dist/cjs/resourceTypes.d.ts.map +1 -0
- package/dist/cjs/resourceTypes.js +267 -0
- package/dist/cjs/resourceTypes.js.map +1 -0
- package/dist/cjs/resources.d.ts +8 -0
- package/dist/cjs/resources.d.ts.map +1 -0
- package/dist/cjs/resources.js +14 -0
- package/dist/cjs/resources.js.map +1 -0
- package/dist/cjs/s3.d.ts +15 -0
- package/dist/cjs/s3.d.ts.map +1 -0
- package/dist/cjs/s3.js +35 -0
- package/dist/cjs/s3.js.map +1 -0
- package/dist/esm/actions.d.ts +9 -0
- package/dist/esm/actions.d.ts.map +1 -0
- package/dist/esm/actions.js +62 -0
- package/dist/esm/actions.js.map +1 -0
- package/dist/esm/arn.d.ts +48 -0
- package/dist/esm/arn.d.ts.map +1 -0
- package/dist/esm/arn.js +63 -0
- package/dist/esm/arn.js.map +1 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/principals.d.ts +58 -0
- package/dist/esm/principals.d.ts.map +1 -0
- package/dist/esm/principals.js +83 -0
- package/dist/esm/principals.js.map +1 -0
- package/dist/esm/resourceInfoContextKeys.d.ts +19 -0
- package/dist/esm/resourceInfoContextKeys.d.ts.map +1 -0
- package/dist/esm/resourceInfoContextKeys.js +50 -0
- package/dist/esm/resourceInfoContextKeys.js.map +1 -0
- package/dist/esm/resourcePatterns.d.ts +9 -0
- package/dist/esm/resourcePatterns.d.ts.map +1 -0
- package/dist/esm/resourcePatterns.js +16 -0
- package/dist/esm/resourcePatterns.js.map +1 -0
- package/dist/esm/resourceTypes.d.ts +30 -0
- package/dist/esm/resourceTypes.d.ts.map +1 -0
- package/dist/esm/resourceTypes.js +263 -0
- package/dist/esm/resourceTypes.js.map +1 -0
- package/dist/esm/resources.d.ts +8 -0
- package/dist/esm/resources.d.ts.map +1 -0
- package/dist/esm/resources.js +11 -0
- package/dist/esm/resources.js.map +1 -0
- package/dist/esm/s3.d.ts +15 -0
- package/dist/esm/s3.d.ts.map +1 -0
- package/dist/esm/s3.js +31 -0
- package/dist/esm/s3.js.map +1 -0
- package/package.json +115 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAuC7E"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actionMatchesPattern = actionMatchesPattern;
|
|
4
|
+
/**
|
|
5
|
+
* Checks to see if the action matches the provided IAM action pattern.
|
|
6
|
+
*
|
|
7
|
+
* @param action the action to check, should not contain wildcards
|
|
8
|
+
* @param pattern the pattern to match against, may contain wildcards
|
|
9
|
+
* @returns true if the action matches the pattern, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
function actionMatchesPattern(action, pattern) {
|
|
12
|
+
const unescapedAction = unescapeUnicodeCharacters(action);
|
|
13
|
+
const unescapedPattern = unescapeUnicodeCharacters(pattern);
|
|
14
|
+
// Full wildcard matches everything
|
|
15
|
+
if (unescapedPattern === '*') {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
// Split into service and action parts
|
|
19
|
+
const patternColonIndex = unescapedPattern.indexOf(':');
|
|
20
|
+
const actionColonIndex = unescapedAction.indexOf(':');
|
|
21
|
+
// If pattern has no colon, it must match the entire action exactly (case-insensitive)
|
|
22
|
+
if (patternColonIndex === -1) {
|
|
23
|
+
if (actionColonIndex === -1) {
|
|
24
|
+
return unescapedAction.toLowerCase() === unescapedPattern.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
// If action has no colon but pattern does, no match
|
|
29
|
+
if (actionColonIndex === -1) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const patternService = unescapedPattern.substring(0, patternColonIndex);
|
|
33
|
+
const patternAction = unescapedPattern.substring(patternColonIndex + 1);
|
|
34
|
+
const actionService = unescapedAction.substring(0, actionColonIndex);
|
|
35
|
+
const actionAction = unescapedAction.substring(actionColonIndex + 1);
|
|
36
|
+
// Service must match exactly (case-insensitive), no wildcards allowed
|
|
37
|
+
if (patternService.toLowerCase() !== actionService.toLowerCase()) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// Match the action part with wildcards
|
|
41
|
+
const regex = convertStringToPattern(patternAction);
|
|
42
|
+
return regex.test(actionAction);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Converts an action string pattern to a regular expression for matching.
|
|
46
|
+
*
|
|
47
|
+
* @param actionString the IAM action pattern string to convert
|
|
48
|
+
* @returns RegExp that matches the pattern (case-insensitive)
|
|
49
|
+
*/
|
|
50
|
+
function convertStringToPattern(actionString) {
|
|
51
|
+
const pattern = '^' + actionString.replace(/\?/g, '.').replace(/\*/g, '.*?') + '$';
|
|
52
|
+
return new RegExp(pattern, 'i');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Unescapes unicode characters in a string.
|
|
56
|
+
*
|
|
57
|
+
* @param str The string to unescape
|
|
58
|
+
* @returns The string with any escaped unicode characters replaced with their actual characters
|
|
59
|
+
*/
|
|
60
|
+
function unescapeUnicodeCharacters(str) {
|
|
61
|
+
return str.replace(/\\u([\dA-Fa-f]{4})/gi, (match, code) => {
|
|
62
|
+
return String.fromCharCode(parseInt(code, 16));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":";;AAOA,oDAuCC;AA9CD;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,MAAc,EAAE,OAAe;IAClE,MAAM,eAAe,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACzD,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAE3D,mCAAmC;IACnC,IAAI,gBAAgB,KAAK,GAAG,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,sCAAsC;IACtC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACvD,MAAM,gBAAgB,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAErD,sFAAsF;IACtF,IAAI,iBAAiB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7B,IAAI,gBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC;YAC5B,OAAO,eAAe,CAAC,WAAW,EAAE,KAAK,gBAAgB,CAAC,WAAW,EAAE,CAAA;QACzE,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,oDAAoD;IACpD,IAAI,gBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;IACvE,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAA;IACvE,MAAM,aAAa,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAA;IACpE,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAA;IAEpE,sEAAsE;IACtE,IAAI,cAAc,CAAC,WAAW,EAAE,KAAK,aAAa,CAAC,WAAW,EAAE,EAAE,CAAC;QACjE,OAAO,KAAK,CAAA;IACd,CAAC;IAED,uCAAuC;IACvC,MAAM,KAAK,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAA;IACnD,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AACjC,CAAC;AAED;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,YAAoB;IAClD,MAAM,OAAO,GAAG,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,GAAG,CAAA;IAClF,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED;;;;;GAKG;AACH,SAAS,yBAAyB,CAAC,GAAW;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACzD,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface ArnParts {
|
|
2
|
+
/**
|
|
3
|
+
* The partition of the ARN such as aws, aws-cn, aws-us-gov
|
|
4
|
+
*/
|
|
5
|
+
partition: string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The service of the ARN such as s3, ec2, iam
|
|
8
|
+
*/
|
|
9
|
+
service: string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The region of the ARN such as us-east-1, us-west-2
|
|
12
|
+
*/
|
|
13
|
+
region: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The account ID of the ARN
|
|
16
|
+
*/
|
|
17
|
+
accountId: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The resource portion of the ARN, includes the resource type, path and name
|
|
20
|
+
*/
|
|
21
|
+
resource: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The resource type of the ARN, such as instance, user, topic, may be undefined for
|
|
24
|
+
* some S3 buckets.
|
|
25
|
+
*/
|
|
26
|
+
resourceType: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The resource path and name of the ARN, such as Development/user1, or MyTopic or my-bucket/my-object.txt
|
|
29
|
+
*/
|
|
30
|
+
resourcePath: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Split an ARN into its parts
|
|
34
|
+
*
|
|
35
|
+
* @param arn the arn to split
|
|
36
|
+
* @returns the parts of the ARN
|
|
37
|
+
*/
|
|
38
|
+
export declare function splitArnParts(arn: string): ArnParts;
|
|
39
|
+
/**
|
|
40
|
+
* Get the product/id segments of the resource portion of an ARN.
|
|
41
|
+
* The first segment is the product segment and the second segment is the resource id segment.
|
|
42
|
+
* This could be split by a colon or a slash, so it checks for both. It also checks for S3 buckets/objects.
|
|
43
|
+
*
|
|
44
|
+
* @param resource The resource to get the resource segments. Must be an ARN resource.
|
|
45
|
+
* @returns a tuple with the first segment being the product segment (without the separator) and the second segment being the resource id.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getResourceSegments(service: string, accountId: string, region: string, resourceString: string): [string, string];
|
|
48
|
+
//# sourceMappingURL=arn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arn.d.ts","sourceRoot":"","sources":["../../src/arn.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAE7B;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAE3B;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAE1B;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAE7B;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAE5B;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAEhC;;OAEG;IACH,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAkBnD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB,CAAC,MAAM,EAAE,MAAM,CAAC,CA+BlB"}
|
package/dist/cjs/arn.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitArnParts = splitArnParts;
|
|
4
|
+
exports.getResourceSegments = getResourceSegments;
|
|
5
|
+
/**
|
|
6
|
+
* Split an ARN into its parts
|
|
7
|
+
*
|
|
8
|
+
* @param arn the arn to split
|
|
9
|
+
* @returns the parts of the ARN
|
|
10
|
+
*/
|
|
11
|
+
function splitArnParts(arn) {
|
|
12
|
+
const parts = arn.split(':');
|
|
13
|
+
const partition = parts.at(1);
|
|
14
|
+
const service = parts.at(2);
|
|
15
|
+
const region = parts.at(3);
|
|
16
|
+
const accountId = parts.at(4);
|
|
17
|
+
const resource = parts.slice(5).join(':');
|
|
18
|
+
const [resourceType, resourcePath] = getResourceSegments(service, accountId, region, resource);
|
|
19
|
+
return {
|
|
20
|
+
partition,
|
|
21
|
+
service,
|
|
22
|
+
region,
|
|
23
|
+
accountId,
|
|
24
|
+
resource,
|
|
25
|
+
resourceType,
|
|
26
|
+
resourcePath
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the product/id segments of the resource portion of an ARN.
|
|
31
|
+
* The first segment is the product segment and the second segment is the resource id segment.
|
|
32
|
+
* This could be split by a colon or a slash, so it checks for both. It also checks for S3 buckets/objects.
|
|
33
|
+
*
|
|
34
|
+
* @param resource The resource to get the resource segments. Must be an ARN resource.
|
|
35
|
+
* @returns a tuple with the first segment being the product segment (without the separator) and the second segment being the resource id.
|
|
36
|
+
*/
|
|
37
|
+
function getResourceSegments(service, accountId, region, resourceString) {
|
|
38
|
+
// This is terrible, and I hate it
|
|
39
|
+
if ((service === 's3' && accountId === '' && region === '') ||
|
|
40
|
+
service === 'sns' ||
|
|
41
|
+
service === 'sqs') {
|
|
42
|
+
return ['', resourceString];
|
|
43
|
+
}
|
|
44
|
+
if (resourceString.startsWith('/')) {
|
|
45
|
+
resourceString = resourceString.slice(1);
|
|
46
|
+
}
|
|
47
|
+
const slashIndex = resourceString.indexOf('/');
|
|
48
|
+
const colonIndex = resourceString.indexOf(':');
|
|
49
|
+
let splitIndex = slashIndex;
|
|
50
|
+
if (slashIndex != -1 && colonIndex != -1) {
|
|
51
|
+
splitIndex = Math.min(slashIndex, colonIndex) + 1;
|
|
52
|
+
}
|
|
53
|
+
else if (slashIndex == -1 && colonIndex == -1) {
|
|
54
|
+
splitIndex = resourceString.length + 1;
|
|
55
|
+
}
|
|
56
|
+
else if (colonIndex == -1) {
|
|
57
|
+
splitIndex = slashIndex + 1;
|
|
58
|
+
}
|
|
59
|
+
else if (slashIndex == -1) {
|
|
60
|
+
splitIndex = colonIndex + 1;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error(`Unable to split resource ${resourceString}`);
|
|
64
|
+
}
|
|
65
|
+
return [resourceString.slice(0, splitIndex - 1), resourceString.slice(splitIndex)];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=arn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arn.js","sourceRoot":"","sources":["../../src/arn.ts"],"names":[],"mappings":";;AA4CA,sCAkBC;AAUD,kDAoCC;AAtED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAA;IAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAA;IAC3B,MAAM,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAA;IAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IAE9F,OAAO;QACL,SAAS;QACT,OAAO;QACP,MAAM;QACN,SAAS;QACT,QAAQ;QACR,YAAY;QACZ,YAAY;KACb,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,OAAe,EACf,SAAiB,EACjB,MAAc,EACd,cAAsB;IAEtB,kCAAkC;IAClC,IACE,CAAC,OAAO,KAAK,IAAI,IAAI,SAAS,KAAK,EAAE,IAAI,MAAM,KAAK,EAAE,CAAC;QACvD,OAAO,KAAK,KAAK;QACjB,OAAO,KAAK,KAAK,EACjB,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,CAAA;IAC7B,CAAC;IAED,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9C,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAE9C,IAAI,UAAU,GAAG,UAAU,CAAA;IAC3B,IAAI,UAAU,IAAI,CAAC,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC;QACzC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;IACnD,CAAC;SAAM,IAAI,UAAU,IAAI,CAAC,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC;QAChD,UAAU,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,CAAA;IACxC,CAAC;SAAM,IAAI,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC;QAC5B,UAAU,GAAG,UAAU,GAAG,CAAC,CAAA;IAC7B,CAAC;SAAM,IAAI,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC;QAC5B,UAAU,GAAG,UAAU,GAAG,CAAC,CAAA;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,4BAA4B,cAAc,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA;AACpF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { actionMatchesPattern } from './actions.js';
|
|
2
|
+
export { getResourceSegments, splitArnParts, type ArnParts } from './arn.js';
|
|
3
|
+
export { convertAssumedRoleArnToRoleArn, convertRoleArnToAssumedRoleArn, isArnPrincipal, isAssumedRoleArn, isFederatedUserArn, isIamRoleArn, isIamUserArn, isServicePrincipal } from './principals.js';
|
|
4
|
+
export { convertResourcePatternToRegex } from './resourcePatterns.js';
|
|
5
|
+
export { resourceArnWithWildcardsToRegex } from './resources.js';
|
|
6
|
+
export { mostSpecificMatchingResourceTypePatterns, resourceStringMatchesResourceTypePattern } from './resourceTypes.js';
|
|
7
|
+
export { actionSupportsAwsResourceInfoContextKeys, isAwsResourceInfoExcludedAction } from './resourceInfoContextKeys.js';
|
|
8
|
+
export { bucketArn, isS3BucketOrObjectArn } from './s3.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EACL,wCAAwC,EACxC,wCAAwC,EACzC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,wCAAwC,EACxC,+BAA+B,EAChC,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isS3BucketOrObjectArn = exports.bucketArn = exports.isAwsResourceInfoExcludedAction = exports.actionSupportsAwsResourceInfoContextKeys = exports.resourceStringMatchesResourceTypePattern = exports.mostSpecificMatchingResourceTypePatterns = exports.resourceArnWithWildcardsToRegex = exports.convertResourcePatternToRegex = exports.isServicePrincipal = exports.isIamUserArn = exports.isIamRoleArn = exports.isFederatedUserArn = exports.isAssumedRoleArn = exports.isArnPrincipal = exports.convertRoleArnToAssumedRoleArn = exports.convertAssumedRoleArnToRoleArn = exports.splitArnParts = exports.getResourceSegments = exports.actionMatchesPattern = void 0;
|
|
4
|
+
var actions_js_1 = require("./actions.js");
|
|
5
|
+
Object.defineProperty(exports, "actionMatchesPattern", { enumerable: true, get: function () { return actions_js_1.actionMatchesPattern; } });
|
|
6
|
+
var arn_js_1 = require("./arn.js");
|
|
7
|
+
Object.defineProperty(exports, "getResourceSegments", { enumerable: true, get: function () { return arn_js_1.getResourceSegments; } });
|
|
8
|
+
Object.defineProperty(exports, "splitArnParts", { enumerable: true, get: function () { return arn_js_1.splitArnParts; } });
|
|
9
|
+
var principals_js_1 = require("./principals.js");
|
|
10
|
+
Object.defineProperty(exports, "convertAssumedRoleArnToRoleArn", { enumerable: true, get: function () { return principals_js_1.convertAssumedRoleArnToRoleArn; } });
|
|
11
|
+
Object.defineProperty(exports, "convertRoleArnToAssumedRoleArn", { enumerable: true, get: function () { return principals_js_1.convertRoleArnToAssumedRoleArn; } });
|
|
12
|
+
Object.defineProperty(exports, "isArnPrincipal", { enumerable: true, get: function () { return principals_js_1.isArnPrincipal; } });
|
|
13
|
+
Object.defineProperty(exports, "isAssumedRoleArn", { enumerable: true, get: function () { return principals_js_1.isAssumedRoleArn; } });
|
|
14
|
+
Object.defineProperty(exports, "isFederatedUserArn", { enumerable: true, get: function () { return principals_js_1.isFederatedUserArn; } });
|
|
15
|
+
Object.defineProperty(exports, "isIamRoleArn", { enumerable: true, get: function () { return principals_js_1.isIamRoleArn; } });
|
|
16
|
+
Object.defineProperty(exports, "isIamUserArn", { enumerable: true, get: function () { return principals_js_1.isIamUserArn; } });
|
|
17
|
+
Object.defineProperty(exports, "isServicePrincipal", { enumerable: true, get: function () { return principals_js_1.isServicePrincipal; } });
|
|
18
|
+
var resourcePatterns_js_1 = require("./resourcePatterns.js");
|
|
19
|
+
Object.defineProperty(exports, "convertResourcePatternToRegex", { enumerable: true, get: function () { return resourcePatterns_js_1.convertResourcePatternToRegex; } });
|
|
20
|
+
var resources_js_1 = require("./resources.js");
|
|
21
|
+
Object.defineProperty(exports, "resourceArnWithWildcardsToRegex", { enumerable: true, get: function () { return resources_js_1.resourceArnWithWildcardsToRegex; } });
|
|
22
|
+
var resourceTypes_js_1 = require("./resourceTypes.js");
|
|
23
|
+
Object.defineProperty(exports, "mostSpecificMatchingResourceTypePatterns", { enumerable: true, get: function () { return resourceTypes_js_1.mostSpecificMatchingResourceTypePatterns; } });
|
|
24
|
+
Object.defineProperty(exports, "resourceStringMatchesResourceTypePattern", { enumerable: true, get: function () { return resourceTypes_js_1.resourceStringMatchesResourceTypePattern; } });
|
|
25
|
+
var resourceInfoContextKeys_js_1 = require("./resourceInfoContextKeys.js");
|
|
26
|
+
Object.defineProperty(exports, "actionSupportsAwsResourceInfoContextKeys", { enumerable: true, get: function () { return resourceInfoContextKeys_js_1.actionSupportsAwsResourceInfoContextKeys; } });
|
|
27
|
+
Object.defineProperty(exports, "isAwsResourceInfoExcludedAction", { enumerable: true, get: function () { return resourceInfoContextKeys_js_1.isAwsResourceInfoExcludedAction; } });
|
|
28
|
+
var s3_js_1 = require("./s3.js");
|
|
29
|
+
Object.defineProperty(exports, "bucketArn", { enumerable: true, get: function () { return s3_js_1.bucketArn; } });
|
|
30
|
+
Object.defineProperty(exports, "isS3BucketOrObjectArn", { enumerable: true, get: function () { return s3_js_1.isS3BucketOrObjectArn; } });
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAAmD;AAA1C,kHAAA,oBAAoB,OAAA;AAC7B,mCAA4E;AAAnE,6GAAA,mBAAmB,OAAA;AAAE,uGAAA,aAAa,OAAA;AAC3C,iDASwB;AARtB,+HAAA,8BAA8B,OAAA;AAC9B,+HAAA,8BAA8B,OAAA;AAC9B,+GAAA,cAAc,OAAA;AACd,iHAAA,gBAAgB,OAAA;AAChB,mHAAA,kBAAkB,OAAA;AAClB,6GAAA,YAAY,OAAA;AACZ,6GAAA,YAAY,OAAA;AACZ,mHAAA,kBAAkB,OAAA;AAEpB,6DAAqE;AAA5D,oIAAA,6BAA6B,OAAA;AACtC,+CAAgE;AAAvD,+HAAA,+BAA+B,OAAA;AACxC,uDAG2B;AAFzB,4IAAA,wCAAwC,OAAA;AACxC,4IAAA,wCAAwC,OAAA;AAE1C,2EAGqC;AAFnC,sJAAA,wCAAwC,OAAA;AACxC,6IAAA,+BAA+B,OAAA;AAEjC,iCAA0D;AAAjD,kGAAA,SAAS,OAAA;AAAE,8GAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform an assumed role session ARN into a role ARN
|
|
3
|
+
*
|
|
4
|
+
* @param assumedRoleArn the assumed role session ARN
|
|
5
|
+
* @returns the role ARN for the assumed role session
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertAssumedRoleArnToRoleArn(assumedRoleArn: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Create an assumed role ARN from a role ARN and a session name
|
|
10
|
+
*
|
|
11
|
+
* @param roleArn the role ARN to create an assumed role ARN from
|
|
12
|
+
* @param sessionName the session name to use
|
|
13
|
+
* @returns the assumed role ARN
|
|
14
|
+
*/
|
|
15
|
+
export declare function convertRoleArnToAssumedRoleArn(roleArn: string, sessionName: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Tests if a principal string is an assumed role ARN
|
|
18
|
+
*
|
|
19
|
+
* @param principal the principal string to test
|
|
20
|
+
* @returns true if the principal is an assumed role ARN, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
export declare function isAssumedRoleArn(principal: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Test if a principal string is an IAM user ARN
|
|
25
|
+
*
|
|
26
|
+
* @param principal the principal string to test
|
|
27
|
+
* @returns true if the principal is an IAM user ARN, false otherwise
|
|
28
|
+
*/
|
|
29
|
+
export declare function isIamUserArn(principal: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Test if a principal string is an IAM Role ARN
|
|
32
|
+
*
|
|
33
|
+
* @param principal the principal string to test
|
|
34
|
+
* @returns true if the principal is an IAM role ARN, false otherwise
|
|
35
|
+
*/
|
|
36
|
+
export declare function isIamRoleArn(principal: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Test if a principal string is a federated user ARN
|
|
39
|
+
*
|
|
40
|
+
* @param principal the principal string to test
|
|
41
|
+
* @returns true if the principal is a federated user ARN, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
export declare function isFederatedUserArn(principal: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Test if a principal string is an ARN
|
|
46
|
+
*
|
|
47
|
+
* @param principal the principal string to test
|
|
48
|
+
* @returns true if the principal is an ARN, false otherwise
|
|
49
|
+
*/
|
|
50
|
+
export declare function isArnPrincipal(principal: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Test if a principal string is a service principal
|
|
53
|
+
*
|
|
54
|
+
* @param principal the principal string to test
|
|
55
|
+
* @returns true if the principal is a service principal, false otherwise
|
|
56
|
+
*/
|
|
57
|
+
export declare function isServicePrincipal(principal: string): boolean;
|
|
58
|
+
//# sourceMappingURL=principals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principals.d.ts","sourceRoot":"","sources":["../../src/principals.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAI7E;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAI3F;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D;AAID;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEvD;AAID;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEvD;AAID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertAssumedRoleArnToRoleArn = convertAssumedRoleArnToRoleArn;
|
|
4
|
+
exports.convertRoleArnToAssumedRoleArn = convertRoleArnToAssumedRoleArn;
|
|
5
|
+
exports.isAssumedRoleArn = isAssumedRoleArn;
|
|
6
|
+
exports.isIamUserArn = isIamUserArn;
|
|
7
|
+
exports.isIamRoleArn = isIamRoleArn;
|
|
8
|
+
exports.isFederatedUserArn = isFederatedUserArn;
|
|
9
|
+
exports.isArnPrincipal = isArnPrincipal;
|
|
10
|
+
exports.isServicePrincipal = isServicePrincipal;
|
|
11
|
+
const arn_js_1 = require("./arn.js");
|
|
12
|
+
/**
|
|
13
|
+
* Transform an assumed role session ARN into a role ARN
|
|
14
|
+
*
|
|
15
|
+
* @param assumedRoleArn the assumed role session ARN
|
|
16
|
+
* @returns the role ARN for the assumed role session
|
|
17
|
+
*/
|
|
18
|
+
function convertAssumedRoleArnToRoleArn(assumedRoleArn) {
|
|
19
|
+
const arnParts = (0, arn_js_1.splitArnParts)(assumedRoleArn);
|
|
20
|
+
const rolePathAndName = arnParts.resourcePath?.split('/').slice(0, -1).join('/');
|
|
21
|
+
return `arn:${arnParts.partition}:iam::${arnParts.accountId}:role/${rolePathAndName}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create an assumed role ARN from a role ARN and a session name
|
|
25
|
+
*
|
|
26
|
+
* @param roleArn the role ARN to create an assumed role ARN from
|
|
27
|
+
* @param sessionName the session name to use
|
|
28
|
+
* @returns the assumed role ARN
|
|
29
|
+
*/
|
|
30
|
+
function convertRoleArnToAssumedRoleArn(roleArn, sessionName) {
|
|
31
|
+
const arnParts = (0, arn_js_1.splitArnParts)(roleArn);
|
|
32
|
+
const rolePathAndName = arnParts.resourcePath;
|
|
33
|
+
return `arn:${arnParts.partition}:sts::${arnParts.accountId}:assumed-role/${rolePathAndName}/${sessionName}`;
|
|
34
|
+
}
|
|
35
|
+
const assumedRoleArnRegex = /^arn:[a-zA-Z\-]+:sts::\d{12}:assumed-role\/.*$/;
|
|
36
|
+
/**
|
|
37
|
+
* Tests if a principal string is an assumed role ARN
|
|
38
|
+
*
|
|
39
|
+
* @param principal the principal string to test
|
|
40
|
+
* @returns true if the principal is an assumed role ARN, false otherwise
|
|
41
|
+
*/
|
|
42
|
+
function isAssumedRoleArn(principal) {
|
|
43
|
+
return assumedRoleArnRegex.test(principal);
|
|
44
|
+
}
|
|
45
|
+
const userArnRegex = /^arn:[a-zA-Z\-]+:iam::\d{12}:user\/.*$/;
|
|
46
|
+
/**
|
|
47
|
+
* Test if a principal string is an IAM user ARN
|
|
48
|
+
*
|
|
49
|
+
* @param principal the principal string to test
|
|
50
|
+
* @returns true if the principal is an IAM user ARN, false otherwise
|
|
51
|
+
*/
|
|
52
|
+
function isIamUserArn(principal) {
|
|
53
|
+
return userArnRegex.test(principal);
|
|
54
|
+
}
|
|
55
|
+
const iamRoleArnRegex = /^arn:[a-zA-Z\-]+:iam::\d{12}:role\/.*$/;
|
|
56
|
+
/**
|
|
57
|
+
* Test if a principal string is an IAM Role ARN
|
|
58
|
+
*
|
|
59
|
+
* @param principal the principal string to test
|
|
60
|
+
* @returns true if the principal is an IAM role ARN, false otherwise
|
|
61
|
+
*/
|
|
62
|
+
function isIamRoleArn(principal) {
|
|
63
|
+
return iamRoleArnRegex.test(principal);
|
|
64
|
+
}
|
|
65
|
+
const federatedUserArnRegex = /^arn:[a-zA-Z\-]+:sts::\d{12}:federated-user\/.*$/;
|
|
66
|
+
/**
|
|
67
|
+
* Test if a principal string is a federated user ARN
|
|
68
|
+
*
|
|
69
|
+
* @param principal the principal string to test
|
|
70
|
+
* @returns true if the principal is a federated user ARN, false otherwise
|
|
71
|
+
*/
|
|
72
|
+
function isFederatedUserArn(principal) {
|
|
73
|
+
return federatedUserArnRegex.test(principal);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Test if a principal string is an ARN
|
|
77
|
+
*
|
|
78
|
+
* @param principal the principal string to test
|
|
79
|
+
* @returns true if the principal is an ARN, false otherwise
|
|
80
|
+
*/
|
|
81
|
+
function isArnPrincipal(principal) {
|
|
82
|
+
return principal.startsWith('arn:');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Test if a principal string is a service principal
|
|
86
|
+
*
|
|
87
|
+
* @param principal the principal string to test
|
|
88
|
+
* @returns true if the principal is a service principal, false otherwise
|
|
89
|
+
*/
|
|
90
|
+
function isServicePrincipal(principal) {
|
|
91
|
+
return !isArnPrincipal(principal) && principal.endsWith('amazonaws.com');
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=principals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principals.js","sourceRoot":"","sources":["../../src/principals.ts"],"names":[],"mappings":";;AAQA,wEAIC;AASD,wEAIC;AAUD,4CAEC;AAUD,oCAEC;AAUD,oCAEC;AAUD,gDAEC;AAQD,wCAEC;AAQD,gDAEC;AA7FD,qCAAwC;AAExC;;;;;GAKG;AACH,SAAgB,8BAA8B,CAAC,cAAsB;IACnE,MAAM,QAAQ,GAAG,IAAA,sBAAa,EAAC,cAAc,CAAC,CAAA;IAC9C,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAChF,OAAO,OAAO,QAAQ,CAAC,SAAS,SAAS,QAAQ,CAAC,SAAS,SAAS,eAAe,EAAE,CAAA;AACvF,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,8BAA8B,CAAC,OAAe,EAAE,WAAmB;IACjF,MAAM,QAAQ,GAAG,IAAA,sBAAa,EAAC,OAAO,CAAC,CAAA;IACvC,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAA;IAC7C,OAAO,OAAO,QAAQ,CAAC,SAAS,SAAS,QAAQ,CAAC,SAAS,iBAAiB,eAAe,IAAI,WAAW,EAAE,CAAA;AAC9G,CAAC;AAED,MAAM,mBAAmB,GAAG,gDAAgD,CAAA;AAE5E;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,YAAY,GAAG,wCAAwC,CAAA;AAE7D;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,SAAiB;IAC5C,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACrC,CAAC;AAED,MAAM,eAAe,GAAG,wCAAwC,CAAA;AAEhE;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,SAAiB;IAC5C,OAAO,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACxC,CAAC;AAED,MAAM,qBAAqB,GAAG,kDAAkD,CAAA;AAEhF;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAC9C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,SAAiB;IAC9C,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;AAC1E,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether an IAM action is excluded from AWS resource-information context keys.
|
|
3
|
+
*
|
|
4
|
+
* AWS does not populate `aws:ResourceAccount`, `aws:ResourceOrgID`, or
|
|
5
|
+
* `aws:ResourceOrgPaths` for every action. This predicate captures the documented
|
|
6
|
+
* excluded actions currently used by Cloud Copilot request-context generation.
|
|
7
|
+
*
|
|
8
|
+
* @param action - IAM action to inspect, such as `s3:GetObject`.
|
|
9
|
+
* @returns True when AWS resource-information context keys are not available.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isAwsResourceInfoExcludedAction(action: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Checks whether AWS resource-information context keys are available for an IAM action.
|
|
14
|
+
*
|
|
15
|
+
* @param action - IAM action to inspect, such as `s3:GetObject`.
|
|
16
|
+
* @returns True when `aws:ResourceAccount`, `aws:ResourceOrgID`, and `aws:ResourceOrgPaths` may be populated.
|
|
17
|
+
*/
|
|
18
|
+
export declare function actionSupportsAwsResourceInfoContextKeys(action: string): boolean;
|
|
19
|
+
//# sourceMappingURL=resourceInfoContextKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceInfoContextKeys.d.ts","sourceRoot":"","sources":["../../src/resourceInfoContextKeys.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGvE;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAwsResourceInfoExcludedAction = isAwsResourceInfoExcludedAction;
|
|
4
|
+
exports.actionSupportsAwsResourceInfoContextKeys = actionSupportsAwsResourceInfoContextKeys;
|
|
5
|
+
const awsResourceInfoExcludedActions = new Set([
|
|
6
|
+
'auditmanager:updateassessmentframeworkshare',
|
|
7
|
+
'detective:acceptinvitation',
|
|
8
|
+
'ds:acceptshareddirectory',
|
|
9
|
+
'ec2:accepttransitgatewaypeeringattachment',
|
|
10
|
+
'ec2:acceptvpcendpointconnections',
|
|
11
|
+
'ec2:acceptvpcpeeringconnection',
|
|
12
|
+
'ec2:copysnapshot',
|
|
13
|
+
'ec2:createtransitgatewaypeeringattachment',
|
|
14
|
+
'ec2:createvpcendpoint',
|
|
15
|
+
'ec2:createvpcpeeringconnection',
|
|
16
|
+
'ec2:deletetransitgatewaypeeringattachment',
|
|
17
|
+
'ec2:deletevpcpeeringconnection',
|
|
18
|
+
'ec2:rejecttransitgatewaypeeringattachment',
|
|
19
|
+
'ec2:rejectvpcendpointconnections',
|
|
20
|
+
'ec2:rejectvpcpeeringconnection',
|
|
21
|
+
'guardduty:acceptadministratorinvitation',
|
|
22
|
+
'macie2:acceptinvitation',
|
|
23
|
+
'es:acceptinboundconnection',
|
|
24
|
+
'route53:associatevpcwithhostedzone',
|
|
25
|
+
'route53:createvpcassociationauthorization',
|
|
26
|
+
'route53:deletevpcassociationauthorization',
|
|
27
|
+
'route53:disassociatevpcfromhostedzone',
|
|
28
|
+
'route53:listhostedzonesbyvpc',
|
|
29
|
+
'securityhub:acceptadministratorinvitation'
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether an IAM action is excluded from AWS resource-information context keys.
|
|
33
|
+
*
|
|
34
|
+
* AWS does not populate `aws:ResourceAccount`, `aws:ResourceOrgID`, or
|
|
35
|
+
* `aws:ResourceOrgPaths` for every action. This predicate captures the documented
|
|
36
|
+
* excluded actions currently used by Cloud Copilot request-context generation.
|
|
37
|
+
*
|
|
38
|
+
* @param action - IAM action to inspect, such as `s3:GetObject`.
|
|
39
|
+
* @returns True when AWS resource-information context keys are not available.
|
|
40
|
+
*/
|
|
41
|
+
function isAwsResourceInfoExcludedAction(action) {
|
|
42
|
+
const lowerCaseAction = action.toLowerCase();
|
|
43
|
+
return lowerCaseAction.startsWith('ebs:') || awsResourceInfoExcludedActions.has(lowerCaseAction);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether AWS resource-information context keys are available for an IAM action.
|
|
47
|
+
*
|
|
48
|
+
* @param action - IAM action to inspect, such as `s3:GetObject`.
|
|
49
|
+
* @returns True when `aws:ResourceAccount`, `aws:ResourceOrgID`, and `aws:ResourceOrgPaths` may be populated.
|
|
50
|
+
*/
|
|
51
|
+
function actionSupportsAwsResourceInfoContextKeys(action) {
|
|
52
|
+
return !isAwsResourceInfoExcludedAction(action);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=resourceInfoContextKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceInfoContextKeys.js","sourceRoot":"","sources":["../../src/resourceInfoContextKeys.ts"],"names":[],"mappings":";;AAqCA,0EAGC;AAQD,4FAEC;AAlDD,MAAM,8BAA8B,GAAG,IAAI,GAAG,CAAC;IAC7C,6CAA6C;IAC7C,4BAA4B;IAC5B,0BAA0B;IAC1B,2CAA2C;IAC3C,kCAAkC;IAClC,gCAAgC;IAChC,kBAAkB;IAClB,2CAA2C;IAC3C,uBAAuB;IACvB,gCAAgC;IAChC,2CAA2C;IAC3C,gCAAgC;IAChC,2CAA2C;IAC3C,kCAAkC;IAClC,gCAAgC;IAChC,yCAAyC;IACzC,yBAAyB;IACzB,4BAA4B;IAC5B,oCAAoC;IACpC,2CAA2C;IAC3C,2CAA2C;IAC3C,uCAAuC;IACvC,8BAA8B;IAC9B,2CAA2C;CAC5C,CAAC,CAAA;AAEF;;;;;;;;;GASG;AACH,SAAgB,+BAA+B,CAAC,MAAc;IAC5D,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IAC5C,OAAO,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,8BAA8B,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAClG,CAAC;AAED;;;;;GAKG;AACH,SAAgB,wCAAwC,CAAC,MAAc;IACrE,OAAO,CAAC,+BAA+B,CAAC,MAAM,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a resource pattern from iam-data to a regex pattern.
|
|
3
|
+
* Variables like `${BucketName}` become named capture groups.
|
|
4
|
+
*
|
|
5
|
+
* @param pattern - The IAM resource type ARN pattern (e.g. `arn:${Partition}:s3:::${BucketName}/${ObjectName}`)
|
|
6
|
+
* @returns A regex string anchored with `^...$` that matches concrete ARNs against the pattern
|
|
7
|
+
*/
|
|
8
|
+
export declare function convertResourcePatternToRegex(pattern: string): string;
|
|
9
|
+
//# sourceMappingURL=resourcePatterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourcePatterns.d.ts","sourceRoot":"","sources":["../../src/resourcePatterns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertResourcePatternToRegex = convertResourcePatternToRegex;
|
|
4
|
+
/**
|
|
5
|
+
* Convert a resource pattern from iam-data to a regex pattern.
|
|
6
|
+
* Variables like `${BucketName}` become named capture groups.
|
|
7
|
+
*
|
|
8
|
+
* @param pattern - The IAM resource type ARN pattern (e.g. `arn:${Partition}:s3:::${BucketName}/${ObjectName}`)
|
|
9
|
+
* @returns A regex string anchored with `^...$` that matches concrete ARNs against the pattern
|
|
10
|
+
*/
|
|
11
|
+
function convertResourcePatternToRegex(pattern) {
|
|
12
|
+
const regex = pattern.replace(/\$\{.*?\}/g, (match) => {
|
|
13
|
+
const name = match.substring(2, match.length - 1);
|
|
14
|
+
const camelName = name.at(0)?.toLowerCase() + name.substring(1);
|
|
15
|
+
return `(?<${camelName}>(.+?))`;
|
|
16
|
+
});
|
|
17
|
+
return `^${regex}$`;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=resourcePatterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourcePatterns.js","sourceRoot":"","sources":["../../src/resourcePatterns.ts"],"names":[],"mappings":";;AAOA,sEAOC;AAdD;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAAC,OAAe;IAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;QACpD,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACjD,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAC/D,OAAO,MAAM,SAAS,SAAS,CAAA;IACjC,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,KAAK,GAAG,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a concrete resource ARN (possibly with wildcards) matches
|
|
3
|
+
* a resource-type ARN pattern from the Service Authorization Reference.
|
|
4
|
+
*
|
|
5
|
+
* A wildcard resource string (`"*"`) always matches.
|
|
6
|
+
*
|
|
7
|
+
* This is a compatibility check: it returns true when there is at least one
|
|
8
|
+
* concrete ARN that could satisfy both the resource string and the resource
|
|
9
|
+
* type pattern. Resource type variables may span resource-component separators
|
|
10
|
+
* such as `:` and `/`.
|
|
11
|
+
*
|
|
12
|
+
* @param resourceString - A concrete resource ARN or wildcard (`"*"`)
|
|
13
|
+
* @param resourcePattern - An ARN pattern from iam-data (e.g. `arn:${Partition}:s3:::${BucketName}/${ObjectName}`)
|
|
14
|
+
* @returns Whether the resource string matches the pattern
|
|
15
|
+
*/
|
|
16
|
+
export declare function resourceStringMatchesResourceTypePattern(resourceString: string, resourcePattern: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Reduce resource type patterns to the most specific patterns that match a resource string.
|
|
19
|
+
*
|
|
20
|
+
* This helper does not know about iam-data or service-specific resource type ordering. It uses
|
|
21
|
+
* the provided pattern set as context and removes matching parent patterns when a matching child
|
|
22
|
+
* pattern has all of the parent's literal structure plus additional literal structure. Wildcard
|
|
23
|
+
* resource strings preserve all matches because the wildcard may refer to parent and child resources.
|
|
24
|
+
*
|
|
25
|
+
* @param resourceString - A concrete resource ARN or wildcard (`"*"`)
|
|
26
|
+
* @param resourcePatterns - Candidate resource type ARN patterns
|
|
27
|
+
* @returns Matching resource type patterns with less-specific parent patterns removed, in input order
|
|
28
|
+
*/
|
|
29
|
+
export declare function mostSpecificMatchingResourceTypePatterns(resourceString: string, resourcePatterns: string[]): string[];
|
|
30
|
+
//# sourceMappingURL=resourceTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceTypes.d.ts","sourceRoot":"","sources":["../../src/resourceTypes.ts"],"names":[],"mappings":"AAsCA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wCAAwC,CACtD,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAgCT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wCAAwC,CACtD,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,EAAE,GACzB,MAAM,EAAE,CAiBV"}
|