@cloud-copilot/iam-expand 0.1.10 → 0.1.12

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 CHANGED
@@ -6,6 +6,11 @@ Use this to:
6
6
  2) Get an exhaustive list of actions that are included in a policy to quickly search it for interesting actions.
7
7
  3) Investigate where interesting or dubious actions are being used in your policies.
8
8
 
9
+ <!-- Image of demo.svg -->
10
+ ![Demo](assets/demo.svg)
11
+
12
+ Extended demo [on YouTube](https://www.youtube.com/watch?v=357-uGru7300).
13
+
9
14
  Published as an [npm package](#typescriptnodejs-usage) in ESM and CommonJS plus available as a [CLI](#cli).
10
15
 
11
16
  All information is sourced from [@cloud-copilot/iam-data](https://github.com/cloud-copilot/iam-data) which is updated daily.
@@ -156,10 +161,10 @@ When reading from stdin (see [below](#read-from-stdin)) the CLI will wait 10 sec
156
161
 
157
162
  ```bash
158
163
  cat policy.json | iam-expand
159
- # Will wait for 10 seconds for input, which is plenty of time for a local file.
164
+ # Will wait up to 10 seconds for input to start, which is plenty of time for a local file.
160
165
 
161
166
  curl "https://government-secrets.s3.amazonaws.com/secret-policy.json" | iam-expand --read-wait-ms=20_000
162
- # Will wait for 20 seconds for the first byte from curl before timing out. Adjust as needed
167
+ # Will wait up to 20 seconds to receive first byte from curl before timing out. Adjust as needed
163
168
  ```
164
169
 
165
170
  ### Read from stdin
@@ -1,11 +1,12 @@
1
1
  import { ExpandIamActionsOptions } from "./expand.js";
2
2
  /**
3
- * Takes any JSON document and expands any Action found in the document
3
+ * Takes any JSON document and expands any Action or NotAction string or array of strings in the document.
4
+ * *MODIFIES THE DOCUMENT IN PLACE*
4
5
  *
5
6
  * @param options the options to use when expanding the actions
6
7
  * @param document the JSON document to expand
7
8
  * @param key the key of the current node in the document
8
- * @returns the expanded JSON document
9
+ * @returns the original JSON document with any actions expanded in place
9
10
  */
10
11
  export declare function expandJsonDocument(options: Partial<ExpandIamActionsOptions>, document: any, key?: string): Promise<any>;
11
12
  //# sourceMappingURL=expand_file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"expand_file.d.ts","sourceRoot":"","sources":["../../src/expand_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAEvE;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA4B7H"}
1
+ {"version":3,"file":"expand_file.d.ts","sourceRoot":"","sources":["../../src/expand_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA0B7H"}
@@ -3,36 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expandJsonDocument = expandJsonDocument;
4
4
  const expand_js_1 = require("./expand.js");
5
5
  /**
6
- * Takes any JSON document and expands any Action found in the document
6
+ * Takes any JSON document and expands any Action or NotAction string or array of strings in the document.
7
+ * *MODIFIES THE DOCUMENT IN PLACE*
7
8
  *
8
9
  * @param options the options to use when expanding the actions
9
10
  * @param document the JSON document to expand
10
11
  * @param key the key of the current node in the document
11
- * @returns the expanded JSON document
12
+ * @returns the original JSON document with any actions expanded in place
12
13
  */
13
14
  async function expandJsonDocument(options, document, key) {
14
15
  if (key === 'Action' || key === 'NotAction') {
15
16
  if (typeof document === 'string') {
16
- return await (0, expand_js_1.expandIamActions)(document, options);
17
+ return (0, expand_js_1.expandIamActions)(document, options);
17
18
  }
18
19
  if (Array.isArray(document) && document.length > 0 && typeof document[0] === 'string') {
19
- const value = await (0, expand_js_1.expandIamActions)(document, { ...options });
20
- return value;
20
+ return (0, expand_js_1.expandIamActions)(document, options);
21
21
  }
22
22
  }
23
23
  if (Array.isArray(document)) {
24
- return Promise.all(document.map(async (item) => {
25
- return expandJsonDocument(options, item);
26
- }));
24
+ const results = [];
25
+ for (const item of document) {
26
+ results.push(await expandJsonDocument(options, item));
27
+ }
28
+ return results;
27
29
  }
28
- if (typeof document === 'object') {
29
- const keys = Object.keys(document);
30
- const newObject = {};
31
- for (const key of keys) {
32
- const value = document[key];
33
- newObject[key] = await expandJsonDocument(options, value, key);
30
+ if (typeof document === 'object' && document !== null) {
31
+ for (const key of Object.keys(document)) {
32
+ document[key] = await expandJsonDocument(options, document[key], key);
34
33
  }
35
- return newObject;
34
+ return document;
36
35
  }
37
36
  return document;
38
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expand_file.js","sourceRoot":"","sources":["../../src/expand_file.ts"],"names":[],"mappings":";;AAUA,gDA4BC;AAtCD,2CAAuE;AAEvE;;;;;;;GAOG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAAyC,EAAE,QAAa,EAAE,GAAY;IAC7G,IAAG,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;QAC3C,IAAG,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,MAAM,IAAA,4BAAgB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAClD,CAAC;QACD,IAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YACrF,MAAM,KAAK,GAAI,MAAM,IAAA,4BAAgB,EAAC,QAAQ,EAAE,EAAC,GAAG,OAAO,EAAC,CAAC,CAAA;YAC7D,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,IAAG,KAAK,CAAC,OAAO,C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,EAAE,OAAO,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,MAAM,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { ExpandIamActionsOptions } from "./expand.js";
2
2
  /**
3
- * Takes any JSON document and expands any Action found in the document
3
+ * Takes any JSON document and expands any Action or NotAction string or array of strings in the document.
4
+ * *MODIFIES THE DOCUMENT IN PLACE*
4
5
  *
5
6
  * @param options the options to use when expanding the actions
6
7
  * @param document the JSON document to expand
7
8
  * @param key the key of the current node in the document
8
- * @returns the expanded JSON document
9
+ * @returns the original JSON document with any actions expanded in place
9
10
  */
10
11
  export declare function expandJsonDocument(options: Partial<ExpandIamActionsOptions>, document: any, key?: string): Promise<any>;
11
12
  //# sourceMappingURL=expand_file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"expand_file.d.ts","sourceRoot":"","sources":["../../src/expand_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAEvE;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA4B7H"}
1
+ {"version":3,"file":"expand_file.d.ts","sourceRoot":"","sources":["../../src/expand_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA0B7H"}
@@ -1,35 +1,34 @@
1
1
  import { expandIamActions } from "./expand.js";
2
2
  /**
3
- * Takes any JSON document and expands any Action found in the document
3
+ * Takes any JSON document and expands any Action or NotAction string or array of strings in the document.
4
+ * *MODIFIES THE DOCUMENT IN PLACE*
4
5
  *
5
6
  * @param options the options to use when expanding the actions
6
7
  * @param document the JSON document to expand
7
8
  * @param key the key of the current node in the document
8
- * @returns the expanded JSON document
9
+ * @returns the original JSON document with any actions expanded in place
9
10
  */
10
11
  export async function expandJsonDocument(options, document, key) {
11
12
  if (key === 'Action' || key === 'NotAction') {
12
13
  if (typeof document === 'string') {
13
- return await expandIamActions(document, options);
14
+ return expandIamActions(document, options);
14
15
  }
15
16
  if (Array.isArray(document) && document.length > 0 && typeof document[0] === 'string') {
16
- const value = await expandIamActions(document, { ...options });
17
- return value;
17
+ return expandIamActions(document, options);
18
18
  }
19
19
  }
20
20
  if (Array.isArray(document)) {
21
- return Promise.all(document.map(async (item) => {
22
- return expandJsonDocument(options, item);
23
- }));
21
+ const results = [];
22
+ for (const item of document) {
23
+ results.push(await expandJsonDocument(options, item));
24
+ }
25
+ return results;
24
26
  }
25
- if (typeof document === 'object') {
26
- const keys = Object.keys(document);
27
- const newObject = {};
28
- for (const key of keys) {
29
- const value = document[key];
30
- newObject[key] = await expandJsonDocument(options, value, key);
27
+ if (typeof document === 'object' && document !== null) {
28
+ for (const key of Object.keys(document)) {
29
+ document[key] = await expandJsonDocument(options, document[key], key);
31
30
  }
32
- return newObject;
31
+ return document;
33
32
  }
34
33
  return document;
35
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expand_file.js","sourceRoot":"","sources":["../../src/expand_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA2B,MAAM,aAAa,CAAA;AAEvE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAyC,EAAE,QAAa,EAAE,GAAY;IAC7G,IAAG,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;QAC3C,IAAG,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,MAAM,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAClD,CAAC;QACD,IAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YACrF,MAAM,KAAK,GAAI,MAAM,gBAAgB,CAAC,QAAQ,EAAE,EAAC,GAAG,OAAO,EAAC,CAAC,CAAA;YAC7D,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,IAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC7C,OAAO,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAC,CAAA;IACL,CAAC;IAED,IAAG,OAAO,QAAQ,KAAK,QAAQ,EAAE,CA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,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-copilot/iam-expand",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Expand AWS IAM Actions with Wildcards",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "types": "dist/cjs/index.d.ts",
19
19
  "bin": {
20
- "iam-expand": "dist/cjs/cli.js"
20
+ "iam-expand": "dist/esm/cli.js"
21
21
  },
22
22
  "scripts": {
23
23
  "build": "npx tsc -p tsconfig.cjs.json && npx tsc -p tsconfig.esm.json && ./postbuild.sh",
@@ -41,6 +41,6 @@
41
41
  "vitest": "^2.0.5"
42
42
  },
43
43
  "peerDependencies": {
44
- "@cloud-copilot/iam-data": ">=0.3.0 <1.0.0"
44
+ "@cloud-copilot/iam-data": ">=0.5.0 <1.0.0"
45
45
  }
46
46
  }