@kensio/yulin 1.20.11 → 1.20.13
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/dist/service/acm/command/delete-certificate/delete-certificate-authorizer.js +1 -0
- package/dist/service/acm/command/describe-certificate/describe-certificate-authorizer.js +1 -0
- package/dist/service/acm/command/list-certificates/list-certificates-authorizer.js +1 -0
- package/dist/service/acm/command/request-certificate/request-certificate-authorizer.js +1 -0
- package/dist/service/apigateway/serve/auth/sim-rest-api-authorizer-policy.js +3 -0
- package/dist/service/apigatewayv2/serve/auth/sim-http-api-authorizer-policy.js +3 -0
- package/dist/service/athena/engine/sim-athena-regexp-flags.d.ts +22 -0
- package/dist/service/athena/engine/sim-athena-regexp-flags.js +34 -0
- package/dist/service/athena/engine/sim-athena-regexp-shims.js +3 -1
- package/dist/service/athena/engine/sim-athena-url-parts.d.ts +24 -0
- package/dist/service/athena/engine/sim-athena-url-parts.js +76 -0
- package/dist/service/athena/engine/sim-athena-url-shims.d.ts +3 -2
- package/dist/service/athena/engine/sim-athena-url-shims.js +57 -25
- package/dist/service/athena/table/sim-athena-negated-columns.d.ts +17 -0
- package/dist/service/athena/table/sim-athena-negated-columns.js +80 -0
- package/dist/service/athena/table/sim-athena-partition-filters.d.ts +7 -4
- package/dist/service/athena/table/sim-athena-partition-filters.js +12 -5
- package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +3 -0
- package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
- package/dist/service/aws/factory/sim-aws-service-factory.d.ts +9 -0
- package/dist/service/aws/factory/sim-aws-service-factory.js +10 -0
- package/dist/service/aws/sim-aws.d.ts +18 -0
- package/dist/service/aws/sim-aws.js +19 -0
- package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.d.ts +6 -0
- package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.js +23 -0
- package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.d.ts +66 -0
- package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.js +136 -0
- package/dist/service/cloudformation/resource/cfn/sim-cfn-service-value-adapters.js +2 -0
- package/dist/service/cloudformation/resource/resolve/service/sim-cfn-service-factories.js +7 -0
- package/dist/service/cloudfront/command/create-distribution/create-distribution-authorizer.js +1 -0
- package/dist/service/cloudfront/command/create-function/create-function-authorizer.js +1 -0
- package/dist/service/cloudfront/command/delete-distribution/delete-distribution-authorizer.js +1 -0
- package/dist/service/cloudfront/command/delete-function/delete-function-authorizer.js +1 -0
- package/dist/service/cloudfront/command/get-distribution/get-distribution-authorizer.js +1 -0
- package/dist/service/cloudfront/command/update-distribution/update-distribution-authorizer.js +1 -0
- package/dist/service/cloudfront/edge/sim-cf-edge-association-auth-z.js +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.js +1 -0
- package/dist/service/cloudwatch/command/authorize/sim-cloudwatch-decide.js +1 -0
- package/dist/service/cognito/command/authorize/sim-cognito-authorizer.js +1 -0
- package/dist/service/dynamodb/command/authorize/sim-dynamodb-authorizer.js +1 -0
- package/dist/service/firehose/command/authorize/sim-firehose-authorizer.js +1 -0
- package/dist/service/glue/command/authorize/sim-glue-authorize-resources.js +1 -0
- package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.d.ts +45 -0
- package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.js +59 -0
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +15 -4
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +15 -4
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context.d.ts +31 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context.factory.js +1 -0
- package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.d.ts +46 -0
- package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.js +71 -0
- package/dist/service/iam/authorize/scp/sim-iam-scp-gate.d.ts +96 -0
- package/dist/service/iam/authorize/scp/sim-iam-scp-gate.js +148 -0
- package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.d.ts +53 -0
- package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.js +1 -0
- package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +8 -0
- package/dist/service/iam/authorize/sim-iam-account-auth-z.js +1 -0
- package/dist/service/iam/authorize/sim-iam-action-authorizer.js +1 -0
- package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -0
- package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
- package/dist/service/iam/authorize/sim-iam-decision-value.d.ts +13 -0
- package/dist/service/iam/authorize/sim-iam-decision-value.js +12 -0
- package/dist/service/iam/authorize/sim-iam-decision.d.ts +33 -16
- package/dist/service/iam/authorize/sim-iam-decision.js +64 -49
- package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.d.ts +8 -0
- package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.js +1 -0
- package/dist/service/iam/error/sim-iam.error.d.ts +8 -0
- package/dist/service/iam/error/sim-iam.error.js +2 -1
- package/dist/service/iam/sim-iam-account-parts.d.ts +9 -0
- package/dist/service/iam/sim-iam-account-parts.js +1 -0
- package/dist/service/kinesis/command/authorize/sim-kinesis-authorizer.js +1 -0
- package/dist/service/kms/command/authorize/sim-kms-authorizer.js +2 -0
- package/dist/service/lambda/command/create-function/create-function-authorizer.js +1 -0
- package/dist/service/lambda/command/delete-function/delete-function-authorizer.js +1 -0
- package/dist/service/lambda/command/event-invoke-config/event-invoke-config-authorizer.js +1 -0
- package/dist/service/lambda/command/function-url/function-url-authorizer.js +1 -0
- package/dist/service/lambda/command/get-function/get-function-authorizer.js +1 -0
- package/dist/service/lambda/command/invoke/invoke-authorizer.js +1 -0
- package/dist/service/lambda/command/list-functions/list-functions-authorizer.js +1 -0
- package/dist/service/lambda/command/update-function-code/update-function-code-authorizer.js +1 -0
- package/dist/service/lambda/command/update-function-configuration/update-function-configuration-authorizer.js +1 -0
- package/dist/service/lambda/command/version/version-authorizer.js +1 -0
- package/dist/service/logs/command/authorize/sim-logs-authorizer.js +1 -0
- package/dist/service/organizations/cfn/sim-cfn-organization-creator.d.ts +19 -0
- package/dist/service/organizations/cfn/sim-cfn-organization-creator.js +25 -0
- package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.d.ts +16 -0
- package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.js +21 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.d.ts +20 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.js +34 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.d.ts +21 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.js +40 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.d.ts +20 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.js +33 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-properties.d.ts +36 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-properties.js +78 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-record.d.ts +40 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-record.js +54 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-remover.d.ts +17 -0
- package/dist/service/organizations/cfn/sim-cfn-organizations-remover.js +40 -0
- package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.d.ts +24 -0
- package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.js +50 -0
- package/dist/service/organizations/index.d.ts +6 -0
- package/dist/service/organizations/index.js +6 -0
- package/dist/service/organizations/policy/sim-organizations-effective-policies.d.ts +43 -0
- package/dist/service/organizations/policy/sim-organizations-effective-policies.js +58 -0
- package/dist/service/organizations/policy/sim-organizations-scp-store.d.ts +61 -0
- package/dist/service/organizations/policy/sim-organizations-scp-store.js +103 -0
- package/dist/service/organizations/sim-organizations-structure.d.ts +94 -0
- package/dist/service/organizations/sim-organizations-structure.js +140 -0
- package/dist/service/organizations/sim-organizations.d.ts +95 -0
- package/dist/service/organizations/sim-organizations.js +99 -0
- package/dist/service/organizations/tree/sim-organizations-node.d.ts +57 -0
- package/dist/service/organizations/tree/sim-organizations-node.js +58 -0
- package/dist/service/organizations/tree/sim-organizations-tree.d.ts +91 -0
- package/dist/service/organizations/tree/sim-organizations-tree.js +154 -0
- package/dist/service/route53/command/change-resource-record-sets/change-resource-record-sets-authorizer.js +1 -0
- package/dist/service/route53/command/create-hosted-zone/create-hosted-zone-authorizer.js +1 -0
- package/dist/service/route53/command/delete-hosted-zone/delete-hosted-zone-authorizer.js +1 -0
- package/dist/service/route53/command/dnssec/sim-route53-dnssec-authorizer.js +1 -0
- package/dist/service/route53/command/get-hosted-zone/get-hosted-zone-authorizer.js +1 -0
- package/dist/service/route53/command/list-hosted-zones-by-name/list-hosted-zones-by-name-authorizer.js +1 -0
- package/dist/service/route53/command/list-resource-record-sets/list-resource-record-sets-authorizer.js +1 -0
- package/dist/service/s3/command/create-bucket/create-bucket.handler.js +1 -0
- package/dist/service/s3/command/delete-bucket/delete-bucket-authorizer.js +1 -0
- package/dist/service/s3/command/delete-bucket-policy/delete-bucket-policy-authorizer.js +1 -0
- package/dist/service/s3/command/delete-object/delete-object-authorizer.js +1 -0
- package/dist/service/s3/command/get-bucket-policy/get-bucket-policy-authorizer.js +1 -0
- package/dist/service/s3/command/get-object/get-object-authorizer.js +1 -0
- package/dist/service/s3/command/head-bucket/head-bucket-authorizer.js +1 -0
- package/dist/service/s3/command/lifecycle/sim-s3-lifecycle-authorizer.js +1 -0
- package/dist/service/s3/command/list-buckets/list-buckets-authorizer.js +1 -0
- package/dist/service/s3/command/list-objects/list-objects-authorizer.js +1 -0
- package/dist/service/s3/command/multipart/sim-s3-multipart-authorizer.js +1 -0
- package/dist/service/s3/command/notification/sim-s3-notification-authorizer.js +1 -0
- package/dist/service/s3/command/public-access-block/sim-s3-public-access-block-authorizer.js +1 -0
- package/dist/service/s3/command/put-bucket-policy/put-bucket-policy-authorizer.js +1 -0
- package/dist/service/s3/command/put-bucket-website/put-bucket-website-authorizer.js +1 -0
- package/dist/service/s3/command/put-object/put-object-authorizer.js +1 -0
- package/dist/service/secretsmanager/command/authorize/sim-secrets-manager-authorizer.js +1 -0
- package/dist/service/ses/command/authorize/sim-ses-authorizer.js +1 -0
- package/dist/service/sqs/command/authorize/sim-sqs-authorizer.js +1 -0
- package/dist/service/ssm/command/authorize/sim-ssm-authorizer.js +1 -0
- package/dist/service/wafv2/command/authorize/sim-wafv2-authorizer.js +1 -0
- package/dist/service/wafv2/command/ip-set/sim-wafv2-ip-set-commands.js +4 -3
- package/dist/service/wafv2/command/regex-pattern-set/sim-wafv2-regex-pattern-set-commands.js +4 -3
- package/dist/service/wafv2/command/sim-wafv2-input.d.ts +15 -0
- package/dist/service/wafv2/command/sim-wafv2-input.js +66 -1
- package/dist/service/wafv2/command/web-acl/sim-wafv2-web-acl-commands.js +7 -5
- package/dist/service/wafv2/error/sim-wafv2.error.d.ts +11 -0
- package/dist/service/wafv2/error/sim-wafv2.error.js +13 -0
- package/package.json +5 -1
|
@@ -1,40 +1,50 @@
|
|
|
1
1
|
import { SimIamPolicyDocumentParser } from "../policy/parse/sim-iam-document-parser.js";
|
|
2
2
|
import { SimIamPolicyStatementMatcher } from "./match/sim-iam-policy-statement-matcher.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ImplicitDeny: "ImplicitDeny",
|
|
8
|
-
};
|
|
3
|
+
import { SimIamPolicyEvaluation } from "./allow/sim-iam-policy-evaluation.js";
|
|
4
|
+
import { SimIamScpGate } from "./scp/sim-iam-scp-gate.js";
|
|
5
|
+
import { SimIamPolicyDecisionValue } from "./sim-iam-decision-value.js";
|
|
6
|
+
export { SimIamPolicyDecisionValue } from "./sim-iam-decision-value.js";
|
|
9
7
|
/**
|
|
10
8
|
* Decision for one simulated IAM policy authorization attempt.
|
|
11
9
|
*
|
|
12
|
-
* This evaluates already-discovered identity
|
|
13
|
-
* does not fetch attached policies itself, apply trust
|
|
14
|
-
* evaluate permissions boundaries,
|
|
15
|
-
* access.
|
|
10
|
+
* This evaluates already-discovered identity, resource, and service control
|
|
11
|
+
* policy documents. It does not fetch attached policies itself, apply trust
|
|
12
|
+
* policy semantics, evaluate permissions boundaries, or enforce service
|
|
13
|
+
* command access.
|
|
16
14
|
*
|
|
17
15
|
* The simulator currently models the common IAM authorization rules:
|
|
18
16
|
*
|
|
19
17
|
* - an explicit Deny in any evaluated policy wins;
|
|
18
|
+
* - the caller's Account has to get past its service control policies, which
|
|
19
|
+
* filter permissions and grant none;
|
|
20
20
|
* - the Allows found must satisfy the request's allow requirement, which is
|
|
21
21
|
* either side within one Account and both sides across Accounts;
|
|
22
22
|
* - otherwise the request is implicitly denied.
|
|
23
23
|
*
|
|
24
|
+
* Reading the policies belongs to SimIamPolicyEvaluation for the two sides
|
|
25
|
+
* that can allow, and to SimIamScpGate for the Account boundary. This class
|
|
26
|
+
* combines what they found.
|
|
27
|
+
*
|
|
24
28
|
* Resource policies are expected to be supplied by the service that owns the
|
|
25
29
|
* target resource.
|
|
26
30
|
*/
|
|
27
31
|
export class SimIamPolicyDecision {
|
|
28
32
|
request;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
explicitDenyStatementRecords = [];
|
|
32
|
-
allows = new SimIamAllowStatements();
|
|
33
|
+
policies;
|
|
34
|
+
scpGate;
|
|
33
35
|
constructor(request, policyDocumentParser = new SimIamPolicyDocumentParser()) {
|
|
36
|
+
const statementMatcher = new SimIamPolicyStatementMatcher(request);
|
|
34
37
|
this.request = request;
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
this.policies = new SimIamPolicyEvaluation({
|
|
39
|
+
policies: [...request.identityPolicies, ...request.resourcePolicies],
|
|
40
|
+
policyDocumentParser,
|
|
41
|
+
statementMatcher,
|
|
42
|
+
});
|
|
43
|
+
this.scpGate = new SimIamScpGate({
|
|
44
|
+
serviceControlPolicies: request.serviceControlPolicies,
|
|
45
|
+
policyDocumentParser,
|
|
46
|
+
statementMatcher,
|
|
47
|
+
});
|
|
38
48
|
}
|
|
39
49
|
/**
|
|
40
50
|
* Resolved caller against which this authorization decision was evaluated.
|
|
@@ -49,13 +59,15 @@ export class SimIamPolicyDecision {
|
|
|
49
59
|
* Final IAM decision value.
|
|
50
60
|
*/
|
|
51
61
|
get value() {
|
|
52
|
-
if (this.
|
|
62
|
+
if (this.policies.isExplicitDeny) {
|
|
53
63
|
return SimIamPolicyDecisionValue.ExplicitDeny;
|
|
54
64
|
}
|
|
55
|
-
if (this.
|
|
56
|
-
return
|
|
65
|
+
if (this.scpGate.value !== undefined) {
|
|
66
|
+
return this.scpGate.value;
|
|
57
67
|
}
|
|
58
|
-
return
|
|
68
|
+
return this.request.allowRequirement.isSatisfiedBy(this.policies.sides)
|
|
69
|
+
? SimIamPolicyDecisionValue.Allow
|
|
70
|
+
: SimIamPolicyDecisionValue.ImplicitDeny;
|
|
59
71
|
}
|
|
60
72
|
/**
|
|
61
73
|
* Whether the request is allowed.
|
|
@@ -87,13 +99,38 @@ export class SimIamPolicyDecision {
|
|
|
87
99
|
* An identity-policy Allow cannot substitute for the target role's trust.
|
|
88
100
|
*/
|
|
89
101
|
get isAllowedByTrustPolicy() {
|
|
90
|
-
return this.
|
|
102
|
+
return this.policies.allowStatements.trust.length > 0;
|
|
91
103
|
}
|
|
92
104
|
/**
|
|
93
105
|
* Matching explicit Deny statements.
|
|
94
106
|
*/
|
|
95
107
|
get explicitDenyStatements() {
|
|
96
|
-
return this.
|
|
108
|
+
return this.policies.explicitDenyStatements;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* What the caller Account's service control policies said about the request.
|
|
112
|
+
*
|
|
113
|
+
* This is the organization's verdict on its own, apart from the identity and
|
|
114
|
+
* resource sides. It reports whether the Account boundary denied the request
|
|
115
|
+
* and which of its statements matched.
|
|
116
|
+
*/
|
|
117
|
+
get serviceControlPolicy() {
|
|
118
|
+
return this.scpGate;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* How an AccessDenied error should explain this denial, where there is more
|
|
122
|
+
* to say than the action and the resource.
|
|
123
|
+
*
|
|
124
|
+
* A service turns a denied decision into an error and passes this through,
|
|
125
|
+
* so an SCP denial reads the way it does in a real account. A matching Deny
|
|
126
|
+
* in an identity or resource policy is what `value` reports first, and it
|
|
127
|
+
* needs nothing added to the message, so it leaves this absent.
|
|
128
|
+
*/
|
|
129
|
+
get denialReason() {
|
|
130
|
+
if (this.policies.isExplicitDeny) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
return this.scpGate.denialReason(this.request.action);
|
|
97
134
|
}
|
|
98
135
|
/**
|
|
99
136
|
* Matching Allow statements, from both policy sides.
|
|
@@ -103,46 +140,24 @@ export class SimIamPolicyDecision {
|
|
|
103
140
|
* from each side.
|
|
104
141
|
*/
|
|
105
142
|
get allowStatements() {
|
|
106
|
-
return this.
|
|
143
|
+
return this.policies.allowStatements.all;
|
|
107
144
|
}
|
|
108
145
|
/**
|
|
109
146
|
* Matching Allow statements from identity-based policies.
|
|
110
147
|
*/
|
|
111
148
|
get identityAllowStatements() {
|
|
112
|
-
return this.
|
|
149
|
+
return this.policies.allowStatements.identity;
|
|
113
150
|
}
|
|
114
151
|
/**
|
|
115
152
|
* Matching Allow statements from resource-based policies.
|
|
116
153
|
*/
|
|
117
154
|
get resourceAllowStatements() {
|
|
118
|
-
return this.
|
|
155
|
+
return this.policies.allowStatements.resource;
|
|
119
156
|
}
|
|
120
157
|
/**
|
|
121
158
|
* Matching Allow statements originating from trust policies.
|
|
122
159
|
*/
|
|
123
160
|
get trustAllowStatements() {
|
|
124
|
-
return this.
|
|
125
|
-
}
|
|
126
|
-
evaluate() {
|
|
127
|
-
for (const policy of [
|
|
128
|
-
...this.request.identityPolicies,
|
|
129
|
-
...this.request.resourcePolicies,
|
|
130
|
-
]) {
|
|
131
|
-
this.evaluatePolicy(policy);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
evaluatePolicy(policy) {
|
|
135
|
-
const parsedPolicy = this.policyDocumentParser.parse(policy.document);
|
|
136
|
-
for (const statement of parsedPolicy.statements) {
|
|
137
|
-
const principal = this.statementMatcher.matches(policy, statement);
|
|
138
|
-
if (!principal.matched) {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (statement.effect === "Deny") {
|
|
142
|
-
this.explicitDenyStatementRecords.push(statement.source);
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
this.allows.record(policy, statement.source, principal);
|
|
146
|
-
}
|
|
161
|
+
return this.policies.allowStatements.trust;
|
|
147
162
|
}
|
|
148
163
|
}
|
|
@@ -15,6 +15,14 @@ export interface SimIamAuthorizationDecision {
|
|
|
15
15
|
readonly caller: SimAwsResolvedCaller;
|
|
16
16
|
readonly isAllowed: boolean;
|
|
17
17
|
readonly isDenied: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* How an AccessDenied error should explain this denial, where the action and
|
|
20
|
+
* the resource leave something out.
|
|
21
|
+
*
|
|
22
|
+
* A service control policy denial is the case this exists for. Absent for a
|
|
23
|
+
* denial an identity or resource policy accounts for on its own.
|
|
24
|
+
*/
|
|
25
|
+
readonly denialReason?: string | undefined;
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
28
|
* IAM authorization capability consumed by other simulated AWS services.
|
|
@@ -19,6 +19,14 @@ export interface SimIamAccessDeniedInput {
|
|
|
19
19
|
readonly principal: SimAwsPrincipal;
|
|
20
20
|
readonly action: string;
|
|
21
21
|
readonly resource: string;
|
|
22
|
+
/**
|
|
23
|
+
* What else the message should say about why the request was denied.
|
|
24
|
+
*
|
|
25
|
+
* AWS names the source of a denial when it is something beyond the caller's
|
|
26
|
+
* own permissions, such as a service control policy. A denial the caller's
|
|
27
|
+
* identity and resource policies account for adds nothing here.
|
|
28
|
+
*/
|
|
29
|
+
readonly reason?: string | undefined;
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* Simulated IAM AccessDenied error.
|
|
@@ -27,7 +27,8 @@ export class SimIamAccessDenied extends SimIamError {
|
|
|
27
27
|
constructor(input) {
|
|
28
28
|
const iamCallerIdentifier = new SimIamCallerIdentifier();
|
|
29
29
|
const callerIdentifier = iamCallerIdentifier.format(input.principal);
|
|
30
|
-
|
|
30
|
+
const reason = input.reason === undefined ? "" : ` ${input.reason}`;
|
|
31
|
+
super(`User: ${callerIdentifier} is not authorized to perform: ${input.action} on resource: ${input.resource}${reason}`, { httpStatusCode: 403 });
|
|
31
32
|
this.caller = input.principal;
|
|
32
33
|
this.action = input.action;
|
|
33
34
|
this.resource = input.resource;
|
|
@@ -10,6 +10,7 @@ import { SimIamSessionManager } from "./credential/session/sim-iam-session-manag
|
|
|
10
10
|
import { type SimIamUserCredentialGenerator } from "./credential/user/sim-iam-user-credential-generator.js";
|
|
11
11
|
import type { SimIamManagedPolicy } from "./policy/sim-iam-policy.js";
|
|
12
12
|
import type { SimIamAccountResolver } from "./registry/sim-iam-account-resolver.js";
|
|
13
|
+
import type { SimIamServiceControlPolicyResolver } from "./authorize/scp/sim-iam-scp-resolver.js";
|
|
13
14
|
import type { SimIamRole, SimIamRoleName } from "./role/sim-iam-role.js";
|
|
14
15
|
import type { SimIamUser, SimIamUsername } from "./user/sim-iam-user.js";
|
|
15
16
|
export interface SimIamProperties {
|
|
@@ -26,6 +27,14 @@ export interface SimIamProperties {
|
|
|
26
27
|
* simulation around it and so leaves this out.
|
|
27
28
|
*/
|
|
28
29
|
readonly iamResolver?: SimIamAccountResolver;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the service control policies in force for this Account.
|
|
32
|
+
*
|
|
33
|
+
* Simulated Organizations supplies this when a SimAws builds IAM. A
|
|
34
|
+
* standalone SimIam has no organization around it, which is the same as an
|
|
35
|
+
* Account belonging to none.
|
|
36
|
+
*/
|
|
37
|
+
readonly scpResolver?: SimIamServiceControlPolicyResolver;
|
|
29
38
|
}
|
|
30
39
|
/**
|
|
31
40
|
* The state and collaborators of one simulated IAM Account.
|
|
@@ -45,6 +45,7 @@ export class SimKmsAuthorizer {
|
|
|
45
45
|
if (decision.isDenied) {
|
|
46
46
|
throw new SimIamAccessDenied({
|
|
47
47
|
principal: decision.caller.principal,
|
|
48
|
+
reason: decision.denialReason,
|
|
48
49
|
action,
|
|
49
50
|
resource: key.arn,
|
|
50
51
|
});
|
|
@@ -65,6 +66,7 @@ export class SimKmsAuthorizer {
|
|
|
65
66
|
if (decision.isDenied) {
|
|
66
67
|
throw new SimIamAccessDenied({
|
|
67
68
|
principal: decision.caller.principal,
|
|
69
|
+
reason: decision.denialReason,
|
|
68
70
|
action,
|
|
69
71
|
resource,
|
|
70
72
|
});
|
|
@@ -32,6 +32,7 @@ export class ListFunctionsAuthorizer {
|
|
|
32
32
|
if (decision.isDenied) {
|
|
33
33
|
throw new SimIamAccessDenied({
|
|
34
34
|
principal: decision.caller.principal,
|
|
35
|
+
reason: decision.denialReason,
|
|
35
36
|
action: ListFunctionsAuthorizer.action,
|
|
36
37
|
resource: ListFunctionsAuthorizer.resource,
|
|
37
38
|
});
|
|
@@ -29,6 +29,7 @@ export class UpdateFunctionConfigurationAuthorizer {
|
|
|
29
29
|
if (decision.isDenied) {
|
|
30
30
|
throw new SimIamAccessDenied({
|
|
31
31
|
principal: decision.caller.principal,
|
|
32
|
+
reason: decision.denialReason,
|
|
32
33
|
action: UpdateFunctionConfigurationAuthorizer.action,
|
|
33
34
|
resource: functionArn,
|
|
34
35
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SimAws } from "../../aws/sim-aws.js";
|
|
2
|
+
import type { SimCfnResource } from "../../cloudformation/resource/sim-cfn-resource.js";
|
|
3
|
+
import type { SimCfnTemplateValueRecord } from "../../cloudformation/template/value/sim-cfn-template-value.js";
|
|
4
|
+
import { SimCfnOrganization } from "./sim-cfn-organizations-record.js";
|
|
5
|
+
/**
|
|
6
|
+
* Records the organization an `AWS::Organizations::Organization` declares.
|
|
7
|
+
*
|
|
8
|
+
* A SimAws already has one organization, so this brings nothing into being.
|
|
9
|
+
* The Resource earns its place by answering `RootId`, which is what the rest
|
|
10
|
+
* of a template hangs off.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SimCfnOrganizationCreator {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(simAws: SimAws);
|
|
15
|
+
/**
|
|
16
|
+
* Record the organization a template declares.
|
|
17
|
+
*/
|
|
18
|
+
create(resource: SimCfnResource, properties: SimCfnTemplateValueRecord): SimCfnOrganization;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SimCfnOrganization } from "./sim-cfn-organizations-record.js";
|
|
2
|
+
import { SimCfnOrganizationsProperties } from "./sim-cfn-organizations-properties.js";
|
|
3
|
+
/**
|
|
4
|
+
* Records the organization an `AWS::Organizations::Organization` declares.
|
|
5
|
+
*
|
|
6
|
+
* A SimAws already has one organization, so this brings nothing into being.
|
|
7
|
+
* The Resource earns its place by answering `RootId`, which is what the rest
|
|
8
|
+
* of a template hangs off.
|
|
9
|
+
*/
|
|
10
|
+
export class SimCfnOrganizationCreator {
|
|
11
|
+
#simAws;
|
|
12
|
+
constructor(simAws) {
|
|
13
|
+
this.#simAws = simAws;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Record the organization a template declares.
|
|
17
|
+
*/
|
|
18
|
+
create(resource, properties) {
|
|
19
|
+
const values = new SimCfnOrganizationsProperties(resource, "AWS::Organizations::Organization");
|
|
20
|
+
const featureSet = properties["FeatureSet"];
|
|
21
|
+
values.ignore(featureSet, "FeatureSet", "Simulated Organizations evaluates service control policies whatever " +
|
|
22
|
+
"the feature set says");
|
|
23
|
+
return new SimCfnOrganization(this.#simAws.organizations().root().id, values.optionalString(featureSet) ?? "ALL", this.#simAws.defaultAccountId);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SimAws } from "../../aws/sim-aws.js";
|
|
2
|
+
import type { SimCfnResource } from "../../cloudformation/resource/sim-cfn-resource.js";
|
|
3
|
+
import type { SimCfnTemplateValueRecord } from "../../cloudformation/template/value/sim-cfn-template-value.js";
|
|
4
|
+
import type { SimOrganizationsOrganizationalUnit } from "../tree/sim-organizations-node.js";
|
|
5
|
+
/**
|
|
6
|
+
* Creates organizational units from
|
|
7
|
+
* `AWS::Organizations::OrganizationalUnit` Resources.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SimCfnOrganizationalUnitCreator {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(simAws: SimAws);
|
|
12
|
+
/**
|
|
13
|
+
* Create a unit under the node its `ParentId` names.
|
|
14
|
+
*/
|
|
15
|
+
create(resource: SimCfnResource, properties: SimCfnTemplateValueRecord): SimOrganizationsOrganizationalUnit;
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SimCfnOrganizationsProperties } from "./sim-cfn-organizations-properties.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates organizational units from
|
|
4
|
+
* `AWS::Organizations::OrganizationalUnit` Resources.
|
|
5
|
+
*/
|
|
6
|
+
export class SimCfnOrganizationalUnitCreator {
|
|
7
|
+
#simAws;
|
|
8
|
+
constructor(simAws) {
|
|
9
|
+
this.#simAws = simAws;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a unit under the node its `ParentId` names.
|
|
13
|
+
*/
|
|
14
|
+
create(resource, properties) {
|
|
15
|
+
const values = new SimCfnOrganizationsProperties(resource, "AWS::Organizations::OrganizationalUnit");
|
|
16
|
+
values.ignore(properties["Tags"], "Tags", "Simulated Organizations reads no unit tags");
|
|
17
|
+
return this.#simAws
|
|
18
|
+
.organizations()
|
|
19
|
+
.createOrganizationalUnit(values.requiredString(properties["Name"], "Name"), values.requiredString(properties["ParentId"], "ParentId"));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SimAws } from "../../aws/sim-aws.js";
|
|
2
|
+
import type { SimCfnResource } from "../../cloudformation/resource/sim-cfn-resource.js";
|
|
3
|
+
import type { SimCfnTemplateValueRecord } from "../../cloudformation/template/value/sim-cfn-template-value.js";
|
|
4
|
+
import { SimCfnOrganizationsAccount } from "./sim-cfn-organizations-record.js";
|
|
5
|
+
/**
|
|
6
|
+
* Puts Accounts in the organization from `AWS::Organizations::Account`
|
|
7
|
+
* Resources.
|
|
8
|
+
*
|
|
9
|
+
* AWS creates a new account here and gives it an id nobody chose, so this does
|
|
10
|
+
* the same. A template reads that id back with `Ref` or with
|
|
11
|
+
* `Fn::GetAtt AccountId`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SimCfnOrganizationsAccountCreator {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(simAws: SimAws);
|
|
16
|
+
/**
|
|
17
|
+
* Create an Account under the first node its `ParentIds` names.
|
|
18
|
+
*/
|
|
19
|
+
create(resource: SimCfnResource, properties: SimCfnTemplateValueRecord): SimCfnOrganizationsAccount;
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { makeSimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
2
|
+
import { SimCfnOrganizationsAccount } from "./sim-cfn-organizations-record.js";
|
|
3
|
+
import { SimCfnOrganizationsProperties } from "./sim-cfn-organizations-properties.js";
|
|
4
|
+
/**
|
|
5
|
+
* Puts Accounts in the organization from `AWS::Organizations::Account`
|
|
6
|
+
* Resources.
|
|
7
|
+
*
|
|
8
|
+
* AWS creates a new account here and gives it an id nobody chose, so this does
|
|
9
|
+
* the same. A template reads that id back with `Ref` or with
|
|
10
|
+
* `Fn::GetAtt AccountId`.
|
|
11
|
+
*/
|
|
12
|
+
export class SimCfnOrganizationsAccountCreator {
|
|
13
|
+
#simAws;
|
|
14
|
+
constructor(simAws) {
|
|
15
|
+
this.#simAws = simAws;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create an Account under the first node its `ParentIds` names.
|
|
19
|
+
*/
|
|
20
|
+
create(resource, properties) {
|
|
21
|
+
const values = new SimCfnOrganizationsProperties(resource, "AWS::Organizations::Account");
|
|
22
|
+
values.ignore(properties["Tags"], "Tags", "Simulated Organizations reads no Account tags");
|
|
23
|
+
values.ignore(properties["RoleName"], "RoleName", "Simulated Organizations creates no cross-account access Role");
|
|
24
|
+
// Everything the Resource needs is read before the organization changes.
|
|
25
|
+
// A property that fails after the Account was placed would leave it in the
|
|
26
|
+
// organization with no record for a teardown to take it out again.
|
|
27
|
+
const accountName = values.requiredString(properties["AccountName"], "AccountName");
|
|
28
|
+
const email = values.requiredString(properties["Email"], "Email");
|
|
29
|
+
const parentId = values.stringList(properties["ParentIds"])[0];
|
|
30
|
+
const accountId = makeSimAwsAccountId();
|
|
31
|
+
this.#simAws.organizations().moveAccount(accountId, parentId);
|
|
32
|
+
return new SimCfnOrganizationsAccount(accountId, accountName, email, this.#simAws.now());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SimAws } from "../../aws/sim-aws.js";
|
|
2
|
+
import type { SimCfnResource } from "../../cloudformation/resource/sim-cfn-resource.js";
|
|
3
|
+
import type { SimCfnTemplateValueRecord } from "../../cloudformation/template/value/sim-cfn-template-value.js";
|
|
4
|
+
import { SimCfnOrganizationsPolicy } from "./sim-cfn-organizations-record.js";
|
|
5
|
+
/**
|
|
6
|
+
* Attaches service control policies from `AWS::Organizations::Policy`
|
|
7
|
+
* Resources to the nodes they target.
|
|
8
|
+
*
|
|
9
|
+
* A policy of any other type is refused as an unsupported Resource, so the
|
|
10
|
+
* Stack records it and deploys on. Simulated Organizations evaluates service
|
|
11
|
+
* control policies and nothing else, and a tag policy stored here would look
|
|
12
|
+
* like one that does something.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SimCfnOrganizationsPolicyCreator {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(simAws: SimAws);
|
|
17
|
+
/**
|
|
18
|
+
* Attach a policy to every node its `TargetIds` names.
|
|
19
|
+
*/
|
|
20
|
+
create(resource: SimCfnResource, properties: SimCfnTemplateValueRecord): SimCfnOrganizationsPolicy;
|
|
21
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { makeSimOrganizationsPolicyId, } from "../tree/sim-organizations-node.js";
|
|
2
|
+
import { SimCfnOrganizationsPolicy } from "./sim-cfn-organizations-record.js";
|
|
3
|
+
import { SimCfnOrganizationsPolicyInput } from "./sim-cfn-organizations-policy-input.js";
|
|
4
|
+
/**
|
|
5
|
+
* Attaches service control policies from `AWS::Organizations::Policy`
|
|
6
|
+
* Resources to the nodes they target.
|
|
7
|
+
*
|
|
8
|
+
* A policy of any other type is refused as an unsupported Resource, so the
|
|
9
|
+
* Stack records it and deploys on. Simulated Organizations evaluates service
|
|
10
|
+
* control policies and nothing else, and a tag policy stored here would look
|
|
11
|
+
* like one that does something.
|
|
12
|
+
*/
|
|
13
|
+
export class SimCfnOrganizationsPolicyCreator {
|
|
14
|
+
#simAws;
|
|
15
|
+
constructor(simAws) {
|
|
16
|
+
this.#simAws = simAws;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Attach a policy to every node its `TargetIds` names.
|
|
20
|
+
*/
|
|
21
|
+
create(resource, properties) {
|
|
22
|
+
const input = new SimCfnOrganizationsPolicyInput(resource, properties);
|
|
23
|
+
const organizations = this.#simAws.organizations();
|
|
24
|
+
// Every target is resolved before any of them is attached to. Refusing one
|
|
25
|
+
// partway through would leave the earlier targets holding a policy no
|
|
26
|
+
// teardown knows about.
|
|
27
|
+
organizations.requireTargets(input.targetIds);
|
|
28
|
+
// An id of its own, rather than one derived from the logical id. Two
|
|
29
|
+
// Stacks can each declare a Policy called the same thing, and a shared id
|
|
30
|
+
// would let one Stack's teardown take the other's policy off.
|
|
31
|
+
const policyId = makeSimOrganizationsPolicyId();
|
|
32
|
+
for (const targetId of input.targetIds) {
|
|
33
|
+
organizations.attachServiceControlPolicy(targetId, input.document, {
|
|
34
|
+
policyName: input.name,
|
|
35
|
+
policyId,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return new SimCfnOrganizationsPolicy(policyId, input.name, input.policyType, input.targetIds);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SimCfnResource } from "../../cloudformation/resource/sim-cfn-resource.js";
|
|
2
|
+
import type { SimCfnTemplateValueRecord } from "../../cloudformation/template/value/sim-cfn-template-value.js";
|
|
3
|
+
import type { SimIamPolicyDocument } from "../../iam/policy/sim-iam-policy.js";
|
|
4
|
+
/**
|
|
5
|
+
* What an `AWS::Organizations::Policy` Resource asks for.
|
|
6
|
+
*
|
|
7
|
+
* Every property is read here before the creator changes anything, so a
|
|
8
|
+
* Resource that cannot be satisfied fails with the organization untouched.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SimCfnOrganizationsPolicyInput {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly document: SimIamPolicyDocument;
|
|
13
|
+
readonly targetIds: readonly string[];
|
|
14
|
+
constructor(resource: SimCfnResource, properties: SimCfnTemplateValueRecord);
|
|
15
|
+
/**
|
|
16
|
+
* The policy type this Resource carries, which is the only one simulated
|
|
17
|
+
* Organizations evaluates.
|
|
18
|
+
*/
|
|
19
|
+
get policyType(): string;
|
|
20
|
+
}
|