iam-floyd 0.847.0 → 0.848.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/.markdownlint-cli2.yaml +12 -0
- package/.prettierignore +4 -0
- package/.yamllint.yaml +13 -0
- package/AGENTS.md +44 -14
- package/README.md +8 -7
- package/doc8.ini +3 -0
- package/eslint.config.mjs +122 -0
- package/lib/collection/allowEc2InstanceDeleteByOwner.d.ts +2 -2
- package/lib/collection/allowEc2InstanceDeleteByOwner.js +3 -3
- package/lib/collection/index.d.ts +2 -1
- package/lib/shared/compact.d.ts +12 -0
- package/lib/shared/compact.js +121 -0
- package/lib/shared/policy-statement/1-base.d.ts +0 -6
- package/lib/shared/policy-statement/1-base.js +0 -7
- package/lib/shared/policy-statement/10-final.d.ts +0 -1
- package/lib/shared/policy-statement/10-final.js +24 -5
- package/lib/shared/policy-statement/2-conditions.d.ts +0 -10
- package/lib/shared/policy-statement/2-conditions.js +9 -70
- package/lib/shared/policy-statement/3-actions.d.ts +7 -9
- package/lib/shared/policy-statement/3-actions.js +61 -109
- package/lib/shared/policy-statement/4-resources.d.ts +4 -10
- package/lib/shared/policy-statement/4-resources.js +2 -44
- package/lib/shared/policy-statement/5-effect.d.ts +0 -6
- package/lib/shared/policy-statement/5-effect.js +0 -8
- package/lib/shared/policy-statement/8-principals.d.ts +0 -9
- package/lib/shared/policy-statement/8-principals.js +0 -23
- package/lint/checkstyle-suppressions.xml +9 -0
- package/lint/go.mod +28 -0
- package/lint/go.sum +45 -0
- package/lint/pom.xml +41 -0
- package/lint/requirements.txt +6 -0
- package/package.json +16 -26
- package/python/iam_floyd/__init__.py +42 -0
- package/python/iam_floyd/_js.py +104 -0
- package/python/iam_floyd/py.typed +0 -0
- package/python/pyproject.toml +39 -0
- package/ruff.toml +11 -0
- package/skills/iam-floyd-usage/SKILL.md +4 -3
- package/.eslintrc +0 -31
|
@@ -7,58 +7,18 @@ class PolicyStatementWithCondition extends _1_base_1.PolicyStatementBase {
|
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
9
9
|
this.floydConditions = {};
|
|
10
|
-
this.cdkConditionsApplied = false;
|
|
11
|
-
}
|
|
12
|
-
toJSON() {
|
|
13
|
-
if (typeof this.addResources == 'function') {
|
|
14
|
-
this.cdkApplyConditions();
|
|
15
|
-
return super.toJSON();
|
|
16
|
-
}
|
|
17
|
-
const statement = super.toJSON();
|
|
18
|
-
if (this.hasConditions()) {
|
|
19
|
-
statement.Condition = this.floydConditions;
|
|
20
|
-
}
|
|
21
|
-
return statement;
|
|
22
|
-
}
|
|
23
|
-
toStatementJson() {
|
|
24
|
-
this.cdkApplyConditions();
|
|
25
|
-
return super.toStatementJson();
|
|
26
|
-
}
|
|
27
|
-
freeze() {
|
|
28
|
-
if (!this.frozen) {
|
|
29
|
-
this.cdkApplyConditions();
|
|
30
|
-
}
|
|
31
|
-
return super.freeze();
|
|
32
|
-
}
|
|
33
|
-
cdkApplyConditions() {
|
|
34
|
-
if (this.hasConditions() && !this.cdkConditionsApplied) {
|
|
35
|
-
Object.keys(this.floydConditions).forEach((operator) => {
|
|
36
|
-
Object.keys(this.floydConditions[operator]).forEach((key) => {
|
|
37
|
-
const condition = {};
|
|
38
|
-
condition[key] = this.floydConditions[operator][key];
|
|
39
|
-
this.addCondition(operator, condition);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
this.cdkConditionsApplied = true;
|
|
43
|
-
}
|
|
44
10
|
}
|
|
45
11
|
hasConditions() {
|
|
46
12
|
return Object.keys(this.floydConditions).length > 0;
|
|
47
13
|
}
|
|
48
14
|
if(key, value, operator) {
|
|
49
|
-
if (this.servicePrefix.length && key.
|
|
15
|
+
if (this.servicePrefix.length && !key.includes(':')) {
|
|
50
16
|
key = `${this.servicePrefix}:${key}`;
|
|
51
17
|
}
|
|
52
18
|
if (typeof operator === 'undefined') {
|
|
53
19
|
operator = operators_1.Operator.stringLike;
|
|
54
20
|
}
|
|
55
|
-
|
|
56
|
-
if (typeof operator === 'string') {
|
|
57
|
-
op = operator;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
op = operator.toString();
|
|
61
|
-
}
|
|
21
|
+
const op = typeof operator === 'string' ? operator : operator.toString();
|
|
62
22
|
if (['boolean', 'number'].includes(typeof value)) {
|
|
63
23
|
value = value.toString();
|
|
64
24
|
}
|
|
@@ -78,18 +38,9 @@ class PolicyStatementWithCondition extends _1_base_1.PolicyStatementBase {
|
|
|
78
38
|
return this.if('aws:CalledViaLast', value, operator);
|
|
79
39
|
}
|
|
80
40
|
ifAwsCurrentTime(value, operator) {
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
else if (Array.isArray(value)) {
|
|
85
|
-
value = value.map((item) => {
|
|
86
|
-
if (typeof item.getMonth === 'function') {
|
|
87
|
-
item = item.toISOString();
|
|
88
|
-
}
|
|
89
|
-
return item;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return this.if('aws:CurrentTime', value, operator ?? operators_1.Operator.dateLessThanEquals);
|
|
41
|
+
return this.if('aws:CurrentTime', Array.isArray(value)
|
|
42
|
+
? value.map((item) => dateToString(item))
|
|
43
|
+
: dateToString(value), operator ?? operators_1.Operator.dateLessThanEquals);
|
|
93
44
|
}
|
|
94
45
|
ifAwsEc2InstanceSourceVpc(value, operator) {
|
|
95
46
|
return this.if('aws:Ec2InstanceSourceVpc', value, operator);
|
|
@@ -98,18 +49,9 @@ class PolicyStatementWithCondition extends _1_base_1.PolicyStatementBase {
|
|
|
98
49
|
return this.if('aws:Ec2InstanceSourcePrivateIPv4', value, operator ?? operators_1.Operator.ipAddress);
|
|
99
50
|
}
|
|
100
51
|
ifAwsEpochTime(value, operator) {
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
else if (Array.isArray(value)) {
|
|
105
|
-
value = value.map((item) => {
|
|
106
|
-
if (typeof item.getMonth === 'function') {
|
|
107
|
-
item = item.toISOString();
|
|
108
|
-
}
|
|
109
|
-
return item;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return this.if('aws:EpochTime', value, operator ?? operators_1.Operator.dateLessThanEquals);
|
|
52
|
+
return this.if('aws:EpochTime', Array.isArray(value)
|
|
53
|
+
? value.map((item) => dateToString(item))
|
|
54
|
+
: dateToString(value), operator ?? operators_1.Operator.dateLessThanEquals);
|
|
113
55
|
}
|
|
114
56
|
ifAwsFederatedProvider(value, operator) {
|
|
115
57
|
return this.if('aws:FederatedProvider', value, operator);
|
|
@@ -213,8 +155,5 @@ class PolicyStatementWithCondition extends _1_base_1.PolicyStatementBase {
|
|
|
213
155
|
}
|
|
214
156
|
exports.PolicyStatementWithCondition = PolicyStatementWithCondition;
|
|
215
157
|
function dateToString(value) {
|
|
216
|
-
|
|
217
|
-
value = value.toISOString();
|
|
218
|
-
}
|
|
219
|
-
return value;
|
|
158
|
+
return value instanceof Date ? value.toISOString() : value;
|
|
220
159
|
}
|
|
@@ -13,19 +13,13 @@ export interface Action {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class PolicyStatementWithActions extends PolicyStatementWithCondition {
|
|
15
15
|
protected accessLevelList: AccessLevelList;
|
|
16
|
-
|
|
16
|
+
protected useNotAction: boolean;
|
|
17
17
|
protected floydActions: string[];
|
|
18
|
-
private cdkActionsApplied;
|
|
19
18
|
private isCompact;
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* Only relevant for the main package. In CDK mode this only calls super.
|
|
20
|
+
* The actions of the statement, compacted if `compact()` was called, without duplicates and sorted
|
|
24
21
|
*/
|
|
25
|
-
|
|
26
|
-
toStatementJson(): any;
|
|
27
|
-
freeze(): any;
|
|
28
|
-
private cdkApplyActions;
|
|
22
|
+
protected uniqueActions(): string[];
|
|
29
23
|
/**
|
|
30
24
|
* Switches the statement to use [`NotAction`](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_notaction.html).
|
|
31
25
|
*/
|
|
@@ -58,6 +52,7 @@ export declare class PolicyStatementWithActions extends PolicyStatementWithCondi
|
|
|
58
52
|
* ```typescript
|
|
59
53
|
* allMatchingActions('/vpn/i')
|
|
60
54
|
* ```
|
|
55
|
+
* Of the flags, only `i` (ignore case) and `y` (match at the start of the action name) have an effect, others are ignored. Without `i`, the match is case-sensitive. A string without slashes is used as the pattern itself.
|
|
61
56
|
*/
|
|
62
57
|
allMatchingActions(...expressions: string[]): this;
|
|
63
58
|
/**
|
|
@@ -113,5 +108,8 @@ export declare class PolicyStatementWithActions extends PolicyStatementWithCondi
|
|
|
113
108
|
* For example, all actions with access level `list` could be reduced to a small pattern `List*`.
|
|
114
109
|
*/
|
|
115
110
|
compact(): this;
|
|
111
|
+
/**
|
|
112
|
+
* Replaces the actions of this service by wildcard patterns. Other actions, like `ec2:*` or actions of other services, are kept as they are.
|
|
113
|
+
*/
|
|
116
114
|
private compactActions;
|
|
117
115
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PolicyStatementWithActions = void 0;
|
|
4
|
-
const common_substrings_1 = require("@udondan/common-substrings");
|
|
5
|
-
const RegexParser = require("regex-parser");
|
|
6
4
|
const access_level_1 = require("../access-level");
|
|
5
|
+
const compact_1 = require("../compact");
|
|
7
6
|
const _2_conditions_1 = require("./2-conditions");
|
|
8
7
|
class PolicyStatementWithActions extends _2_conditions_1.PolicyStatementWithCondition {
|
|
9
8
|
constructor() {
|
|
@@ -11,55 +10,15 @@ class PolicyStatementWithActions extends _2_conditions_1.PolicyStatementWithCond
|
|
|
11
10
|
this.accessLevelList = {};
|
|
12
11
|
this.useNotAction = false;
|
|
13
12
|
this.floydActions = [];
|
|
14
|
-
this.cdkActionsApplied = false;
|
|
15
13
|
this.isCompact = false;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
this.
|
|
20
|
-
return super.toJSON();
|
|
15
|
+
uniqueActions() {
|
|
16
|
+
if (this.isCompact) {
|
|
17
|
+
this.compactActions();
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (this.hasActions()) {
|
|
26
|
-
if (this.isCompact) {
|
|
27
|
-
this.compactActions();
|
|
28
|
-
}
|
|
29
|
-
const actions = this.floydActions
|
|
30
|
-
.filter((elem, pos) => {
|
|
31
|
-
return self.floydActions.indexOf(elem) == pos;
|
|
32
|
-
})
|
|
33
|
-
.sort();
|
|
34
|
-
statement[mode] = actions.length > 1 ? actions : actions[0];
|
|
35
|
-
}
|
|
36
|
-
return statement;
|
|
37
|
-
}
|
|
38
|
-
toStatementJson() {
|
|
39
|
-
this.cdkApplyActions();
|
|
40
|
-
return super.toStatementJson();
|
|
41
|
-
}
|
|
42
|
-
freeze() {
|
|
43
|
-
if (!this.frozen) {
|
|
44
|
-
this.cdkApplyActions();
|
|
45
|
-
}
|
|
46
|
-
return super.freeze();
|
|
47
|
-
}
|
|
48
|
-
cdkApplyActions() {
|
|
49
|
-
if (!this.cdkActionsApplied) {
|
|
50
|
-
const mode = this.useNotAction ? 'addNotActions' : 'addActions';
|
|
51
|
-
const self = this;
|
|
52
|
-
if (this.isCompact) {
|
|
53
|
-
this.compactActions();
|
|
54
|
-
}
|
|
55
|
-
const uniqueActions = this.floydActions
|
|
56
|
-
.filter((elem, pos) => {
|
|
57
|
-
return self.floydActions.indexOf(elem) == pos;
|
|
58
|
-
})
|
|
59
|
-
.sort();
|
|
60
|
-
this[mode](...uniqueActions);
|
|
61
|
-
}
|
|
62
|
-
this.cdkActionsApplied = true;
|
|
19
|
+
return this.floydActions
|
|
20
|
+
.filter((elem, pos) => this.floydActions.indexOf(elem) == pos)
|
|
21
|
+
.sort();
|
|
63
22
|
}
|
|
64
23
|
notAction() {
|
|
65
24
|
this.useNotAction = true;
|
|
@@ -69,7 +28,7 @@ class PolicyStatementWithActions extends _2_conditions_1.PolicyStatementWithCond
|
|
|
69
28
|
return this.floydActions.length > 0;
|
|
70
29
|
}
|
|
71
30
|
to(action) {
|
|
72
|
-
if (this.servicePrefix.length && action.
|
|
31
|
+
if (this.servicePrefix.length && !action.includes(':')) {
|
|
73
32
|
action = `${this.servicePrefix}:${action}`;
|
|
74
33
|
}
|
|
75
34
|
this.floydActions.push(action);
|
|
@@ -86,9 +45,10 @@ class PolicyStatementWithActions extends _2_conditions_1.PolicyStatementWithCond
|
|
|
86
45
|
}
|
|
87
46
|
allMatchingActions(...expressions) {
|
|
88
47
|
expressions.forEach((expression) => {
|
|
48
|
+
const regex = parseRegex(expression);
|
|
89
49
|
for (const [_, actions] of Object.entries(this.accessLevelList)) {
|
|
90
50
|
actions.forEach((action) => {
|
|
91
|
-
if (
|
|
51
|
+
if (regex.test(action)) {
|
|
92
52
|
this.to(`${this.servicePrefix}:${action}`);
|
|
93
53
|
}
|
|
94
54
|
});
|
|
@@ -112,10 +72,8 @@ class PolicyStatementWithActions extends _2_conditions_1.PolicyStatementWithCond
|
|
|
112
72
|
return this.addAccessLevel(access_level_1.AccessLevel.tagging);
|
|
113
73
|
}
|
|
114
74
|
addAccessLevel(accessLevel) {
|
|
115
|
-
|
|
116
|
-
this.
|
|
117
|
-
this.to(`${this.servicePrefix}:${action}`);
|
|
118
|
-
});
|
|
75
|
+
for (const action of this.accessLevelList[accessLevel] ?? []) {
|
|
76
|
+
this.to(`${this.servicePrefix}:${action}`);
|
|
119
77
|
}
|
|
120
78
|
return this;
|
|
121
79
|
}
|
|
@@ -124,66 +82,60 @@ class PolicyStatementWithActions extends _2_conditions_1.PolicyStatementWithCond
|
|
|
124
82
|
return this;
|
|
125
83
|
}
|
|
126
84
|
compactActions() {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
const excludeActions = [];
|
|
85
|
+
const prefix = `${this.servicePrefix}:`;
|
|
86
|
+
const known = new Set();
|
|
131
87
|
for (const [_, actions] of Object.entries(this.accessLevelList)) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
});
|
|
88
|
+
for (const action of actions) {
|
|
89
|
+
known.add(action);
|
|
90
|
+
}
|
|
137
91
|
}
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (action.includes(sub.name)) {
|
|
148
|
-
return false;
|
|
92
|
+
const selected = [];
|
|
93
|
+
const selectedSet = new Set();
|
|
94
|
+
const kept = [];
|
|
95
|
+
for (const action of this.floydActions) {
|
|
96
|
+
const name = action.substring(prefix.length);
|
|
97
|
+
if (action.startsWith(prefix) && known.has(name)) {
|
|
98
|
+
if (!selectedSet.has(name)) {
|
|
99
|
+
selected.push(name);
|
|
100
|
+
selectedSet.add(name);
|
|
149
101
|
}
|
|
150
102
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
.sort((a, b) => {
|
|
154
|
-
if (a.source.length < b.source.length)
|
|
155
|
-
return 1;
|
|
156
|
-
if (a.source.length > b.source.length)
|
|
157
|
-
return -1;
|
|
158
|
-
return 0;
|
|
159
|
-
})
|
|
160
|
-
.filter((sub) => {
|
|
161
|
-
const sources = sub.source.filter((source) => {
|
|
162
|
-
return !covered.includes(source);
|
|
163
|
-
});
|
|
164
|
-
if (sources.length > 1) {
|
|
165
|
-
covered = covered.concat(sources);
|
|
166
|
-
return true;
|
|
103
|
+
else {
|
|
104
|
+
kept.push(action);
|
|
167
105
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
includeActions
|
|
180
|
-
.filter((action) => {
|
|
181
|
-
return action.length > 0;
|
|
182
|
-
})
|
|
183
|
-
.forEach((action) => {
|
|
184
|
-
compactActionList.push(`${this.servicePrefix}:${action}`);
|
|
185
|
-
});
|
|
186
|
-
this.floydActions = compactActionList;
|
|
106
|
+
}
|
|
107
|
+
const excluded = [];
|
|
108
|
+
for (const name of known) {
|
|
109
|
+
if (!selectedSet.has(name)) {
|
|
110
|
+
excluded.push(name);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const pattern of (0, compact_1.compactActionNames)(selected, excluded)) {
|
|
114
|
+
kept.push(`${prefix}${pattern}`);
|
|
115
|
+
}
|
|
116
|
+
this.floydActions = kept;
|
|
187
117
|
}
|
|
188
118
|
}
|
|
189
119
|
exports.PolicyStatementWithActions = PolicyStatementWithActions;
|
|
120
|
+
function parseRegex(expression) {
|
|
121
|
+
if (expression.length == 0) {
|
|
122
|
+
throw new Error('Invalid regular expression format.');
|
|
123
|
+
}
|
|
124
|
+
let pattern = expression;
|
|
125
|
+
let flags = '';
|
|
126
|
+
const end = expression.lastIndexOf('/');
|
|
127
|
+
if (expression.startsWith('/') && end > 1) {
|
|
128
|
+
pattern = expression.substring(1, end);
|
|
129
|
+
for (let i = end + 1; i < expression.length; i++) {
|
|
130
|
+
const char = expression.substring(i, i + 1);
|
|
131
|
+
if (!'abcdefghijklmnopqrstuvwxyz'.includes(char.toLowerCase())) {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
flags = `${flags}${char}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (flags.includes('y')) {
|
|
138
|
+
pattern = `^(?:${pattern})`;
|
|
139
|
+
}
|
|
140
|
+
return new RegExp(pattern, flags.includes('i') ? 'i' : '');
|
|
141
|
+
}
|
|
@@ -10,19 +10,13 @@ export interface ResourceType {
|
|
|
10
10
|
* Adds "resource" functionality to the Policy Statement
|
|
11
11
|
*/
|
|
12
12
|
export declare class PolicyStatementWithResources extends PolicyStatementWithActions {
|
|
13
|
-
|
|
13
|
+
protected useNotResource: boolean;
|
|
14
14
|
protected floydResources: string[];
|
|
15
15
|
protected skipAutoResource: boolean;
|
|
16
|
-
private cdkResourcesApplied;
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* Only relevant for the main package. In CDK mode this only calls super.
|
|
17
|
+
* The resources of the statement without duplicates
|
|
21
18
|
*/
|
|
22
|
-
|
|
23
|
-
toStatementJson(): any;
|
|
24
|
-
freeze(): any;
|
|
25
|
-
private cdkApplyResources;
|
|
19
|
+
protected uniqueResources(): string[];
|
|
26
20
|
/**
|
|
27
21
|
* Switches the statement to use [`NotResource`](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_notresource.html).
|
|
28
22
|
*/
|
|
@@ -43,5 +37,5 @@ export declare class PolicyStatementWithResources extends PolicyStatementWithAct
|
|
|
43
37
|
* This is the default behavior, unless the statement has principals.
|
|
44
38
|
*/
|
|
45
39
|
onAllResources(): this;
|
|
46
|
-
|
|
40
|
+
protected ensureResource(): void;
|
|
47
41
|
}
|
|
@@ -8,47 +8,9 @@ class PolicyStatementWithResources extends _3_actions_1.PolicyStatementWithActio
|
|
|
8
8
|
this.useNotResource = false;
|
|
9
9
|
this.floydResources = [];
|
|
10
10
|
this.skipAutoResource = false;
|
|
11
|
-
this.cdkResourcesApplied = false;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.cdkApplyResources();
|
|
16
|
-
return super.toJSON();
|
|
17
|
-
}
|
|
18
|
-
const mode = this.useNotResource ? 'NotResource' : 'Resource';
|
|
19
|
-
const statement = super.toJSON();
|
|
20
|
-
const self = this;
|
|
21
|
-
this.ensureResource();
|
|
22
|
-
if (this.floydResources.length) {
|
|
23
|
-
const resources = this.floydResources.filter((elem, pos) => {
|
|
24
|
-
return self.floydResources.indexOf(elem) == pos;
|
|
25
|
-
});
|
|
26
|
-
statement[mode] = resources.length > 1 ? resources : resources[0];
|
|
27
|
-
}
|
|
28
|
-
return statement;
|
|
29
|
-
}
|
|
30
|
-
toStatementJson() {
|
|
31
|
-
this.ensureResource();
|
|
32
|
-
this.cdkApplyResources();
|
|
33
|
-
return super.toStatementJson();
|
|
34
|
-
}
|
|
35
|
-
freeze() {
|
|
36
|
-
if (!this.frozen) {
|
|
37
|
-
this.ensureResource();
|
|
38
|
-
this.cdkApplyResources();
|
|
39
|
-
}
|
|
40
|
-
return super.freeze();
|
|
41
|
-
}
|
|
42
|
-
cdkApplyResources() {
|
|
43
|
-
if (!this.cdkResourcesApplied) {
|
|
44
|
-
const mode = this.useNotResource ? 'addNotResources' : 'addResources';
|
|
45
|
-
const self = this;
|
|
46
|
-
const uniqueResources = this.floydResources.filter((elem, pos) => {
|
|
47
|
-
return self.floydResources.indexOf(elem) == pos;
|
|
48
|
-
});
|
|
49
|
-
this[mode](...uniqueResources);
|
|
50
|
-
this.cdkResourcesApplied = true;
|
|
51
|
-
}
|
|
12
|
+
uniqueResources() {
|
|
13
|
+
return this.floydResources.filter((elem, pos) => this.floydResources.indexOf(elem) == pos);
|
|
52
14
|
}
|
|
53
15
|
notResource() {
|
|
54
16
|
this.useNotResource = true;
|
|
@@ -68,10 +30,6 @@ class PolicyStatementWithResources extends _3_actions_1.PolicyStatementWithActio
|
|
|
68
30
|
ensureResource() {
|
|
69
31
|
if (this.hasResources())
|
|
70
32
|
return;
|
|
71
|
-
if (this.hasResource)
|
|
72
|
-
return;
|
|
73
|
-
if (this.hasPrincipal)
|
|
74
|
-
return;
|
|
75
33
|
if (this.skipAutoResource)
|
|
76
34
|
return;
|
|
77
35
|
this.onAllResources();
|
|
@@ -11,12 +11,6 @@ export declare enum Effect {
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class PolicyStatementWithEffect extends PolicyStatementWithResources {
|
|
13
13
|
effect: Effect;
|
|
14
|
-
/**
|
|
15
|
-
* Injects effect into the statement.
|
|
16
|
-
*
|
|
17
|
-
* Only relevant for the main package. In CDK mode this only calls super.
|
|
18
|
-
*/
|
|
19
|
-
toJSON(): any;
|
|
20
14
|
/**
|
|
21
15
|
* Allow the actions in this statement
|
|
22
16
|
*/
|
|
@@ -12,14 +12,6 @@ class PolicyStatementWithEffect extends _4_resources_1.PolicyStatementWithResour
|
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.effect = Effect.allow;
|
|
14
14
|
}
|
|
15
|
-
toJSON() {
|
|
16
|
-
if (typeof this.addResources == 'function') {
|
|
17
|
-
return super.toJSON();
|
|
18
|
-
}
|
|
19
|
-
const statement = super.toJSON();
|
|
20
|
-
statement.Effect = this.effect;
|
|
21
|
-
return statement;
|
|
22
|
-
}
|
|
23
15
|
allow() {
|
|
24
16
|
this.effect = Effect.allow;
|
|
25
17
|
return this;
|
|
@@ -15,15 +15,6 @@ export declare enum PrincipalType {
|
|
|
15
15
|
export declare class PolicyStatementWithPrincipal extends PolicyStatementWithArnDefaults {
|
|
16
16
|
protected useNotPrincipal: boolean;
|
|
17
17
|
protected myPrincipals: Principals;
|
|
18
|
-
/**
|
|
19
|
-
* Injects principals into the statement.
|
|
20
|
-
*
|
|
21
|
-
* Only relevant for the main package. In CDK mode this only calls super.
|
|
22
|
-
*/
|
|
23
|
-
toJSON(): any;
|
|
24
|
-
toStatementJson(): any;
|
|
25
|
-
freeze(): any;
|
|
26
|
-
protected cdkApplyPrincipals(): void;
|
|
27
18
|
/**
|
|
28
19
|
* Switches the statement to use [`notPrincipal`](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_notprincipal.html).
|
|
29
20
|
*/
|
|
@@ -15,29 +15,6 @@ class PolicyStatementWithPrincipal extends _6_arn_defaults_1.PolicyStatementWith
|
|
|
15
15
|
this.useNotPrincipal = false;
|
|
16
16
|
this.myPrincipals = {};
|
|
17
17
|
}
|
|
18
|
-
toJSON() {
|
|
19
|
-
if (typeof this.addResources == 'function') {
|
|
20
|
-
this.cdkApplyPrincipals();
|
|
21
|
-
return super.toJSON();
|
|
22
|
-
}
|
|
23
|
-
const mode = this.useNotPrincipal ? 'NotPrincipal' : 'Principal';
|
|
24
|
-
const statement = super.toJSON();
|
|
25
|
-
if (this.hasPrincipals()) {
|
|
26
|
-
statement[mode] = this.myPrincipals;
|
|
27
|
-
}
|
|
28
|
-
return statement;
|
|
29
|
-
}
|
|
30
|
-
toStatementJson() {
|
|
31
|
-
this.cdkApplyPrincipals();
|
|
32
|
-
return super.toStatementJson();
|
|
33
|
-
}
|
|
34
|
-
freeze() {
|
|
35
|
-
if (!this.frozen) {
|
|
36
|
-
this.cdkApplyPrincipals();
|
|
37
|
-
}
|
|
38
|
-
return super.freeze();
|
|
39
|
-
}
|
|
40
|
-
cdkApplyPrincipals() { }
|
|
41
18
|
notPrincipal() {
|
|
42
19
|
this.useNotPrincipal = true;
|
|
43
20
|
return this;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<!DOCTYPE suppressions PUBLIC
|
|
3
|
+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
|
4
|
+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
|
5
|
+
<suppressions>
|
|
6
|
+
<!-- The examples are snippets for the docs, which the runners compile without a package -->
|
|
7
|
+
<suppress checks="PackageDeclaration|OuterTypeFilename" files="[\\/]examples[\\/]"/>
|
|
8
|
+
<suppress checks="PackageDeclaration" files="[\\/]Main\.java$"/>
|
|
9
|
+
</suppressions>
|
package/lint/go.mod
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module github.com/udondan/iam-floyd/lint
|
|
2
|
+
|
|
3
|
+
go 1.27.1
|
|
4
|
+
|
|
5
|
+
tool (
|
|
6
|
+
github.com/rhysd/actionlint/cmd/actionlint
|
|
7
|
+
mvdan.cc/sh/v3/cmd/shfmt
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
require (
|
|
11
|
+
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
|
|
12
|
+
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
|
13
|
+
github.com/fatih/color v1.19.0 // indirect
|
|
14
|
+
github.com/google/renameio/v2 v2.0.2 // indirect
|
|
15
|
+
github.com/mattn/go-colorable v0.1.14 // indirect
|
|
16
|
+
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
17
|
+
github.com/mattn/go-runewidth v0.0.21 // indirect
|
|
18
|
+
github.com/mattn/go-shellwords v1.0.12 // indirect
|
|
19
|
+
github.com/rhysd/actionlint v1.7.12 // indirect
|
|
20
|
+
github.com/robfig/cron/v3 v3.0.1 // indirect
|
|
21
|
+
github.com/rogpeppe/go-internal v1.15.0 // indirect
|
|
22
|
+
go.yaml.in/yaml/v4 v4.0.0-rc.3 // indirect
|
|
23
|
+
golang.org/x/sync v0.20.0 // indirect
|
|
24
|
+
golang.org/x/sys v0.47.0 // indirect
|
|
25
|
+
golang.org/x/term v0.45.0 // indirect
|
|
26
|
+
mvdan.cc/editorconfig v0.3.0 // indirect
|
|
27
|
+
mvdan.cc/sh/v3 v3.14.1 // indirect
|
|
28
|
+
)
|
package/lint/go.sum
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs=
|
|
2
|
+
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
|
3
|
+
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
|
4
|
+
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
|
5
|
+
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
|
|
6
|
+
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
|
|
7
|
+
github.com/go-quicktest/qt v1.102.0 h1:HSQxCeh5YZH3EL3W39ixjtyaEhcWSXQHtHnMBzSs474=
|
|
8
|
+
github.com/go-quicktest/qt v1.102.0/go.mod h1:p4lGIVX+8Wa6ZPNDvqcxq36XpUDLh42FLetFU7odllI=
|
|
9
|
+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
10
|
+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
11
|
+
github.com/google/renameio/v2 v2.0.2 h1:qKZs+tfn+arruZZhQ7TKC/ergJunuJicWS6gLDt/dGw=
|
|
12
|
+
github.com/google/renameio/v2 v2.0.2/go.mod h1:OX+G6WHHpHq3NVj7cAOleLOwJfcQ1s3uUJQCrr78SWo=
|
|
13
|
+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|
14
|
+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
|
15
|
+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|
16
|
+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
|
17
|
+
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
|
18
|
+
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
|
19
|
+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
|
20
|
+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
|
21
|
+
github.com/mattn/go-runewidth v0.0.21 h1:jJKAZiQH+2mIinzCJIaIG9Be1+0NR+5sz/lYEEjdM8w=
|
|
22
|
+
github.com/mattn/go-runewidth v0.0.21/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
|
23
|
+
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
|
|
24
|
+
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
|
|
25
|
+
github.com/rhysd/actionlint v1.7.12 h1:vQ4GeJN86C0QH+gTUQcs8McmK62OLT3kmakPMtEWYnY=
|
|
26
|
+
github.com/rhysd/actionlint v1.7.12/go.mod h1:krOUhujIsJusovkaYzQ/VNH8PFexjNKqU0q5XI/4w+g=
|
|
27
|
+
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
|
28
|
+
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
|
29
|
+
github.com/rogpeppe/go-internal v1.15.0 h1:D0RCU5rMAp+SpgkiNdrjfJ+LX4J1M32V2NeCY7EJ6hc=
|
|
30
|
+
github.com/rogpeppe/go-internal v1.15.0/go.mod h1:DrUVZyrJU+txYW5/1kwtXQSMFio52ZOxX7yM1VHvnxs=
|
|
31
|
+
go.yaml.in/yaml/v4 v4.0.0-rc.3 h1:3h1fjsh1CTAPjW7q/EMe+C8shx5d8ctzZTrLcs/j8Go=
|
|
32
|
+
go.yaml.in/yaml/v4 v4.0.0-rc.3/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
|
33
|
+
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
|
34
|
+
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
35
|
+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
36
|
+
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
|
37
|
+
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
38
|
+
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
|
|
39
|
+
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
|
40
|
+
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
|
41
|
+
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
|
42
|
+
mvdan.cc/editorconfig v0.3.0 h1:D1D2wLYEYGpawWT5SpM5pRivgEgXjtEXwC9MWhEY0gQ=
|
|
43
|
+
mvdan.cc/editorconfig v0.3.0/go.mod h1:NcJHuDtNOTEJ6251indKiWuzK6+VcrMuLzGMLKBFupQ=
|
|
44
|
+
mvdan.cc/sh/v3 v3.14.1 h1:bXkhQWNHCs0KZEChF8hYS6FC+T2N9mUZLbQv9blditI=
|
|
45
|
+
mvdan.cc/sh/v3 v3.14.1/go.mod h1:syYCoFET8w9tvevxiXUtY8/ICrU+l26jHmhJDra3Vwo=
|