@kensio/yulin 1.20.12 → 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/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/package.json +5 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Brand } from "../../../util/brand.type.js";
|
|
2
|
+
import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
3
|
+
export type SimOrganizationsRootId = Brand<string, "SimOrganizationsRootId">;
|
|
4
|
+
export type SimOrganizationsOrganizationalUnitId = Brand<string, "SimOrganizationsOrganizationalUnitId">;
|
|
5
|
+
/**
|
|
6
|
+
* Anything a service control policy can hang on.
|
|
7
|
+
*
|
|
8
|
+
* AWS attaches a policy to the root, to an organizational unit, or to one
|
|
9
|
+
* account, and an account inherits every policy on the path down to it.
|
|
10
|
+
*/
|
|
11
|
+
export type SimOrganizationsNodeId = SimOrganizationsRootId | SimOrganizationsOrganizationalUnitId | SimAwsAccountId;
|
|
12
|
+
/**
|
|
13
|
+
* Generate an AWS-shaped organization root id.
|
|
14
|
+
*/
|
|
15
|
+
export declare function makeSimOrganizationsRootId(): SimOrganizationsRootId;
|
|
16
|
+
/**
|
|
17
|
+
* Generate an AWS-shaped organizational unit id.
|
|
18
|
+
*/
|
|
19
|
+
export declare function makeSimOrganizationsOrganizationalUnitId(rootId: SimOrganizationsRootId): SimOrganizationsOrganizationalUnitId;
|
|
20
|
+
/**
|
|
21
|
+
* Generate an AWS-shaped service control policy id.
|
|
22
|
+
*/
|
|
23
|
+
export declare function makeSimOrganizationsPolicyId(): string;
|
|
24
|
+
/**
|
|
25
|
+
* An organizational unit in a simulated organization.
|
|
26
|
+
*
|
|
27
|
+
* This is the handle a test holds on to. Pass it where a policy is attached or
|
|
28
|
+
* an Account is moved, so neither reads back as a bare string.
|
|
29
|
+
*/
|
|
30
|
+
export declare class SimOrganizationsOrganizationalUnit {
|
|
31
|
+
readonly id: SimOrganizationsOrganizationalUnitId;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly parentId: SimOrganizationsNodeId;
|
|
34
|
+
constructor(id: SimOrganizationsOrganizationalUnitId, name: string, parentId: SimOrganizationsNodeId);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The root of a simulated organization.
|
|
38
|
+
*/
|
|
39
|
+
export declare class SimOrganizationsRoot {
|
|
40
|
+
readonly id: SimOrganizationsRootId;
|
|
41
|
+
readonly name = "Root";
|
|
42
|
+
constructor(id: SimOrganizationsRootId);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Somewhere a policy can be attached, given as a handle or as an id.
|
|
46
|
+
*
|
|
47
|
+
* An id is what a CloudFormation template carries, since a `Ref` to a unit
|
|
48
|
+
* resolves to the id AWS gave it rather than to anything holding a reference.
|
|
49
|
+
*/
|
|
50
|
+
export type SimOrganizationsTarget = SimOrganizationsRoot | SimOrganizationsOrganizationalUnit | string;
|
|
51
|
+
/**
|
|
52
|
+
* Whether an id names the root or an organizational unit.
|
|
53
|
+
*
|
|
54
|
+
* AWS ids carry their own kind in a prefix, and an Account id is twelve
|
|
55
|
+
* digits, so nothing here has to guess which of the two a string is.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isSimOrganizationsUnitId(value: string): boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { faker } from "@faker-js/faker";
|
|
2
|
+
/**
|
|
3
|
+
* Generate an AWS-shaped organization root id.
|
|
4
|
+
*/
|
|
5
|
+
export function makeSimOrganizationsRootId() {
|
|
6
|
+
return `r-${faker.string.alphanumeric({
|
|
7
|
+
length: 4,
|
|
8
|
+
casing: "lower",
|
|
9
|
+
})}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generate an AWS-shaped organizational unit id.
|
|
13
|
+
*/
|
|
14
|
+
export function makeSimOrganizationsOrganizationalUnitId(rootId) {
|
|
15
|
+
const suffix = faker.string.alphanumeric({ length: 8, casing: "lower" });
|
|
16
|
+
return `ou-${rootId.slice(2)}-${suffix}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generate an AWS-shaped service control policy id.
|
|
20
|
+
*/
|
|
21
|
+
export function makeSimOrganizationsPolicyId() {
|
|
22
|
+
return `p-${faker.string.alphanumeric({ length: 8, casing: "lower" })}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* An organizational unit in a simulated organization.
|
|
26
|
+
*
|
|
27
|
+
* This is the handle a test holds on to. Pass it where a policy is attached or
|
|
28
|
+
* an Account is moved, so neither reads back as a bare string.
|
|
29
|
+
*/
|
|
30
|
+
export class SimOrganizationsOrganizationalUnit {
|
|
31
|
+
id;
|
|
32
|
+
name;
|
|
33
|
+
parentId;
|
|
34
|
+
constructor(id, name, parentId) {
|
|
35
|
+
this.id = id;
|
|
36
|
+
this.name = name;
|
|
37
|
+
this.parentId = parentId;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The root of a simulated organization.
|
|
42
|
+
*/
|
|
43
|
+
export class SimOrganizationsRoot {
|
|
44
|
+
id;
|
|
45
|
+
name = "Root";
|
|
46
|
+
constructor(id) {
|
|
47
|
+
this.id = id;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Whether an id names the root or an organizational unit.
|
|
52
|
+
*
|
|
53
|
+
* AWS ids carry their own kind in a prefix, and an Account id is twelve
|
|
54
|
+
* digits, so nothing here has to guess which of the two a string is.
|
|
55
|
+
*/
|
|
56
|
+
export function isSimOrganizationsUnitId(value) {
|
|
57
|
+
return value.startsWith("r-") || value.startsWith("ou-");
|
|
58
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { SimOrganizationsOrganizationalUnit, type SimOrganizationsNodeId, SimOrganizationsRoot } from "./sim-organizations-node.js";
|
|
2
|
+
import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
3
|
+
/**
|
|
4
|
+
* Thrown for an organizational unit this organization has never seen.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SimOrganizationsUnknownNode extends Error {
|
|
7
|
+
constructor(nodeId: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Where the Accounts and organizational units of one simulated organization
|
|
11
|
+
* sit relative to each other.
|
|
12
|
+
*
|
|
13
|
+
* The tree answers one question for authorization: which nodes lie on the path
|
|
14
|
+
* from the root down to an Account. Every policy on that path applies to the
|
|
15
|
+
* Account, which is what makes an organizational unit worth modelling at all.
|
|
16
|
+
*
|
|
17
|
+
* An Account joins the organization the moment it is named, whether by being
|
|
18
|
+
* moved into a unit or by having a policy attached to it. An Account never
|
|
19
|
+
* named sits outside the organization and is unrestricted.
|
|
20
|
+
*/
|
|
21
|
+
export declare class SimOrganizationsTree {
|
|
22
|
+
readonly root: SimOrganizationsRoot;
|
|
23
|
+
private readonly organizationalUnits;
|
|
24
|
+
private readonly accountParents;
|
|
25
|
+
/**
|
|
26
|
+
* Create an organizational unit, under the root unless another unit is
|
|
27
|
+
* named as its parent.
|
|
28
|
+
*/
|
|
29
|
+
createOrganizationalUnit(name: string, parentId?: SimOrganizationsNodeId): SimOrganizationsOrganizationalUnit;
|
|
30
|
+
/**
|
|
31
|
+
* Place an Account under a node, joining the organization if it was outside
|
|
32
|
+
* it.
|
|
33
|
+
*/
|
|
34
|
+
placeAccount(accountId: SimAwsAccountId, parentId?: SimOrganizationsNodeId): void;
|
|
35
|
+
/**
|
|
36
|
+
* Take an Account out of the organization.
|
|
37
|
+
*/
|
|
38
|
+
removeAccount(accountId: SimAwsAccountId): void;
|
|
39
|
+
/**
|
|
40
|
+
* Take an organizational unit out of the organization.
|
|
41
|
+
*
|
|
42
|
+
* Whatever still sits under it moves up to its parent, which is the only
|
|
43
|
+
* answer that leaves every Account on a path back to the root. AWS refuses
|
|
44
|
+
* to delete a unit that still holds anything, and a Stack tears down in
|
|
45
|
+
* reverse dependency order, so nothing should still be there.
|
|
46
|
+
*/
|
|
47
|
+
removeOrganizationalUnit(unitId: SimOrganizationsNodeId): void;
|
|
48
|
+
/**
|
|
49
|
+
* Every Account in the organization.
|
|
50
|
+
*/
|
|
51
|
+
accountIds(): readonly SimAwsAccountId[];
|
|
52
|
+
/**
|
|
53
|
+
* Whether this Account is in the organization.
|
|
54
|
+
*/
|
|
55
|
+
holds(accountId: SimAwsAccountId): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Refuse a root or organizational unit this organization never created.
|
|
58
|
+
*
|
|
59
|
+
* A handle from another simulated organization would otherwise be attached
|
|
60
|
+
* to and then never read, because no Account here has it on its path. A
|
|
61
|
+
* policy that silently applies to nothing is worse than a refusal.
|
|
62
|
+
*/
|
|
63
|
+
requireNode(nodeId: SimOrganizationsNodeId): void;
|
|
64
|
+
/**
|
|
65
|
+
* Whether this organization has a root or unit under an id.
|
|
66
|
+
*/
|
|
67
|
+
hasNode(nodeId: SimOrganizationsNodeId): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The nodes a request against an Account is filtered by, root first.
|
|
70
|
+
*
|
|
71
|
+
* The Account itself is the last of them, because a policy attached to an
|
|
72
|
+
* Account applies alongside the ones it inherits.
|
|
73
|
+
*/
|
|
74
|
+
pathTo(accountId: SimAwsAccountId): readonly SimOrganizationsNodeId[];
|
|
75
|
+
/**
|
|
76
|
+
* What to call a node in a denial.
|
|
77
|
+
*/
|
|
78
|
+
nameOf(nodeId: SimOrganizationsNodeId): string;
|
|
79
|
+
/**
|
|
80
|
+
* Move everything under one node up to another.
|
|
81
|
+
*/
|
|
82
|
+
private reparent;
|
|
83
|
+
/**
|
|
84
|
+
* The nodes from the root down to one node, root first.
|
|
85
|
+
*/
|
|
86
|
+
private ancestors;
|
|
87
|
+
/**
|
|
88
|
+
* Refuse a node this organization never created.
|
|
89
|
+
*/
|
|
90
|
+
private requireKnown;
|
|
91
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { makeSimOrganizationsOrganizationalUnitId, makeSimOrganizationsRootId, SimOrganizationsOrganizationalUnit, SimOrganizationsRoot, } from "./sim-organizations-node.js";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown for an organizational unit this organization has never seen.
|
|
4
|
+
*/
|
|
5
|
+
export class SimOrganizationsUnknownNode extends Error {
|
|
6
|
+
constructor(nodeId) {
|
|
7
|
+
super(`Unknown simulated Organizations node "${nodeId}"`);
|
|
8
|
+
this.name = "SimOrganizationsUnknownNode";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Where the Accounts and organizational units of one simulated organization
|
|
13
|
+
* sit relative to each other.
|
|
14
|
+
*
|
|
15
|
+
* The tree answers one question for authorization: which nodes lie on the path
|
|
16
|
+
* from the root down to an Account. Every policy on that path applies to the
|
|
17
|
+
* Account, which is what makes an organizational unit worth modelling at all.
|
|
18
|
+
*
|
|
19
|
+
* An Account joins the organization the moment it is named, whether by being
|
|
20
|
+
* moved into a unit or by having a policy attached to it. An Account never
|
|
21
|
+
* named sits outside the organization and is unrestricted.
|
|
22
|
+
*/
|
|
23
|
+
export class SimOrganizationsTree {
|
|
24
|
+
root = new SimOrganizationsRoot(makeSimOrganizationsRootId());
|
|
25
|
+
organizationalUnits = new Map();
|
|
26
|
+
accountParents = new Map();
|
|
27
|
+
/**
|
|
28
|
+
* Create an organizational unit, under the root unless another unit is
|
|
29
|
+
* named as its parent.
|
|
30
|
+
*/
|
|
31
|
+
createOrganizationalUnit(name, parentId = this.root.id) {
|
|
32
|
+
this.requireKnown(parentId);
|
|
33
|
+
const unit = new SimOrganizationsOrganizationalUnit(makeSimOrganizationsOrganizationalUnitId(this.root.id), name, parentId);
|
|
34
|
+
this.organizationalUnits.set(unit.id, unit);
|
|
35
|
+
return unit;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Place an Account under a node, joining the organization if it was outside
|
|
39
|
+
* it.
|
|
40
|
+
*/
|
|
41
|
+
placeAccount(accountId, parentId = this.root.id) {
|
|
42
|
+
this.requireKnown(parentId);
|
|
43
|
+
this.accountParents.set(accountId, parentId);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Take an Account out of the organization.
|
|
47
|
+
*/
|
|
48
|
+
removeAccount(accountId) {
|
|
49
|
+
this.accountParents.delete(accountId);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Take an organizational unit out of the organization.
|
|
53
|
+
*
|
|
54
|
+
* Whatever still sits under it moves up to its parent, which is the only
|
|
55
|
+
* answer that leaves every Account on a path back to the root. AWS refuses
|
|
56
|
+
* to delete a unit that still holds anything, and a Stack tears down in
|
|
57
|
+
* reverse dependency order, so nothing should still be there.
|
|
58
|
+
*/
|
|
59
|
+
removeOrganizationalUnit(unitId) {
|
|
60
|
+
const unit = this.organizationalUnits.get(unitId);
|
|
61
|
+
if (unit === undefined) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.organizationalUnits.delete(unitId);
|
|
65
|
+
this.reparent(unitId, unit.parentId);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Every Account in the organization.
|
|
69
|
+
*/
|
|
70
|
+
accountIds() {
|
|
71
|
+
return this.accountParents.keys().toArray();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Whether this Account is in the organization.
|
|
75
|
+
*/
|
|
76
|
+
holds(accountId) {
|
|
77
|
+
return this.accountParents.has(accountId);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Refuse a root or organizational unit this organization never created.
|
|
81
|
+
*
|
|
82
|
+
* A handle from another simulated organization would otherwise be attached
|
|
83
|
+
* to and then never read, because no Account here has it on its path. A
|
|
84
|
+
* policy that silently applies to nothing is worse than a refusal.
|
|
85
|
+
*/
|
|
86
|
+
requireNode(nodeId) {
|
|
87
|
+
this.requireKnown(nodeId);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Whether this organization has a root or unit under an id.
|
|
91
|
+
*/
|
|
92
|
+
hasNode(nodeId) {
|
|
93
|
+
return nodeId === this.root.id || this.organizationalUnits.has(nodeId);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The nodes a request against an Account is filtered by, root first.
|
|
97
|
+
*
|
|
98
|
+
* The Account itself is the last of them, because a policy attached to an
|
|
99
|
+
* Account applies alongside the ones it inherits.
|
|
100
|
+
*/
|
|
101
|
+
pathTo(accountId) {
|
|
102
|
+
const parentId = this.accountParents.get(accountId);
|
|
103
|
+
if (parentId === undefined) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
return [...this.ancestors(parentId), accountId];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* What to call a node in a denial.
|
|
110
|
+
*/
|
|
111
|
+
nameOf(nodeId) {
|
|
112
|
+
if (nodeId === this.root.id) {
|
|
113
|
+
return this.root.name;
|
|
114
|
+
}
|
|
115
|
+
return this.organizationalUnits.get(nodeId)?.name ?? String(nodeId);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Move everything under one node up to another.
|
|
119
|
+
*/
|
|
120
|
+
reparent(fromId, toId) {
|
|
121
|
+
for (const [accountId, parentId] of this.accountParents) {
|
|
122
|
+
if (parentId === fromId) {
|
|
123
|
+
this.accountParents.set(accountId, toId);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const orphaned = this.organizationalUnits
|
|
127
|
+
.values()
|
|
128
|
+
.filter((unit) => unit.parentId === fromId)
|
|
129
|
+
.toArray();
|
|
130
|
+
for (const unit of orphaned) {
|
|
131
|
+
this.organizationalUnits.set(unit.id, new SimOrganizationsOrganizationalUnit(unit.id, unit.name, toId));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The nodes from the root down to one node, root first.
|
|
136
|
+
*/
|
|
137
|
+
ancestors(nodeId) {
|
|
138
|
+
const path = [];
|
|
139
|
+
let currentId = nodeId;
|
|
140
|
+
while (currentId !== undefined && currentId !== this.root.id) {
|
|
141
|
+
path.unshift(currentId);
|
|
142
|
+
currentId = this.organizationalUnits.get(currentId)?.parentId;
|
|
143
|
+
}
|
|
144
|
+
return [this.root.id, ...path];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Refuse a node this organization never created.
|
|
148
|
+
*/
|
|
149
|
+
requireKnown(nodeId) {
|
|
150
|
+
if (nodeId !== this.root.id && !this.organizationalUnits.has(nodeId)) {
|
|
151
|
+
throw new SimOrganizationsUnknownNode(nodeId);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -33,6 +33,7 @@ export class ChangeResourceRecordSetsAuthorizer {
|
|
|
33
33
|
if (decision.isDenied) {
|
|
34
34
|
throw new SimIamAccessDenied({
|
|
35
35
|
principal: decision.caller.principal,
|
|
36
|
+
reason: decision.denialReason,
|
|
36
37
|
action: ChangeResourceRecordSetsAuthorizer.action,
|
|
37
38
|
resource: hostedZoneArn,
|
|
38
39
|
});
|
|
@@ -29,6 +29,7 @@ export class CreateHostedZoneAuthorizer {
|
|
|
29
29
|
if (decision.isDenied) {
|
|
30
30
|
throw new SimIamAccessDenied({
|
|
31
31
|
principal: decision.caller.principal,
|
|
32
|
+
reason: decision.denialReason,
|
|
32
33
|
action: CreateHostedZoneAuthorizer.action,
|
|
33
34
|
resource: CreateHostedZoneAuthorizer.resource,
|
|
34
35
|
});
|
|
@@ -30,6 +30,7 @@ export class ListHostedZonesByNameAuthorizer {
|
|
|
30
30
|
if (decision.isDenied) {
|
|
31
31
|
throw new SimIamAccessDenied({
|
|
32
32
|
principal: decision.caller.principal,
|
|
33
|
+
reason: decision.denialReason,
|
|
33
34
|
action: ListHostedZonesByNameAuthorizer.action,
|
|
34
35
|
resource: ListHostedZonesByNameAuthorizer.resource,
|
|
35
36
|
});
|
|
@@ -33,6 +33,7 @@ export class ListResourceRecordSetsAuthorizer {
|
|
|
33
33
|
if (decision.isDenied) {
|
|
34
34
|
throw new SimIamAccessDenied({
|
|
35
35
|
principal: decision.caller.principal,
|
|
36
|
+
reason: decision.denialReason,
|
|
36
37
|
action: ListResourceRecordSetsAuthorizer.action,
|
|
37
38
|
resource: hostedZoneArn,
|
|
38
39
|
});
|
|
@@ -37,6 +37,7 @@ export class ListBucketsAuthorizer {
|
|
|
37
37
|
if (decision.isDenied) {
|
|
38
38
|
throw new SimIamAccessDenied({
|
|
39
39
|
principal: decision.caller.principal,
|
|
40
|
+
reason: decision.denialReason,
|
|
40
41
|
action: ListBucketsAuthorizer.action,
|
|
41
42
|
resource: ListBucketsAuthorizer.resource,
|
|
42
43
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kensio/yulin",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.13",
|
|
4
4
|
"description": "AWS system behaviour simulation for isolated unit testing",
|
|
5
5
|
"repository": "https://github.com/KensioSoftware/yulin",
|
|
6
6
|
"homepage": "https://yulinsim.dev/",
|
|
@@ -142,6 +142,10 @@
|
|
|
142
142
|
},
|
|
143
143
|
"./oxlint/cffjs2.oxlintrc.json": "./dist/config/oxlint/cffjs2.oxlintrc.json",
|
|
144
144
|
"./package.json": "./package.json",
|
|
145
|
+
"./organizations": {
|
|
146
|
+
"import": "./dist/service/organizations/index.js",
|
|
147
|
+
"types": "./dist/service/organizations/index.d.ts"
|
|
148
|
+
},
|
|
145
149
|
"./personalize": {
|
|
146
150
|
"import": "./dist/service/personalize/index.js",
|
|
147
151
|
"types": "./dist/service/personalize/index.d.ts"
|