@cloud-copilot/iam-shrink 0.1.3 → 0.1.5
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/.github/workflows/guarddog.yml +31 -0
- package/.github/workflows/pr-checks.yml +87 -0
- package/.github/workflows/release.yml +33 -0
- package/.vscode/settings.json +12 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE.txt +68 -81
- package/README.md +45 -35
- package/dist/cjs/cli.js +37 -35
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/cli_utils.d.ts +3 -15
- package/dist/cjs/cli_utils.d.ts.map +1 -1
- package/dist/cjs/cli_utils.js +9 -42
- package/dist/cjs/cli_utils.js.map +1 -1
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/errors.js +3 -3
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/shrink.d.ts.map +1 -1
- package/dist/cjs/shrink.js +26 -27
- package/dist/cjs/shrink.js.map +1 -1
- package/dist/cjs/shrink_file.d.ts +1 -1
- package/dist/cjs/shrink_file.d.ts.map +1 -1
- package/dist/cjs/shrink_file.js.map +1 -1
- package/dist/cjs/validate.d.ts.map +1 -1
- package/dist/cjs/validate.js.map +1 -1
- package/dist/esm/cli.js +40 -38
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/cli_utils.d.ts +3 -15
- package/dist/esm/cli_utils.d.ts.map +1 -1
- package/dist/esm/cli_utils.js +9 -41
- package/dist/esm/cli_utils.js.map +1 -1
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +3 -3
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/shrink.d.ts.map +1 -1
- package/dist/esm/shrink.js +26 -27
- package/dist/esm/shrink.js.map +1 -1
- package/dist/esm/shrink_file.d.ts +1 -1
- package/dist/esm/shrink_file.d.ts.map +1 -1
- package/dist/esm/shrink_file.js +1 -1
- package/dist/esm/shrink_file.js.map +1 -1
- package/dist/esm/validate.d.ts.map +1 -1
- package/dist/esm/validate.js +1 -1
- package/dist/esm/validate.js.map +1 -1
- package/package.json +74 -5
- package/src/cli.ts +54 -46
- package/src/cli_utils.test.ts +20 -58
- package/src/cli_utils.ts +21 -55
- package/src/errors.ts +14 -10
- package/src/index.ts +3 -4
- package/src/shrink.test.ts +270 -270
- package/src/shrink.ts +164 -132
- package/src/shrink_file.test.ts +4 -4
- package/src/shrink_file.ts +14 -10
- package/src/validate.test.ts +19 -21
- package/src/validate.ts +15 -12
- package/dist/cjs/stdin.d.ts +0 -7
- package/dist/cjs/stdin.d.ts.map +0 -1
- package/dist/cjs/stdin.js +0 -36
- package/dist/cjs/stdin.js.map +0 -1
- package/dist/esm/stdin.d.ts +0 -7
- package/dist/esm/stdin.d.ts.map +0 -1
- package/dist/esm/stdin.js +0 -33
- package/dist/esm/stdin.js.map +0 -1
- package/src/stdin.ts +0 -36
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: GuardDog
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
guarddog:
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
name: Scan Dependencies and Source Code
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: '3.10'
|
|
26
|
+
|
|
27
|
+
- name: Install GuardDog
|
|
28
|
+
run: pip install guarddog
|
|
29
|
+
|
|
30
|
+
- run: guarddog npm scan src/ --exit-non-zero-on-finding
|
|
31
|
+
- run: guarddog npm verify package.json --exclude-rules empty_information --exit-non-zero-on-finding
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
name: 'Lint PR'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- edited
|
|
8
|
+
- synchronize
|
|
9
|
+
- reopened
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
main:
|
|
16
|
+
name: Validate PR title
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: amannn/action-semantic-pull-request@v5
|
|
20
|
+
env:
|
|
21
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
22
|
+
|
|
23
|
+
lint:
|
|
24
|
+
name: Code Formatting Check
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- name: Check out the repository
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
ref: ${{ github.event.pull_request.head.sha }}
|
|
31
|
+
|
|
32
|
+
- name: Set up Node
|
|
33
|
+
uses: actions/setup-node@v4
|
|
34
|
+
with:
|
|
35
|
+
node-version: '22'
|
|
36
|
+
|
|
37
|
+
- name: Install dependencies
|
|
38
|
+
run: npm ci
|
|
39
|
+
|
|
40
|
+
- name: Check Code Formatting
|
|
41
|
+
run: npm run format-check
|
|
42
|
+
|
|
43
|
+
test:
|
|
44
|
+
name: Build and Test
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
steps:
|
|
47
|
+
- name: Check out the repository
|
|
48
|
+
uses: actions/checkout@v4
|
|
49
|
+
with:
|
|
50
|
+
ref: ${{ github.event.pull_request.head.sha }}
|
|
51
|
+
|
|
52
|
+
- name: Set up Node
|
|
53
|
+
uses: actions/setup-node@v4
|
|
54
|
+
with:
|
|
55
|
+
node-version: '22'
|
|
56
|
+
|
|
57
|
+
- name: Install dependencies
|
|
58
|
+
run: npm ci
|
|
59
|
+
|
|
60
|
+
- name: Build
|
|
61
|
+
run: npm run build
|
|
62
|
+
|
|
63
|
+
- name: Check Tests
|
|
64
|
+
run: npm test
|
|
65
|
+
|
|
66
|
+
guarddog:
|
|
67
|
+
permissions:
|
|
68
|
+
contents: read
|
|
69
|
+
name: GuardDog Check
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
|
|
72
|
+
steps:
|
|
73
|
+
- name: Check out the repository
|
|
74
|
+
uses: actions/checkout@v4
|
|
75
|
+
with:
|
|
76
|
+
ref: ${{ github.event.pull_request.head.sha }}
|
|
77
|
+
|
|
78
|
+
- name: Set up Python
|
|
79
|
+
uses: actions/setup-python@v5
|
|
80
|
+
with:
|
|
81
|
+
python-version: '3.10'
|
|
82
|
+
|
|
83
|
+
- name: Install GuardDog
|
|
84
|
+
run: pip install guarddog
|
|
85
|
+
|
|
86
|
+
- run: guarddog npm scan src/ --exit-non-zero-on-finding
|
|
87
|
+
- run: guarddog npm verify package.json --exclude-rules empty_information --exit-non-zero-on-finding
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
release:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
issues: write
|
|
15
|
+
steps:
|
|
16
|
+
- name: Check out
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Node
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: '22'
|
|
23
|
+
|
|
24
|
+
- name: Run semantic-release
|
|
25
|
+
env:
|
|
26
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
28
|
+
run: |
|
|
29
|
+
npm ci
|
|
30
|
+
npm run format-check
|
|
31
|
+
npm run build
|
|
32
|
+
npm run test
|
|
33
|
+
npx semantic-release
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": true,
|
|
3
|
+
"[javascript]": {
|
|
4
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
5
|
+
},
|
|
6
|
+
"[typescript]": {
|
|
7
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
8
|
+
},
|
|
9
|
+
"[json]": {
|
|
10
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
11
|
+
}
|
|
12
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## [0.1.5](https://github.com/cloud-copilot/iam-shrink/compare/v0.1.4...v0.1.5) (2025-03-01)
|
|
2
|
+
|
|
3
|
+
## [0.1.4](https://github.com/cloud-copilot/iam-shrink/compare/v0.1.3...v0.1.4) (2025-02-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* switching to @cloud-copilot/cli and updating docs. ([ba73f09](https://github.com/cloud-copilot/iam-shrink/commit/ba73f09d74e6800a1cdea4ce54715e4c473ae428))
|
package/LICENSE.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
GNU GENERAL PUBLIC LICENSE
|
|
2
|
-
Version 3,
|
|
1
|
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 19 November 2007
|
|
3
3
|
|
|
4
4
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
5
|
Everyone is permitted to copy and distribute verbatim copies
|
|
@@ -7,17 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
Preamble
|
|
9
9
|
|
|
10
|
-
The GNU General Public License is a free, copyleft license for
|
|
11
|
-
software and other kinds of works
|
|
10
|
+
The GNU Affero General Public License is a free, copyleft license for
|
|
11
|
+
software and other kinds of works, specifically designed to ensure
|
|
12
|
+
cooperation with the community in the case of network server software.
|
|
12
13
|
|
|
13
14
|
The licenses for most software and other practical works are designed
|
|
14
15
|
to take away your freedom to share and change the works. By contrast,
|
|
15
|
-
|
|
16
|
+
our General Public Licenses are intended to guarantee your freedom to
|
|
16
17
|
share and change all versions of a program--to make sure it remains free
|
|
17
|
-
software for all its users.
|
|
18
|
-
GNU General Public License for most of our software; it applies also to
|
|
19
|
-
any other work released this way by its authors. You can apply it to
|
|
20
|
-
your programs, too.
|
|
18
|
+
software for all its users.
|
|
21
19
|
|
|
22
20
|
When we speak of free software, we are referring to freedom, not
|
|
23
21
|
price. Our General Public Licenses are designed to make sure that you
|
|
@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
|
|
|
26
24
|
want it, that you can change the software or use pieces of it in new
|
|
27
25
|
free programs, and that you know you can do these things.
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
that
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
products. If such problems arise substantially in other domains, we
|
|
58
|
-
stand ready to extend this provision to those domains in future versions
|
|
59
|
-
of the GPL, as needed to protect the freedom of users.
|
|
60
|
-
|
|
61
|
-
Finally, every program is threatened constantly by software patents.
|
|
62
|
-
States should not allow patents to restrict development and use of
|
|
63
|
-
software on general-purpose computers, but in those that do, we wish to
|
|
64
|
-
avoid the special danger that patents applied to a free program could
|
|
65
|
-
make it effectively proprietary. To prevent this, the GPL assures that
|
|
66
|
-
patents cannot be used to render the program non-free.
|
|
27
|
+
Developers that use our General Public Licenses protect your rights
|
|
28
|
+
with two steps: (1) assert copyright on the software, and (2) offer
|
|
29
|
+
you this License which gives you legal permission to copy, distribute
|
|
30
|
+
and/or modify the software.
|
|
31
|
+
|
|
32
|
+
A secondary benefit of defending all users' freedom is that
|
|
33
|
+
improvements made in alternate versions of the program, if they
|
|
34
|
+
receive widespread use, become available for other developers to
|
|
35
|
+
incorporate. Many developers of free software are heartened and
|
|
36
|
+
encouraged by the resulting cooperation. However, in the case of
|
|
37
|
+
software used on network servers, this result may fail to come about.
|
|
38
|
+
The GNU General Public License permits making a modified version and
|
|
39
|
+
letting the public access it on a server without ever releasing its
|
|
40
|
+
source code to the public.
|
|
41
|
+
|
|
42
|
+
The GNU Affero General Public License is designed specifically to
|
|
43
|
+
ensure that, in such cases, the modified source code becomes available
|
|
44
|
+
to the community. It requires the operator of a network server to
|
|
45
|
+
provide the source code of the modified version running there to the
|
|
46
|
+
users of that server. Therefore, public use of a modified version, on
|
|
47
|
+
a publicly accessible server, gives the public access to the source
|
|
48
|
+
code of the modified version.
|
|
49
|
+
|
|
50
|
+
An older license, called the Affero General Public License and
|
|
51
|
+
published by Affero, was designed to accomplish similar goals. This is
|
|
52
|
+
a different license, not a version of the Affero GPL, but Affero has
|
|
53
|
+
released a new version of the Affero GPL which permits relicensing under
|
|
54
|
+
this license.
|
|
67
55
|
|
|
68
56
|
The precise terms and conditions for copying, distribution and
|
|
69
57
|
modification follow.
|
|
@@ -72,7 +60,7 @@ modification follow.
|
|
|
72
60
|
|
|
73
61
|
0. Definitions.
|
|
74
62
|
|
|
75
|
-
"This License" refers to version 3 of the GNU General Public License.
|
|
63
|
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
|
76
64
|
|
|
77
65
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
78
66
|
works, such as semiconductor masks.
|
|
@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
|
|
|
549
537
|
the Program, the only way you could satisfy both those terms and this
|
|
550
538
|
License would be to refrain entirely from conveying the Program.
|
|
551
539
|
|
|
552
|
-
13. Use with the GNU
|
|
540
|
+
13. Remote Network Interaction; Use with the GNU General Public License.
|
|
541
|
+
|
|
542
|
+
Notwithstanding any other provision of this License, if you modify the
|
|
543
|
+
Program, your modified version must prominently offer all users
|
|
544
|
+
interacting with it remotely through a computer network (if your version
|
|
545
|
+
supports such interaction) an opportunity to receive the Corresponding
|
|
546
|
+
Source of your version by providing access to the Corresponding Source
|
|
547
|
+
from a network server at no charge, through some standard or customary
|
|
548
|
+
means of facilitating copying of software. This Corresponding Source
|
|
549
|
+
shall include the Corresponding Source for any work covered by version 3
|
|
550
|
+
of the GNU General Public License that is incorporated pursuant to the
|
|
551
|
+
following paragraph.
|
|
553
552
|
|
|
554
553
|
Notwithstanding any other provision of this License, you have
|
|
555
554
|
permission to link or combine any covered work with a work licensed
|
|
556
|
-
under version 3 of the GNU
|
|
555
|
+
under version 3 of the GNU General Public License into a single
|
|
557
556
|
combined work, and to convey the resulting work. The terms of this
|
|
558
557
|
License will continue to apply to the part which is the covered work,
|
|
559
|
-
but the
|
|
560
|
-
|
|
561
|
-
combination as such.
|
|
558
|
+
but the work with which it is combined will remain governed by version
|
|
559
|
+
3 of the GNU General Public License.
|
|
562
560
|
|
|
563
561
|
14. Revised Versions of this License.
|
|
564
562
|
|
|
565
563
|
The Free Software Foundation may publish revised and/or new versions of
|
|
566
|
-
the GNU General Public License from time to time. Such new versions
|
|
567
|
-
be similar in spirit to the present version, but may differ in detail to
|
|
564
|
+
the GNU Affero General Public License from time to time. Such new versions
|
|
565
|
+
will be similar in spirit to the present version, but may differ in detail to
|
|
568
566
|
address new problems or concerns.
|
|
569
567
|
|
|
570
568
|
Each version is given a distinguishing version number. If the
|
|
571
|
-
Program specifies that a certain numbered version of the GNU General
|
|
569
|
+
Program specifies that a certain numbered version of the GNU Affero General
|
|
572
570
|
Public License "or any later version" applies to it, you have the
|
|
573
571
|
option of following the terms and conditions either of that numbered
|
|
574
572
|
version or of any later version published by the Free Software
|
|
575
573
|
Foundation. If the Program does not specify a version number of the
|
|
576
|
-
GNU General Public License, you may choose any version ever published
|
|
574
|
+
GNU Affero General Public License, you may choose any version ever published
|
|
577
575
|
by the Free Software Foundation.
|
|
578
576
|
|
|
579
577
|
If the Program specifies that a proxy can decide which future
|
|
580
|
-
versions of the GNU General Public License can be used, that proxy's
|
|
578
|
+
versions of the GNU Affero General Public License can be used, that proxy's
|
|
581
579
|
public statement of acceptance of a version permanently authorizes you
|
|
582
580
|
to choose that version for the Program.
|
|
583
581
|
|
|
@@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
|
|
|
635
633
|
Copyright (C) <year> <name of author>
|
|
636
634
|
|
|
637
635
|
This program is free software: you can redistribute it and/or modify
|
|
638
|
-
it under the terms of the GNU General Public License as published by
|
|
636
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
639
637
|
the Free Software Foundation, either version 3 of the License, or
|
|
640
638
|
(at your option) any later version.
|
|
641
639
|
|
|
642
640
|
This program is distributed in the hope that it will be useful,
|
|
643
641
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
644
642
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
645
|
-
GNU General Public License for more details.
|
|
643
|
+
GNU Affero General Public License for more details.
|
|
646
644
|
|
|
647
|
-
You should have received a copy of the GNU General Public License
|
|
645
|
+
You should have received a copy of the GNU Affero General Public License
|
|
648
646
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
649
647
|
|
|
650
648
|
Also add information on how to contact you by electronic and paper mail.
|
|
651
649
|
|
|
652
|
-
If
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
661
|
-
parts of the General Public License. Of course, your program's commands
|
|
662
|
-
might be different; for a GUI interface, you would use an "about box".
|
|
650
|
+
If your software can interact with users remotely through a computer
|
|
651
|
+
network, you should also make sure that it provides a way for users to
|
|
652
|
+
get its source. For example, if your program is a web application, its
|
|
653
|
+
interface could display a "Source" link that leads users to an archive
|
|
654
|
+
of the code. There are many ways you could offer source, and different
|
|
655
|
+
solutions will be better for different programs; see section 13 for the
|
|
656
|
+
specific requirements.
|
|
663
657
|
|
|
664
658
|
You should also get your employer (if you work as a programmer) or school,
|
|
665
659
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
666
|
-
For more information on this, and how to apply and follow the GNU
|
|
667
|
-
<https://www.gnu.org/licenses/>.
|
|
668
|
-
|
|
669
|
-
The GNU General Public License does not permit incorporating your program
|
|
670
|
-
into proprietary programs. If your program is a subroutine library, you
|
|
671
|
-
may consider it more useful to permit linking proprietary applications with
|
|
672
|
-
the library. If this is what you want to do, use the GNU Lesser General
|
|
673
|
-
Public License instead of this License. But first, please read
|
|
674
|
-
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
660
|
+
For more information on this, and how to apply and follow the GNU AGPL, see
|
|
661
|
+
<https://www.gnu.org/licenses/>.
|
package/README.md
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
# Shrink IAM Actions
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@cloud-copilot/iam-shrink) [](LICENSE.txt) [](https://github.com/cloud-copilot/iam-shrink/actions/workflows/guarddog.yml) [](https://snyk.io/test/github/cloud-copilot/iam-shrink?targetFile=package.json)
|
|
4
|
+
|
|
3
5
|
Built in the Unix philosophy, this is a small tool with two goals:
|
|
6
|
+
|
|
4
7
|
1. Shrink IAM actions lists by creating patterns that match only the actions specified and no others.
|
|
5
8
|
2. Do #1 in a way that won't make your coworkers hate you.
|
|
6
9
|
|
|
7
10
|
Using Action Wildcards is not recommended, sometimes there are [IAM Limits](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html) you can't get around. This tool helps you stay within those limits.
|
|
8
11
|
|
|
9
12
|
## Getting Small While Staying Sane
|
|
13
|
+
|
|
10
14
|
IAM Actions are camel cased into a number of words. For example:
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
|
|
16
|
+
- `s3:GetObject` -> "Get" "Object"
|
|
17
|
+
- `s3:GetObjectTagging` -> "Get" "Object" "Tagging"
|
|
13
18
|
|
|
14
19
|
IAM Shrink will only replace one word at a time and will never replace part of a word. So for instance `s3:GetObject` will never get shrunk to something like `s3:*et*`. This is to balance size reduction with readability.
|
|
15
20
|
|
|
16
21
|
## Use in Browser
|
|
22
|
+
|
|
17
23
|
[https://iam.cloudcopilot.io/tools/iam-shrink](https://iam.cloudcopilot.io/tools/iam-shrink)
|
|
18
24
|
|
|
19
25
|
## Use in CLI
|
|
20
26
|
|
|
21
27
|
### Installation
|
|
28
|
+
|
|
22
29
|
You can install it globally. This also works in the default AWS CloudShell!
|
|
30
|
+
|
|
23
31
|
```bash
|
|
24
32
|
npm install -g @cloud-copilot/iam-shrink
|
|
25
33
|
```
|
|
26
|
-
|
|
34
|
+
|
|
35
|
+
_Depending on your configuration sudo may be required to install globally._
|
|
27
36
|
|
|
28
37
|
### Help
|
|
29
38
|
|
|
@@ -34,7 +43,8 @@ iam-shrink --help
|
|
|
34
43
|
### Shrink IAM Actions
|
|
35
44
|
|
|
36
45
|
#### Pass in Argument
|
|
37
|
-
|
|
46
|
+
|
|
47
|
+
It's unlikely that you will pass in on the CLI a number of actions after the command name, but you can. You'll need a large number of actions for it to be practical, so it's mostly for automation.
|
|
38
48
|
|
|
39
49
|
```bash
|
|
40
50
|
Usage: iam-shrink s3:GetBucketTagging s3:GetJobTagging s3:GetObjectTagging s3:GetObjectVersionTagging s3:GetStorageLensConfigurationTagging
|
|
@@ -43,6 +53,7 @@ s3:Get*Tagging
|
|
|
43
53
|
```
|
|
44
54
|
|
|
45
55
|
#### Read from stdin
|
|
56
|
+
|
|
46
57
|
If no actions are passed as arguments, the CLI will read from stdin.
|
|
47
58
|
|
|
48
59
|
```bash
|
|
@@ -52,9 +63,11 @@ s3:Get*Tagging
|
|
|
52
63
|
```
|
|
53
64
|
|
|
54
65
|
#### Shrink JSON input
|
|
66
|
+
|
|
55
67
|
If the input is a valid json document, the CLI will find every instance of `Action` and `NotAction` that is an array of strings and shrink them.
|
|
56
68
|
|
|
57
69
|
Given `policy.json`
|
|
70
|
+
|
|
58
71
|
```json
|
|
59
72
|
{
|
|
60
73
|
"Version": "2012-10-17",
|
|
@@ -104,25 +117,19 @@ cat policy.json | iam-shrink > smaller-policy.json
|
|
|
104
117
|
```
|
|
105
118
|
|
|
106
119
|
Gives this file in `smaller-policy.json`
|
|
120
|
+
|
|
107
121
|
```json
|
|
108
122
|
{
|
|
109
123
|
"Version": "2012-10-17",
|
|
110
124
|
"Statement": [
|
|
111
125
|
{
|
|
112
126
|
"Effect": "Allow",
|
|
113
|
-
"Action": [
|
|
114
|
-
"groundstation:List*",
|
|
115
|
-
"groundstation:Get*",
|
|
116
|
-
"s3:Get*Tagging"
|
|
117
|
-
],
|
|
127
|
+
"Action": ["groundstation:List*", "groundstation:Get*", "s3:Get*Tagging"],
|
|
118
128
|
"Resource": "*"
|
|
119
129
|
},
|
|
120
130
|
{
|
|
121
131
|
"Effect": "Deny",
|
|
122
|
-
"NotAction": [
|
|
123
|
-
"organizations:Delete*",
|
|
124
|
-
"organizations:Leave*"
|
|
125
|
-
],
|
|
132
|
+
"NotAction": ["organizations:Delete*", "organizations:Leave*"],
|
|
126
133
|
"Resource": "*"
|
|
127
134
|
}
|
|
128
135
|
]
|
|
@@ -130,11 +137,12 @@ Gives this file in `smaller-policy.json`
|
|
|
130
137
|
```
|
|
131
138
|
|
|
132
139
|
### Configuring iterations
|
|
140
|
+
|
|
133
141
|
By default, the CLI will do two iterations of shrinking. This generally does a good balance between reducing size and maintaining readability. This can be adjusted with the `--iterations` flag.
|
|
134
142
|
|
|
135
143
|
Assuming the [AWS Read Only policy](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/ReadOnlyAccess.html) is in `readonly.json`
|
|
136
144
|
|
|
137
|
-
|
|
145
|
+
````bash
|
|
138
146
|
You can change this with the `--iterations` flag.
|
|
139
147
|
|
|
140
148
|
```bash
|
|
@@ -143,45 +151,47 @@ cat readonly.json | iam-shrink | wc -m
|
|
|
143
151
|
# 61305 characters
|
|
144
152
|
|
|
145
153
|
# Increasing iterations
|
|
146
|
-
cat readonly.json | iam-shrink --iterations
|
|
154
|
+
cat readonly.json | iam-shrink --iterations 3 | wc -m
|
|
147
155
|
# 45983 characters
|
|
148
|
-
cat readonly.json | iam-shrink --iterations
|
|
156
|
+
cat readonly.json | iam-shrink --iterations 4 | wc -m
|
|
149
157
|
# 43654 characters
|
|
150
|
-
cat readonly.json | iam-shrink --iterations
|
|
158
|
+
cat readonly.json | iam-shrink --iterations 5 | wc -m
|
|
151
159
|
# 43336 characters
|
|
152
160
|
|
|
153
161
|
# Unlimited iterations until the policy cannot be further reduced
|
|
154
|
-
cat readonly.json | iam-shrink --iterations
|
|
162
|
+
cat readonly.json | iam-shrink --iterations 0 | wc -m
|
|
155
163
|
# 43281 characters
|
|
156
|
-
|
|
164
|
+
````
|
|
157
165
|
|
|
158
|
-
If you want to shrink the policy as much as possible, you can use `--iterations
|
|
166
|
+
If you want to shrink the policy as much as possible, you can use `--iterations 0`. This will keep shrinking the policy until it can't be reduced any further.
|
|
159
167
|
|
|
160
168
|
## Use in TypeScript/Node
|
|
161
169
|
|
|
162
170
|
You can use the shrink function in your own code.
|
|
171
|
+
|
|
163
172
|
```typescript
|
|
164
|
-
import { shrink } from '@cloud-copilot/iam-shrink'
|
|
173
|
+
import { shrink } from '@cloud-copilot/iam-shrink'
|
|
165
174
|
|
|
166
175
|
const actions = [
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
]
|
|
173
|
-
|
|
174
|
-
const shrunk = await shrink(actions)
|
|
175
|
-
console.log(shrunk)
|
|
176
|
+
's3:GetBucketTagging',
|
|
177
|
+
's3:GetJobTagging',
|
|
178
|
+
's3:GetObjectTagging',
|
|
179
|
+
's3:GetObjectVersionTagging',
|
|
180
|
+
's3:GetStorageLensConfigurationTagging'
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
const shrunk = await shrink(actions)
|
|
184
|
+
console.log(shrunk)
|
|
176
185
|
// [ s3:Get*Tagging ]
|
|
177
186
|
```
|
|
178
187
|
|
|
179
188
|
You can specify the number of iterations as well.
|
|
189
|
+
|
|
180
190
|
```typescript
|
|
181
|
-
import { shrink } from '@cloud-copilot/iam-shrink'
|
|
191
|
+
import { shrink } from '@cloud-copilot/iam-shrink'
|
|
182
192
|
|
|
183
|
-
const bigListOfActions = getBigListOfActions()
|
|
193
|
+
const bigListOfActions = getBigListOfActions()
|
|
184
194
|
|
|
185
|
-
const smallerList = await shrink(bigListOfActions, { iterations: 3 })
|
|
186
|
-
console.log(shrunk)
|
|
187
|
-
```
|
|
195
|
+
const smallerList = await shrink(bigListOfActions, { iterations: 3 })
|
|
196
|
+
console.log(shrunk)
|
|
197
|
+
```
|