@cloud-copilot/iam-expand 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/cjs/stdin.d.ts.map +1 -1
- package/dist/cjs/stdin.js +3 -1
- package/dist/cjs/stdin.js.map +1 -1
- package/dist/esm/stdin.d.ts.map +1 -1
- package/dist/esm/stdin.js +3 -1
- package/dist/esm/stdin.js.map +1 -1
- package/package.json +4 -3
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -67
- package/dist/cli.js.map +0 -1
- package/dist/cli_utils.d.ts +0 -27
- package/dist/cli_utils.d.ts.map +0 -1
- package/dist/cli_utils.js +0 -57
- package/dist/cli_utils.js.map +0 -1
- package/dist/cli_utils.test.d.ts +0 -2
- package/dist/cli_utils.test.d.ts.map +0 -1
- package/dist/cli_utils.test.js +0 -90
- package/dist/cli_utils.test.js.map +0 -1
- package/dist/expand.d.ts +0 -55
- package/dist/expand.d.ts.map +0 -1
- package/dist/expand.js +0 -94
- package/dist/expand.js.map +0 -1
- package/dist/expand.test.d.ts +0 -2
- package/dist/expand.test.d.ts.map +0 -1
- package/dist/expand.test.js +0 -382
- package/dist/expand.test.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
- package/dist/stdin.d.ts +0 -7
- package/dist/stdin.d.ts.map +0 -1
- package/dist/stdin.js +0 -35
- package/dist/stdin.js.map +0 -1
package/README.md
CHANGED
|
@@ -18,6 +18,9 @@ All information is sourced from [@cloud-copilot/iam-data](https://github.com/clo
|
|
|
18
18
|
## Only Valid Values
|
|
19
19
|
`iam-expand` intends to only return valid, actual actions, if any invalid values are passed in such as an invalid format or a service/action that does not exist, they will be left out of the output. There are options to override this behavior.
|
|
20
20
|
|
|
21
|
+
## Use In Browser
|
|
22
|
+
[http://iam.cloudcopilot.io/tools/iam-expand](http://iam.cloudcopilot.io/tools/iam-expand)
|
|
23
|
+
|
|
21
24
|
## CLI
|
|
22
25
|
There is a CLI! The [examples folder](examples/README.md) has examples showing how to use the CLI to find interesting actions in your IAM policies.
|
|
23
26
|
|
package/dist/cjs/stdin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../../src/stdin.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../../src/stdin.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CA6B7E"}
|
package/dist/cjs/stdin.js
CHANGED
|
@@ -15,7 +15,7 @@ async function readStdin(readWait) {
|
|
|
15
15
|
readWait = definitelyReceivingData ? 10_000 : 20;
|
|
16
16
|
}
|
|
17
17
|
let data = '';
|
|
18
|
-
setTimeout(() => {
|
|
18
|
+
const timeout = setTimeout(() => {
|
|
19
19
|
if (data.length === 0) {
|
|
20
20
|
resolve(data);
|
|
21
21
|
}
|
|
@@ -25,9 +25,11 @@ async function readStdin(readWait) {
|
|
|
25
25
|
});
|
|
26
26
|
process_1.stdin.on('end', () => {
|
|
27
27
|
resolve(data);
|
|
28
|
+
clearTimeout(timeout);
|
|
28
29
|
});
|
|
29
30
|
process_1.stdin.on('error', (err) => {
|
|
30
31
|
reject(err);
|
|
32
|
+
clearTimeout(timeout);
|
|
31
33
|
});
|
|
32
34
|
});
|
|
33
35
|
}
|
package/dist/cjs/stdin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdin.js","sourceRoot":"","sources":["../../src/stdin.ts"],"names":[],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|
-
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../../src/stdin.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../../src/stdin.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CA6B7E"}
|
package/dist/esm/stdin.js
CHANGED
|
@@ -12,7 +12,7 @@ export async function readStdin(readWait) {
|
|
|
12
12
|
readWait = definitelyReceivingData ? 10000 : 20;
|
|
13
13
|
}
|
|
14
14
|
let data = '';
|
|
15
|
-
setTimeout(() => {
|
|
15
|
+
const timeout = setTimeout(() => {
|
|
16
16
|
if (data.length === 0) {
|
|
17
17
|
resolve(data);
|
|
18
18
|
}
|
|
@@ -22,9 +22,11 @@ export async function readStdin(readWait) {
|
|
|
22
22
|
});
|
|
23
23
|
stdin.on('end', () => {
|
|
24
24
|
resolve(data);
|
|
25
|
+
clearTimeout(timeout);
|
|
25
26
|
});
|
|
26
27
|
stdin.on('error', (err) => {
|
|
27
28
|
reject(err);
|
|
29
|
+
clearTimeout(timeout);
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
}
|
package/dist/esm/stdin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdin.js","sourceRoot":"","sources":["../../src/stdin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAA4B;IAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,4EAA4E;QAC5E,MAAM,uBAAuB,GAAG,CAAC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AC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;YACZ,YAAY,CAAC,OAAO,CAAC,CAAA;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-copilot/iam-expand",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Expand AWS IAM Actions with Wildcards",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "npx tsc -p tsconfig.cjs.json && npx tsc -p tsconfig.esm.json && ./postbuild.sh",
|
|
24
|
+
"clean": "rm -rf dist",
|
|
24
25
|
"test": "npx vitest --run --coverage",
|
|
25
|
-
"
|
|
26
|
+
"release": "npm run clean && npm run build && npm run test && npm publish"
|
|
26
27
|
},
|
|
27
28
|
"keywords": [
|
|
28
29
|
"AWS",
|
|
@@ -41,6 +42,6 @@
|
|
|
41
42
|
"vitest": "^2.0.5"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"@cloud-copilot/iam-data": ">=0.
|
|
45
|
+
"@cloud-copilot/iam-data": ">=0.7.0 <1.0.0"
|
|
45
46
|
}
|
|
46
47
|
}
|
package/dist/cli.d.ts
DELETED
package/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
5
|
-
const cli_utils_1 = require("./cli_utils");
|
|
6
|
-
const expand_1 = require("./expand");
|
|
7
|
-
function expandAndPrint(actionStrings, options) {
|
|
8
|
-
try {
|
|
9
|
-
const result = (0, expand_1.expandIamActions)(actionStrings, options);
|
|
10
|
-
for (const action of result) {
|
|
11
|
-
console.log(action);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
catch (e) {
|
|
15
|
-
console.error(e.message);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function printUsage() {
|
|
20
|
-
console.log('No arguments provided');
|
|
21
|
-
console.log('Usage:');
|
|
22
|
-
console.log(' expand-iam-actions [options] [action1] [action2] ...');
|
|
23
|
-
console.log(' <input from stdout> | expand-iam-actions');
|
|
24
|
-
console.log('Action Expanding Options:');
|
|
25
|
-
console.log(' --distinct: Remove duplicate actions');
|
|
26
|
-
console.log(' --sort: Sort the actions');
|
|
27
|
-
console.log(' --expand-asterik: Expand the * action to all actions');
|
|
28
|
-
console.log(' --expand-service-asterik: Expand service:* to all actions for that service');
|
|
29
|
-
console.log(' --error-on-missing-service: Throw an error if a service is not found');
|
|
30
|
-
console.log(' --error-on-invalid-format: Throw an error if the action string is not in the correct format');
|
|
31
|
-
console.log('CLI Behavior Options:');
|
|
32
|
-
console.log(' --show-data-version: Print the version of the iam-data package being used and exit');
|
|
33
|
-
console.log(' --input-wait-time: Millisenconds to wait for input from stdin before timing out. Example: --input-wait-time=10_000');
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
const args = process.argv.slice(2); // Ignore the first two elements
|
|
37
|
-
const actionStrings = [];
|
|
38
|
-
const optionStrings = [];
|
|
39
|
-
for (const arg of args) {
|
|
40
|
-
if (arg.startsWith('--')) {
|
|
41
|
-
optionStrings.push(arg);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
actionStrings.push(arg);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function run() {
|
|
48
|
-
const options = (0, cli_utils_1.convertOptions)(optionStrings);
|
|
49
|
-
if (options.showDataVersion) {
|
|
50
|
-
console.log(`@cloud-copilot/iam-data version: ${(0, iam_data_1.getVersion)()}`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (actionStrings.length === 0) {
|
|
54
|
-
const otherActions = await (0, cli_utils_1.parseStdInActions)();
|
|
55
|
-
actionStrings.push(...otherActions);
|
|
56
|
-
}
|
|
57
|
-
if (actionStrings.length > 0) {
|
|
58
|
-
expandAndPrint(actionStrings, options);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
printUsage();
|
|
62
|
-
}
|
|
63
|
-
run().catch((e) => {
|
|
64
|
-
console.error(e);
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}).then(() => process.exit(0)).finally(() => { });
|
|
67
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,sDAAqD;AACrD,2CAAgE;AAChE,qCAAqE;AAIrE,SAAS,cAAc,CAAC,aAAuB,EAAE,OAAyC;IACxF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,yBAAgB,EAAC,aAAa,EAAE,OAAO,CAAC,CAAA;QACvD,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC,uBAAuB,CA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,IAAG,OAAO,CAAC,eAAe,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,oCAAoC,IAAA,qBAAU,GAAE,EAAE,CAAC,CAAA;QAC/D,OAAM;IACR,CAAC;IAED,IAAG,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,YAAY,GAAG,MAAM,IAAA,6BAAiB,GAAE,CAAA;QAC9C,aAAa,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAA;IACrC,CAAC;IAED,IAAG,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;QACtC,OAAM;IACR,CAAC;IAED,UAAU,EAAE,CAAA;AACd,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA"}
|
package/dist/cli_utils.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ExpandIamActionsOptions } from "./expand";
|
|
2
|
-
interface CliOptions extends ExpandIamActionsOptions {
|
|
3
|
-
showDataVersion: boolean;
|
|
4
|
-
waitTime: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Convert a dash-case string to camelCase
|
|
8
|
-
* @param str the string to convert
|
|
9
|
-
* @returns the camelCase string
|
|
10
|
-
*/
|
|
11
|
-
export declare function dashToCamelCase(str: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Convert an array of option strings to an object
|
|
14
|
-
*
|
|
15
|
-
* @param optionArgs the array of option strings to convert
|
|
16
|
-
* @returns the object representation of the options
|
|
17
|
-
*/
|
|
18
|
-
export declare function convertOptions(optionArgs: string[]): Partial<CliOptions>;
|
|
19
|
-
export declare function extractActionsFromLineOfInput(line: string): string[];
|
|
20
|
-
/**
|
|
21
|
-
* Parse the actions from stdin
|
|
22
|
-
*
|
|
23
|
-
* @returns an array of strings from stdin
|
|
24
|
-
*/
|
|
25
|
-
export declare function parseStdInActions(): Promise<string[]>;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=cli_utils.d.ts.map
|
package/dist/cli_utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli_utils.d.ts","sourceRoot":"","sources":["../src/cli_utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGnD,UAAU,UAAW,SAAQ,uBAAuB;IAClD,eAAe,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAexE;AAGD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMpE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAS3D"}
|
package/dist/cli_utils.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dashToCamelCase = dashToCamelCase;
|
|
4
|
-
exports.convertOptions = convertOptions;
|
|
5
|
-
exports.extractActionsFromLineOfInput = extractActionsFromLineOfInput;
|
|
6
|
-
exports.parseStdInActions = parseStdInActions;
|
|
7
|
-
const stdin_1 = require("./stdin");
|
|
8
|
-
/**
|
|
9
|
-
* Convert a dash-case string to camelCase
|
|
10
|
-
* @param str the string to convert
|
|
11
|
-
* @returns the camelCase string
|
|
12
|
-
*/
|
|
13
|
-
function dashToCamelCase(str) {
|
|
14
|
-
str = str.substring(2);
|
|
15
|
-
return str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Convert an array of option strings to an object
|
|
19
|
-
*
|
|
20
|
-
* @param optionArgs the array of option strings to convert
|
|
21
|
-
* @returns the object representation of the options
|
|
22
|
-
*/
|
|
23
|
-
function convertOptions(optionArgs) {
|
|
24
|
-
// const options: Record<string, string | boolean> = {} ;
|
|
25
|
-
// for(const option of optionArgs) {
|
|
26
|
-
// let key: string = option
|
|
27
|
-
// let value: boolean | string = false
|
|
28
|
-
// console.log(key, value)
|
|
29
|
-
// if(option.includes('=')) {
|
|
30
|
-
// [key,value] = option.split('=')
|
|
31
|
-
// }
|
|
32
|
-
// options[dashToCamelCase(key)] = value
|
|
33
|
-
// }
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
const actionPattern = /\:?([a-zA-Z0-9]+:[a-zA-Z0-9*]+)/g;
|
|
37
|
-
function extractActionsFromLineOfInput(line) {
|
|
38
|
-
const matches = line.matchAll(actionPattern);
|
|
39
|
-
return Array.from(matches)
|
|
40
|
-
.filter((match) => !match[0].startsWith('arn:') && !match[0].startsWith(':'))
|
|
41
|
-
.map((match) => match[1]);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Parse the actions from stdin
|
|
45
|
-
*
|
|
46
|
-
* @returns an array of strings from stdin
|
|
47
|
-
*/
|
|
48
|
-
async function parseStdInActions() {
|
|
49
|
-
const data = await (0, stdin_1.readStdin)(undefined);
|
|
50
|
-
if (data.length === 0) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const lines = data.split('\n');
|
|
54
|
-
const actions = lines.flatMap(line => extractActionsFromLineOfInput(line));
|
|
55
|
-
return actions;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=cli_utils.js.map
|
package/dist/cli_utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli_utils.js","sourceRoot":"","sources":["../src/cli_utils.ts"],"names":[],"mappings":";;AAcA,0CAGC;AAQD,wCAeC;AAGD,sEAMC;AAOD,8CASC;AA/DD,mCAAoC;AAOpC;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACtB,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,UAAoB;IACjD,yDAAyD;IAEzD,oCAAoC;IACpC,6BAA6B;IAC7B,wCAAwC;IACxC,4BAA4B;IAC5B,+BAA+B;IAC/B,sCAAsC;IACtC,MAAM;IAEN,0CAA0C;IAC1C,IAAI;IAEJ,OAAO,EAAS,CAAA;AAClB,CAAC;AAED,MAAM,aAAa,GAAG,kCAAkC,CAAC;AACzD,SAAgB,6BAA6B,CAAC,IAAY;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAE5C,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;SACb,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAC5E,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACvC,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB;IACrC,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAS,EAAC,SAAS,CAAC,CAAA;IACvC,IAAG,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1E,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/dist/cli_utils.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli_utils.test.d.ts","sourceRoot":"","sources":["../src/cli_utils.test.ts"],"names":[],"mappings":""}
|
package/dist/cli_utils.test.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const stdin_1 = require("./stdin");
|
|
4
|
-
jest.mock('./stdin');
|
|
5
|
-
const mockReadStdin = stdin_1.readStdin;
|
|
6
|
-
const cli_utils_1 = require("./cli_utils");
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
jest.resetAllMocks();
|
|
9
|
-
});
|
|
10
|
-
const extractScenarios = [
|
|
11
|
-
{ input: ' s3:Get* ', expected: ['s3:Get*'] },
|
|
12
|
-
{ input: ' s3:Get* s3:Put* ', expected: ['s3:Get*', 's3:Put*'] },
|
|
13
|
-
{ input: ' "s3:Get*", "s3:Put*"', expected: ['s3:Get*', 's3:Put*'] },
|
|
14
|
-
{ input: ' `s3:Get*`, `s3:Put*`', expected: ['s3:Get*', 's3:Put*'] },
|
|
15
|
-
{ input: ` 's3:Get*', 's3:Put*'`, expected: ['s3:Get*', 's3:Put*'] },
|
|
16
|
-
{ input: `s3:Get*, s3:Put*`, expected: ['s3:Get*', 's3:Put*'] },
|
|
17
|
-
{ input: "s3:Put*", expected: ['s3:Put*'] },
|
|
18
|
-
{ input: ":s3:Put*", expected: [] },
|
|
19
|
-
{ input: 'arn:aws:apigateway:*::/apis', expected: [] },
|
|
20
|
-
{ input: 'hamburger', expected: [] },
|
|
21
|
-
];
|
|
22
|
-
const dashToCamelCaseScenarios = [
|
|
23
|
-
{ input: "--distinct", expected: "distinct" },
|
|
24
|
-
{ input: "--sort", expected: "sort" },
|
|
25
|
-
{ input: "--expand-asterik", expected: "expandAsterik" },
|
|
26
|
-
{ input: "--expand-service-asterik", expected: "expandServiceAsterik" },
|
|
27
|
-
{ input: "--error-on-missing-service", expected: "errorOnMissingService" },
|
|
28
|
-
{ input: "--error-on-invalid-format", expected: "errorOnInvalidFormat" },
|
|
29
|
-
{ input: "--show-data-version", expected: "showDataVersion" },
|
|
30
|
-
];
|
|
31
|
-
describe('cli_utils', () => {
|
|
32
|
-
describe('extractActionsFromLineOfInput', () => {
|
|
33
|
-
extractScenarios.forEach((scenario, index) => {
|
|
34
|
-
it(`should return for scenario ${index}: ${scenario.input} `, () => {
|
|
35
|
-
// Given the input
|
|
36
|
-
const input = scenario.input;
|
|
37
|
-
// When the actions are extracted
|
|
38
|
-
const result = (0, cli_utils_1.extractActionsFromLineOfInput)(input);
|
|
39
|
-
// Then I should get the expected result
|
|
40
|
-
expect(result).toEqual(scenario.expected);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('dashToCamelCase', () => {
|
|
45
|
-
dashToCamelCaseScenarios.forEach((scenario, index) => {
|
|
46
|
-
it(`should return for scenario ${index}: ${scenario.input} `, () => {
|
|
47
|
-
// Given the input
|
|
48
|
-
const input = scenario.input;
|
|
49
|
-
// When the input is converted
|
|
50
|
-
const result = (0, cli_utils_1.dashToCamelCase)(input);
|
|
51
|
-
// Then I should get the expected result
|
|
52
|
-
expect(result).toEqual(scenario.expected);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('convertOptions', () => {
|
|
57
|
-
it.only('should convert the options to keys on an object', () => {
|
|
58
|
-
// Given options as an array of strings
|
|
59
|
-
const optionArgs = ['--distinct', '--sort', '--something-cool', '--key-with-value=10'];
|
|
60
|
-
// When the options are converted
|
|
61
|
-
const result = (0, cli_utils_1.convertOptions)(optionArgs);
|
|
62
|
-
// Then each option should be a key on the object
|
|
63
|
-
expect(result).toEqual({
|
|
64
|
-
distinct: true,
|
|
65
|
-
sort: true,
|
|
66
|
-
somethingCool: true,
|
|
67
|
-
keyWithValue: "10",
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe('parseStdInActions', () => {
|
|
72
|
-
it('should return an empty array if no data is provided', async () => {
|
|
73
|
-
// Given no data is provided
|
|
74
|
-
mockReadStdin.mockResolvedValue('');
|
|
75
|
-
// When the actions are parsed
|
|
76
|
-
const result = await (0, cli_utils_1.parseStdInActions)();
|
|
77
|
-
// Then I should get an empty array
|
|
78
|
-
expect(result).toEqual([]);
|
|
79
|
-
});
|
|
80
|
-
it('should return an array of actions from the data', async () => {
|
|
81
|
-
// Given there is data with actions in multiple lines
|
|
82
|
-
mockReadStdin.mockResolvedValue('s3:GetObject\ns3:PutObject\ns3:DeleteObject\n');
|
|
83
|
-
// When the actions are parsed
|
|
84
|
-
const result = await (0, cli_utils_1.parseStdInActions)();
|
|
85
|
-
// Then I should get the expected actions
|
|
86
|
-
expect(result).toEqual(['s3:GetObject', 's3:PutObject', 's3:DeleteObject']);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
//# sourceMappingURL=cli_utils.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli_utils.test.js","sourceRoot":"","sources":["../src/cli_utils.test.ts"],"names":[],"mappings":";;AAAA,mCAAoC;AACpC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACpB,MAAM,aAAa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,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/expand.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for the expand function
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export interface ExpandIamActionsOptions {
|
|
6
|
-
/**
|
|
7
|
-
* If true, a single `*` will be expanded to all actions for all services
|
|
8
|
-
* If false, a single `*` will be returned as is
|
|
9
|
-
* Default: false
|
|
10
|
-
*/
|
|
11
|
-
expandAsterik: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* If true, `service:*` will be expanded to all actions for that service
|
|
14
|
-
* If false, `service:*` will be returned as is
|
|
15
|
-
* Default: false
|
|
16
|
-
*/
|
|
17
|
-
expandServiceAsterik: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* If true, an error will be thrown if the action string is not in the correct format
|
|
20
|
-
* If false, an empty array will be returned
|
|
21
|
-
* Default: false
|
|
22
|
-
*/
|
|
23
|
-
errorOnInvalidFormat: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* If true, an error will be thrown if the service in the action string does not exist
|
|
26
|
-
* If false, an empty array will be returned
|
|
27
|
-
* Default: false
|
|
28
|
-
*/
|
|
29
|
-
errorOnMissingService: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* If true, only unique values will be returned, while maintaining order
|
|
32
|
-
* If false, all values will be returned, even if they are duplicates
|
|
33
|
-
* Default: false
|
|
34
|
-
*/
|
|
35
|
-
distinct: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* If true, the returned array will be sorted
|
|
38
|
-
* If false, the returned array will be in the order they were expanded
|
|
39
|
-
* Default: false
|
|
40
|
-
*/
|
|
41
|
-
sort: boolean;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Expands an IAM action string that contains wildcards.
|
|
45
|
-
* If the action string contains no wildcards, it is returned as is.
|
|
46
|
-
* @see {@link ExpandIamActionsOptions} for options to customize behavior
|
|
47
|
-
*
|
|
48
|
-
* If any options are set to throw an error, the function will throw an error if validation fails for a single value.
|
|
49
|
-
*
|
|
50
|
-
* @param actionStringOrStrings An IAM action or array IAM action(s) that may contain wildcards
|
|
51
|
-
* @param overrideOptions Options to override the default behavior
|
|
52
|
-
* @returns An array of expanded action strings flattend to a single array
|
|
53
|
-
*/
|
|
54
|
-
export declare function expandIamActions(actionStringOrStrings: string | string[], overrideOptions?: Partial<ExpandIamActionsOptions>): string[];
|
|
55
|
-
//# sourceMappingURL=expand.d.ts.map
|
package/dist/expand.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../src/expand.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAA;IAEtB;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAE7B;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAE7B;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,CAAA;IAE9B;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;IAEjB;;;;OAIG;IACH,IAAI,EAAE,OAAO,CAAA;CACd;AAWD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,qBAAqB,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAAG,MAAM,EAAE,CAkFvI"}
|
package/dist/expand.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expandIamActions = expandIamActions;
|
|
4
|
-
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
5
|
-
const defaultOptions = {
|
|
6
|
-
expandAsterik: false,
|
|
7
|
-
expandServiceAsterik: false,
|
|
8
|
-
errorOnInvalidFormat: false,
|
|
9
|
-
errorOnMissingService: false,
|
|
10
|
-
distinct: false,
|
|
11
|
-
sort: false
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Expands an IAM action string that contains wildcards.
|
|
15
|
-
* If the action string contains no wildcards, it is returned as is.
|
|
16
|
-
* @see {@link ExpandIamActionsOptions} for options to customize behavior
|
|
17
|
-
*
|
|
18
|
-
* If any options are set to throw an error, the function will throw an error if validation fails for a single value.
|
|
19
|
-
*
|
|
20
|
-
* @param actionStringOrStrings An IAM action or array IAM action(s) that may contain wildcards
|
|
21
|
-
* @param overrideOptions Options to override the default behavior
|
|
22
|
-
* @returns An array of expanded action strings flattend to a single array
|
|
23
|
-
*/
|
|
24
|
-
function expandIamActions(actionStringOrStrings, overrideOptions) {
|
|
25
|
-
const options = { ...defaultOptions, ...overrideOptions };
|
|
26
|
-
if (!actionStringOrStrings) {
|
|
27
|
-
//Just in case the user passes in null or undefined
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
if (Array.isArray(actionStringOrStrings)) {
|
|
31
|
-
let allMatches = actionStringOrStrings.flatMap(actionString => expandIamActions(actionString, options));
|
|
32
|
-
if (options.distinct) {
|
|
33
|
-
const aSet = new Set();
|
|
34
|
-
allMatches = allMatches.filter((value) => {
|
|
35
|
-
if (aSet.has(value)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
aSet.add(value);
|
|
39
|
-
return true;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
if (options.sort) {
|
|
43
|
-
allMatches.sort();
|
|
44
|
-
}
|
|
45
|
-
return allMatches;
|
|
46
|
-
}
|
|
47
|
-
const actionString = actionStringOrStrings.trim();
|
|
48
|
-
if (actionString === '*') {
|
|
49
|
-
if (options.expandAsterik) {
|
|
50
|
-
//If that's really what you want...
|
|
51
|
-
return (0, iam_data_1.allServiceKeys)().flatMap(service => (0, iam_data_1.getActionsForService)(service).map(action => `${service}:${action}`));
|
|
52
|
-
}
|
|
53
|
-
return ['*'];
|
|
54
|
-
}
|
|
55
|
-
if (!actionString.includes(':')) {
|
|
56
|
-
if (options.errorOnInvalidFormat) {
|
|
57
|
-
throw new Error(`Invalid action format: ${actionString}`);
|
|
58
|
-
}
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
const parts = actionString.split(':');
|
|
62
|
-
if (parts.length !== 2) {
|
|
63
|
-
if (options.errorOnInvalidFormat) {
|
|
64
|
-
throw new Error(`Invalid action format: ${actionString}`);
|
|
65
|
-
}
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
const [service, wildcardActions] = parts.map(part => part.toLowerCase());
|
|
69
|
-
if (!(0, iam_data_1.serviceExists)(service)) {
|
|
70
|
-
if (options.errorOnMissingService) {
|
|
71
|
-
throw new Error(`Service not found: ${service}`);
|
|
72
|
-
}
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
if (!actionString.includes('*')) {
|
|
76
|
-
//No wildcards, just return the action string
|
|
77
|
-
return [actionString];
|
|
78
|
-
}
|
|
79
|
-
if (wildcardActions === '*') {
|
|
80
|
-
if (options.expandServiceAsterik) {
|
|
81
|
-
return (0, iam_data_1.getActionsForService)(service).map(action => `${service}:${action}`);
|
|
82
|
-
}
|
|
83
|
-
return [actionString];
|
|
84
|
-
}
|
|
85
|
-
const allActions = (0, iam_data_1.getActionsForService)(service);
|
|
86
|
-
const pattern = "^" + wildcardActions.replace(/\*/g, '.*?') + "$";
|
|
87
|
-
const regex = new RegExp(pattern, 'i');
|
|
88
|
-
const matchingActions = allActions.filter(action => regex.test(action)).map(action => `${service}:${action}`);
|
|
89
|
-
if (options.sort) {
|
|
90
|
-
matchingActions.sort();
|
|
91
|
-
}
|
|
92
|
-
return matchingActions;
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=expand.js.map
|
package/dist/expand.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expand.js","sourceRoot":"","sources":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AAC,EAAE,CAAC;QAC/B,6CAA6C;QAC7C,OAAO,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC;IAED,IAAG,eAAe,KAAK,GAAG,EAAE,CAAC;QAC3B,IAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;YAChC,OAAO,IAAA,+BAAoB,EAAC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,IAAI,MAAM,EAAE,CAAC,CAAA;QAC5E,CAAC;QACD,OAAO,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC;IAED,MAAM,UAAU,GAAG,IAAA,+BAAoB,EAAC,OAAO,CAAC,CAAA;IAChD,MAAM,OAAO,GAAG,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,GAAG,CAAA;IACjE,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACtC,MAAM,eAAe,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,IAAI,MAAM,EAAE,CAAC,CAAA;IAC7G,IAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,eAAe,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;IAED,OAAO,eAAe,CAAA;AACxB,CAAC"}
|
package/dist/expand.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expand.test.d.ts","sourceRoot":"","sources":["../src/expand.test.ts"],"names":[],"mappings":""}
|
package/dist/expand.test.js
DELETED
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const expand_1 = require("./expand");
|
|
4
|
-
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
5
|
-
jest.mock('@cloud-copilot/iam-data');
|
|
6
|
-
const mockGetActionsForService = iam_data_1.getActionsForService;
|
|
7
|
-
const mockServiceExists = iam_data_1.serviceExists;
|
|
8
|
-
const mockAllServiceKeys = iam_data_1.allServiceKeys;
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
jest.resetAllMocks();
|
|
11
|
-
});
|
|
12
|
-
describe("expand", () => {
|
|
13
|
-
it("should return an empty array when actionString is null", () => {
|
|
14
|
-
//Given actionString is null
|
|
15
|
-
const actionString = null;
|
|
16
|
-
//When expand is called with actionString
|
|
17
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
18
|
-
//Then result should be an empty array
|
|
19
|
-
expect(result).toEqual([]);
|
|
20
|
-
});
|
|
21
|
-
it("should return '*' when actionString is '*' and expandAsterik is false", () => {
|
|
22
|
-
//Given actionString is '*'
|
|
23
|
-
const actionString = '*';
|
|
24
|
-
//When expand is called with actionString
|
|
25
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
26
|
-
//Then result should be '*'
|
|
27
|
-
expect(result).toEqual(['*']);
|
|
28
|
-
});
|
|
29
|
-
it("should expand all actions for all services when actionString is '*' and expandAsterik is true", () => {
|
|
30
|
-
//Given actionString is '*'
|
|
31
|
-
const actionString = '*';
|
|
32
|
-
//And expandAsterik is true
|
|
33
|
-
const options = { expandAsterik: true };
|
|
34
|
-
//And there are services
|
|
35
|
-
mockAllServiceKeys.mockReturnValue(['s3', 'ec2']);
|
|
36
|
-
//And there are actions for the services
|
|
37
|
-
mockGetActionsForService.mockImplementation(service => {
|
|
38
|
-
if (service === 's3') {
|
|
39
|
-
return ['action1', 'action2'];
|
|
40
|
-
}
|
|
41
|
-
if (service === 'ec2') {
|
|
42
|
-
return ['action3', 'action4'];
|
|
43
|
-
}
|
|
44
|
-
return [];
|
|
45
|
-
});
|
|
46
|
-
//When expand is called with actionString and options
|
|
47
|
-
const result = (0, expand_1.expandIamActions)(actionString, options);
|
|
48
|
-
//Then result should be an array of all actions for all services
|
|
49
|
-
expect(result.sort()).toEqual([
|
|
50
|
-
'ec2:action3',
|
|
51
|
-
'ec2:action4',
|
|
52
|
-
's3:action1',
|
|
53
|
-
's3:action2'
|
|
54
|
-
]);
|
|
55
|
-
});
|
|
56
|
-
it("should do a case insensitive match for the service in the action string", () => {
|
|
57
|
-
//Given actionString is 'S3:GetObject'
|
|
58
|
-
const actionString = 'S3:get*';
|
|
59
|
-
//And s3 service exists
|
|
60
|
-
mockServiceExists.mockImplementation((s) => s === 's3');
|
|
61
|
-
//And there are matching actions
|
|
62
|
-
mockGetActionsForService.mockReturnValue(['GetObject']);
|
|
63
|
-
//When expand is called with actionString
|
|
64
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
65
|
-
//Then result should be an array with the actionString
|
|
66
|
-
expect(result).toEqual(['s3:GetObject']);
|
|
67
|
-
});
|
|
68
|
-
it("should return the action string as is when it does not contain wildcards", () => {
|
|
69
|
-
//Given actionString contains no wildcards
|
|
70
|
-
const actionString = 's3:GetObject';
|
|
71
|
-
//And the service and action exist
|
|
72
|
-
mockServiceExists.mockReturnValue(true);
|
|
73
|
-
mockGetActionsForService.mockReturnValue(['GetObject']);
|
|
74
|
-
//When expand is called with actionString
|
|
75
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
76
|
-
//Then result should be an array with the actionString
|
|
77
|
-
expect(result).toEqual([actionString]);
|
|
78
|
-
});
|
|
79
|
-
describe("when the actions string is in the wrong format", () => {
|
|
80
|
-
it("should return an empty array when there are too many parts and errorOnInvalidFormat is false", () => {
|
|
81
|
-
//Given actionString is in the wrong format
|
|
82
|
-
const actionString = 's3:GetObject:Extra*';
|
|
83
|
-
//And errorOnInvalidFormat is false
|
|
84
|
-
const options = { errorOnInvalidFormat: false };
|
|
85
|
-
//When expand is called with actionString
|
|
86
|
-
const result = (0, expand_1.expandIamActions)(actionString, options);
|
|
87
|
-
//Then result should be an empty array
|
|
88
|
-
expect(result).toEqual([]);
|
|
89
|
-
});
|
|
90
|
-
it("should return an empty array when there are too few parts and errorOnInvalidFormat is false", () => {
|
|
91
|
-
//Given actionString has no :
|
|
92
|
-
const actionString = 's3GetObject*';
|
|
93
|
-
//And errorOnInvalidFormat is false
|
|
94
|
-
const options = { errorOnInvalidFormat: false };
|
|
95
|
-
//When expand is called with actionString
|
|
96
|
-
const result = (0, expand_1.expandIamActions)(actionString, options);
|
|
97
|
-
//Then result should be an empty array
|
|
98
|
-
expect(result).toEqual([]);
|
|
99
|
-
});
|
|
100
|
-
it("should throw an error when there are too many parts and errorOnInvalidFormat is true", () => {
|
|
101
|
-
//Given actionString is in the wrong format
|
|
102
|
-
const actionString = 's3:GetObject:Extra*';
|
|
103
|
-
//And errorOnInvalidFormat is true
|
|
104
|
-
const options = { errorOnInvalidFormat: true };
|
|
105
|
-
//When expand is called with actionString
|
|
106
|
-
//Then an error should be thrown
|
|
107
|
-
expect(() => (0, expand_1.expandIamActions)(actionString, options)).toThrowError('Invalid action format');
|
|
108
|
-
});
|
|
109
|
-
it("should throw an error when there are too few parts and errorOnInvalidFormat is true", () => {
|
|
110
|
-
//Given actionString has no :
|
|
111
|
-
const actionString = 's3GetObject*';
|
|
112
|
-
//And errorOnInvalidFormat is true
|
|
113
|
-
const options = { errorOnInvalidFormat: true };
|
|
114
|
-
//When expand is called with actionString
|
|
115
|
-
//Then an error should be thrown
|
|
116
|
-
expect(() => (0, expand_1.expandIamActions)(actionString, options)).toThrowError('Invalid action format');
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
describe("when the service in the action string does not exist", () => {
|
|
120
|
-
it("should return an empty array when errorOnMissingService is false", () => {
|
|
121
|
-
//Given actionString contains a service that does not exist
|
|
122
|
-
const actionString = 'fake:GetObject*';
|
|
123
|
-
//And errorOnMissingService is false
|
|
124
|
-
const options = { errorOnMissingService: false };
|
|
125
|
-
//When expand is called with actionString
|
|
126
|
-
const result = (0, expand_1.expandIamActions)(actionString, options);
|
|
127
|
-
//Then result should be an empty array
|
|
128
|
-
expect(result).toEqual([]);
|
|
129
|
-
});
|
|
130
|
-
it("should throw an error when errorOnMissingService is true", () => {
|
|
131
|
-
//Given actionString contains a service that does not exist
|
|
132
|
-
const actionString = 'fake:GetObject*';
|
|
133
|
-
//And errorOnMissingService is true
|
|
134
|
-
const options = { errorOnMissingService: true };
|
|
135
|
-
//When expand is called with actionString
|
|
136
|
-
//Then an error should be thrown
|
|
137
|
-
expect(() => (0, expand_1.expandIamActions)(actionString, options)).toThrowError('Service not found');
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe("when the action string contains a wildcard for a service", () => {
|
|
141
|
-
it("should expand not expand the wildcard when expandServiceAsterik is false", () => {
|
|
142
|
-
//Given actionString is 's3:*'
|
|
143
|
-
const actionString = 's3:*';
|
|
144
|
-
//And expandServiceAsterik is false
|
|
145
|
-
const options = { expandServiceAsterik: false };
|
|
146
|
-
//And s3 service exists
|
|
147
|
-
mockServiceExists.mockReturnValue(true);
|
|
148
|
-
//And there are matching actions
|
|
149
|
-
mockGetActionsForService.mockReturnValue(['GetObject', 'PutObject']);
|
|
150
|
-
//When expand is called with actionString
|
|
151
|
-
const result = (0, expand_1.expandIamActions)(actionString, options);
|
|
152
|
-
//Then result should be an array with the original string
|
|
153
|
-
expect(result).toEqual([actionString]);
|
|
154
|
-
});
|
|
155
|
-
it("should expand the wildcard when expandServiceAsterik is true", () => {
|
|
156
|
-
//Given actionString is 's3:*'
|
|
157
|
-
const actionString = 's3:*';
|
|
158
|
-
//And expandServiceAsterik is true
|
|
159
|
-
const options = { expandServiceAsterik: true };
|
|
160
|
-
//And s3 service exists
|
|
161
|
-
mockServiceExists.mockReturnValue(true);
|
|
162
|
-
//And there are matching actions
|
|
163
|
-
mockGetActionsForService.mockReturnValue(['GetObject', 'PutObject']);
|
|
164
|
-
//When expand is called with actionString
|
|
165
|
-
const result = (0, expand_1.expandIamActions)(actionString, options);
|
|
166
|
-
//Then result should be an array of actions
|
|
167
|
-
expect(result).toEqual([
|
|
168
|
-
's3:GetObject',
|
|
169
|
-
's3:PutObject'
|
|
170
|
-
]);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
describe("when the action string contains wildcards", () => {
|
|
174
|
-
it('should expand the wildcard actions at the end', () => {
|
|
175
|
-
//Given actionString is 's3:Get*'
|
|
176
|
-
const actionString = 's3:Get*';
|
|
177
|
-
//And s3 service exists
|
|
178
|
-
mockServiceExists.mockReturnValue(true);
|
|
179
|
-
//And there are matching actions
|
|
180
|
-
mockGetActionsForService.mockReturnValue([
|
|
181
|
-
'GetObject',
|
|
182
|
-
'GetObjectAcl',
|
|
183
|
-
'GetObjectTagging',
|
|
184
|
-
'GetObjectTorrent',
|
|
185
|
-
'PutObject',
|
|
186
|
-
'PutObjectAcl',
|
|
187
|
-
'SomethingGetSomething'
|
|
188
|
-
]);
|
|
189
|
-
//When expand is called with actionString
|
|
190
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
191
|
-
//Then result should be an array of actions
|
|
192
|
-
expect(result).toEqual([
|
|
193
|
-
's3:GetObject',
|
|
194
|
-
's3:GetObjectAcl',
|
|
195
|
-
's3:GetObjectTagging',
|
|
196
|
-
's3:GetObjectTorrent'
|
|
197
|
-
]);
|
|
198
|
-
});
|
|
199
|
-
it('should expand the wildcard actions at the beginning', () => {
|
|
200
|
-
//Given actionString is 's3:*Object'
|
|
201
|
-
const actionString = 's3:*Object';
|
|
202
|
-
//And s3 service exists
|
|
203
|
-
mockServiceExists.mockReturnValue(true);
|
|
204
|
-
//And there are matching actions
|
|
205
|
-
mockGetActionsForService.mockReturnValue([
|
|
206
|
-
'GetObject',
|
|
207
|
-
'GetObjectAcl',
|
|
208
|
-
'GetObjectTagging',
|
|
209
|
-
'GetObjectTorrent',
|
|
210
|
-
'PutObject',
|
|
211
|
-
'PutObjectAcl',
|
|
212
|
-
'SomethingGetSomething'
|
|
213
|
-
]);
|
|
214
|
-
//When expand is called with actionString
|
|
215
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
216
|
-
//Then result should be an array of actions
|
|
217
|
-
expect(result).toEqual([
|
|
218
|
-
's3:GetObject',
|
|
219
|
-
's3:PutObject'
|
|
220
|
-
]);
|
|
221
|
-
});
|
|
222
|
-
it('should expand the wildcard actions in the middle', () => {
|
|
223
|
-
//Given actionString is 's3:Get*Tagging'
|
|
224
|
-
const actionString = 's3:Get*Tagging';
|
|
225
|
-
//And s3 service exists
|
|
226
|
-
mockServiceExists.mockReturnValue(true);
|
|
227
|
-
//And there are matching actions
|
|
228
|
-
mockGetActionsForService.mockReturnValue([
|
|
229
|
-
'GetObject',
|
|
230
|
-
'GetObjectAcl',
|
|
231
|
-
'GetObjectTagging',
|
|
232
|
-
'GetBanskyTagging',
|
|
233
|
-
'GetObjectTorrent',
|
|
234
|
-
'PutObject',
|
|
235
|
-
'PutObjectAcl',
|
|
236
|
-
'SomethingGetSomething'
|
|
237
|
-
]);
|
|
238
|
-
//When expand is called with actionString
|
|
239
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
240
|
-
//Then result should be an array of actions
|
|
241
|
-
expect(result).toEqual([
|
|
242
|
-
's3:GetObjectTagging',
|
|
243
|
-
's3:GetBanskyTagging'
|
|
244
|
-
]);
|
|
245
|
-
});
|
|
246
|
-
it('should expand multiple wildcards', () => {
|
|
247
|
-
//Given actionString is 's3:Get*Tagging*'
|
|
248
|
-
const actionString = 's3:Get*Tagging*';
|
|
249
|
-
//And s3 service exists
|
|
250
|
-
mockServiceExists.mockReturnValue(true);
|
|
251
|
-
//And there are matching actions
|
|
252
|
-
mockGetActionsForService.mockReturnValue([
|
|
253
|
-
'GetObject',
|
|
254
|
-
'GetObjectAcl',
|
|
255
|
-
'GetObjectTagging',
|
|
256
|
-
'GetBanskyTagging',
|
|
257
|
-
'GetTagging',
|
|
258
|
-
'GetObjectTorrent',
|
|
259
|
-
'GetSomethingTaggingSomething',
|
|
260
|
-
'PutObject',
|
|
261
|
-
'PutObjectAcl',
|
|
262
|
-
'SomethingGetSomething'
|
|
263
|
-
]);
|
|
264
|
-
//When expand is called with actionString
|
|
265
|
-
const result = (0, expand_1.expandIamActions)(actionString);
|
|
266
|
-
//Then result should be an array of actions
|
|
267
|
-
expect(result).toEqual([
|
|
268
|
-
's3:GetObjectTagging',
|
|
269
|
-
's3:GetBanskyTagging',
|
|
270
|
-
's3:GetTagging',
|
|
271
|
-
's3:GetSomethingTaggingSomething'
|
|
272
|
-
]);
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
describe("when actionStrings is an array", () => {
|
|
276
|
-
it("should return an empty array when actionStrings is an empty array", () => {
|
|
277
|
-
//Given actionStrings is an empty array
|
|
278
|
-
const actionStrings = [];
|
|
279
|
-
//When expand is called with actionStrings
|
|
280
|
-
const result = (0, expand_1.expandIamActions)(actionStrings);
|
|
281
|
-
//Then result should be an empty array
|
|
282
|
-
expect(result).toEqual([]);
|
|
283
|
-
});
|
|
284
|
-
it("should return an array of expanded actions when actionStrings is an array of action strings", () => {
|
|
285
|
-
//Given actionStrings is an array of action strings
|
|
286
|
-
const actionStrings = [
|
|
287
|
-
's3:Get*',
|
|
288
|
-
'ec2:*Instances'
|
|
289
|
-
];
|
|
290
|
-
//And s3 and ec2 services exist
|
|
291
|
-
mockServiceExists.mockReturnValue(true);
|
|
292
|
-
//And there are actions for the services
|
|
293
|
-
mockGetActionsForService.mockImplementation(service => {
|
|
294
|
-
if (service === 's3') {
|
|
295
|
-
return ['GetObject', 'GetObjectTagging', 'PutObject', 'PutObjectTagging'];
|
|
296
|
-
}
|
|
297
|
-
if (service === 'ec2') {
|
|
298
|
-
return ['RunInstances', 'TerminateInstances'];
|
|
299
|
-
}
|
|
300
|
-
return [];
|
|
301
|
-
});
|
|
302
|
-
//When expand is called with actionStrings
|
|
303
|
-
const result = (0, expand_1.expandIamActions)(actionStrings);
|
|
304
|
-
//Then result should be an array of expanded actions
|
|
305
|
-
expect(result.sort()).toEqual([
|
|
306
|
-
'ec2:RunInstances',
|
|
307
|
-
'ec2:TerminateInstances',
|
|
308
|
-
's3:GetObject',
|
|
309
|
-
's3:GetObjectTagging',
|
|
310
|
-
]);
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
describe("distinct option", () => {
|
|
314
|
-
it('should return all values when distinct is false', () => {
|
|
315
|
-
//Given two action strings
|
|
316
|
-
const actionString = ['s3:Get*', 's3:*Object'];
|
|
317
|
-
//And s3 service exists
|
|
318
|
-
mockServiceExists.mockReturnValue(true);
|
|
319
|
-
//And there are matching actions
|
|
320
|
-
mockGetActionsForService.mockReturnValue(['GetObject', 'PutObject', 'GetOtherObject']);
|
|
321
|
-
//When expand is called with actionString and distinct is false
|
|
322
|
-
const result = (0, expand_1.expandIamActions)(actionString, { distinct: false });
|
|
323
|
-
//Then result should be an array of actions, even if they are duplicates
|
|
324
|
-
expect(result).toEqual(['s3:GetObject', 's3:GetOtherObject', 's3:GetObject', 's3:PutObject', 's3:GetOtherObject']);
|
|
325
|
-
});
|
|
326
|
-
it('should return only unique values when distinct is true, and maintain order', () => {
|
|
327
|
-
//Given two action strings
|
|
328
|
-
const actionString = ['s3:Get*', 's3:*Object'];
|
|
329
|
-
//And s3 service exists
|
|
330
|
-
mockServiceExists.mockReturnValue(true);
|
|
331
|
-
//And there are matching actions
|
|
332
|
-
mockGetActionsForService.mockReturnValue(['GetObject', 'PutObject', 'GetOtherObject']);
|
|
333
|
-
//When expand is called with actionStrings and distinct is true
|
|
334
|
-
const result = (0, expand_1.expandIamActions)(actionString, { distinct: true });
|
|
335
|
-
//Then result should be an array of unique actions
|
|
336
|
-
expect(result).toEqual(['s3:GetObject', 's3:GetOtherObject', 's3:PutObject']);
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
describe("sort option", () => {
|
|
340
|
-
it('should return values in the order they were expanded when sort is false', () => {
|
|
341
|
-
//Given two action strings
|
|
342
|
-
const actionString = ['s3:Get*', 'ec2:Describe*'];
|
|
343
|
-
//And s3 service exists
|
|
344
|
-
mockServiceExists.mockReturnValue(true);
|
|
345
|
-
//And there are matching actions
|
|
346
|
-
mockGetActionsForService.mockImplementation(service => {
|
|
347
|
-
if (service === 's3') {
|
|
348
|
-
return ['GetObject', 'GetBucket'];
|
|
349
|
-
}
|
|
350
|
-
if (service === 'ec2') {
|
|
351
|
-
return ['DescribeInstances', 'DescribeVolumes'];
|
|
352
|
-
}
|
|
353
|
-
return [];
|
|
354
|
-
});
|
|
355
|
-
//When expand is called with actionStrings and sort is false
|
|
356
|
-
const result = (0, expand_1.expandIamActions)(actionString, { sort: false });
|
|
357
|
-
//Then result should be an array of actions in the order they were expanded
|
|
358
|
-
expect(result).toEqual(['s3:GetObject', 's3:GetBucket', 'ec2:DescribeInstances', 'ec2:DescribeVolumes']);
|
|
359
|
-
});
|
|
360
|
-
it('should return values sorted when sort is true', () => {
|
|
361
|
-
//Given two action strings
|
|
362
|
-
const actionString = ['s3:Get*', 'ec2:Describe*'];
|
|
363
|
-
//And s3 service exists
|
|
364
|
-
mockServiceExists.mockReturnValue(true);
|
|
365
|
-
//And there are matching actions
|
|
366
|
-
mockGetActionsForService.mockImplementation(service => {
|
|
367
|
-
if (service === 's3') {
|
|
368
|
-
return ['GetObject', 'GetBucket'];
|
|
369
|
-
}
|
|
370
|
-
if (service === 'ec2') {
|
|
371
|
-
return ['DescribeInstances', 'DescribeVolumes'];
|
|
372
|
-
}
|
|
373
|
-
return [];
|
|
374
|
-
});
|
|
375
|
-
//When expand is called with actionStrings and sort is false
|
|
376
|
-
const result = (0, expand_1.expandIamActions)(actionString, { sort: true });
|
|
377
|
-
//Then result should be an array of actions in the order they were expanded
|
|
378
|
-
expect(result).toEqual(['ec2:DescribeInstances', 'ec2:DescribeVolumes', 's3:GetBucket', 's3:GetObject']);
|
|
379
|
-
});
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
//# sourceMappingURL=expand.test.js.map
|
package/dist/expand.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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I,EAAE,IAAI,EAAE,CAAC,CAAA;YAC7D,2EAA2E;YAC3E,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,uBAAuB,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;QAC1G,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AAGJ,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./expand"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
package/dist/stdin.d.ts
DELETED
package/dist/stdin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../src/stdin.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B7E"}
|
package/dist/stdin.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readStdin = readStdin;
|
|
4
|
-
const process_1 = require("process");
|
|
5
|
-
/**
|
|
6
|
-
* Read from stdin until the stream ends, timeout, or an error occurs
|
|
7
|
-
*
|
|
8
|
-
* @returns the string input from stdin
|
|
9
|
-
*/
|
|
10
|
-
async function readStdin(readWait) {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
// If the input is not a TTY, we are most likely receiving data from a pipe.
|
|
13
|
-
const definitelyReceivingData = !process.stdin.isTTY;
|
|
14
|
-
if (!readWait || readWait <= 0) {
|
|
15
|
-
readWait = definitelyReceivingData ? 10_000 : 20;
|
|
16
|
-
}
|
|
17
|
-
let data = '';
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
if (data.length === 0) {
|
|
20
|
-
resolve(data);
|
|
21
|
-
}
|
|
22
|
-
}, readWait);
|
|
23
|
-
process_1.stdin.on('data', (chunk) => {
|
|
24
|
-
data += chunk;
|
|
25
|
-
});
|
|
26
|
-
process_1.stdin.on('end', () => {
|
|
27
|
-
console.log('end');
|
|
28
|
-
resolve(data);
|
|
29
|
-
});
|
|
30
|
-
process_1.stdin.on('error', (err) => {
|
|
31
|
-
reject(err);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=stdin.js.map
|
package/dist/stdin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stdin.js","sourceRoot":"","sources":["../src/stdin.ts"],"names":[],"mappings":";;AAMA,8BA4BC;AAlCD,qCAAgC;AAChC;;;;GAIG;AACI,KAAK,UAAU,SAAS,CAAC,QAA4B;IAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,4EAA4E;QAC5E,MAAM,uBAAuB,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAA;QACpD,IAAG,CAAC,QAAQ,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;YAC9B,QAAQ,GAAG,uBAAuB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;QAClD,CAAC;QAED,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,UAAU,CAAC,GAAG,EAAE;YACd,IAAG,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,CAAC,CAAA;YACf,CAAC;QACH,CAAC,EAAE,QAAQ,CAAC,CAAA;QAEZ,eAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,eAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACnB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,eAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|