@cloud-copilot/iam-simulate 0.1.81 → 0.1.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -18
- package/package.json +1 -1
- package/dist/cjs/condition/baseConditionperatorTests.d.ts +0 -18
- package/dist/cjs/condition/baseConditionperatorTests.d.ts.map +0 -1
- package/dist/cjs/condition/baseConditionperatorTests.js +0 -37
- package/dist/cjs/condition/baseConditionperatorTests.js.map +0 -1
- package/dist/esm/condition/baseConditionperatorTests.d.ts +0 -18
- package/dist/esm/condition/baseConditionperatorTests.d.ts.map +0 -1
- package/dist/esm/condition/baseConditionperatorTests.js +0 -34
- package/dist/esm/condition/baseConditionperatorTests.js.map +0 -1
package/README.md
CHANGED
|
@@ -91,30 +91,24 @@ const simulation: Simulation = {
|
|
|
91
91
|
/*
|
|
92
92
|
The default RCP `RCPFullAWSAccess` is always applied implicitly and you do not need to include it here. https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_examples.html#example-rcp-full-aws-access
|
|
93
93
|
*/
|
|
94
|
-
resourceControlPolicies: [
|
|
94
|
+
resourceControlPolicies: [
|
|
95
95
|
{
|
|
96
96
|
orgIdentifier: 'o-123456789012',
|
|
97
97
|
policies: [
|
|
98
98
|
{
|
|
99
99
|
name: 'EnforceSecureTransport',
|
|
100
100
|
policy: {
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
Version: '2012-10-17',
|
|
102
|
+
Statement: [
|
|
103
103
|
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"kms:*"
|
|
113
|
-
],
|
|
114
|
-
"Resource": "*",
|
|
115
|
-
"Condition": {
|
|
116
|
-
"BoolIfExists": {
|
|
117
|
-
"aws:SecureTransport": "false"
|
|
104
|
+
Sid: 'EnforceSecureTransport',
|
|
105
|
+
Effect: 'Deny',
|
|
106
|
+
Principal: '*',
|
|
107
|
+
Action: ['sts:*', 's3:*', 'sqs:*', 'secretsmanager:*', 'kms:*'],
|
|
108
|
+
Resource: '*',
|
|
109
|
+
Condition: {
|
|
110
|
+
BoolIfExists: {
|
|
111
|
+
'aws:SecureTransport': 'false'
|
|
118
112
|
}
|
|
119
113
|
}
|
|
120
114
|
}
|
|
@@ -123,7 +117,7 @@ const simulation: Simulation = {
|
|
|
123
117
|
}
|
|
124
118
|
]
|
|
125
119
|
}
|
|
126
|
-
|
|
120
|
+
],
|
|
127
121
|
resourcePolicy: {
|
|
128
122
|
Version: '2012-10-17',
|
|
129
123
|
Statement: [
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseConditionOperator } from './BaseConditionOperator.js';
|
|
2
|
-
export interface BaseOperatorTest {
|
|
3
|
-
name: string;
|
|
4
|
-
requestContext?: {
|
|
5
|
-
[key: string]: string | string[];
|
|
6
|
-
};
|
|
7
|
-
policyValues: string[];
|
|
8
|
-
testValue: string;
|
|
9
|
-
expected: boolean;
|
|
10
|
-
explains?: {
|
|
11
|
-
value: string;
|
|
12
|
-
matches: boolean;
|
|
13
|
-
resolvedValue?: string;
|
|
14
|
-
errors?: string[];
|
|
15
|
-
}[];
|
|
16
|
-
}
|
|
17
|
-
export declare function testOperator(name: string, tests: BaseOperatorTest[], operator: BaseConditionOperator): void;
|
|
18
|
-
//# sourceMappingURL=baseConditionperatorTests.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseConditionperatorTests.d.ts","sourceRoot":"","sources":["../../../src/condition/baseConditionperatorTests.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAElE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;IACrD,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,OAAO,CAAA;QAChB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAClB,EAAE,CAAA;CACJ;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,gBAAgB,EAAE,EACzB,QAAQ,EAAE,qBAAqB,QAwChC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.testOperator = testOperator;
|
|
4
|
-
const vitest_1 = require("vitest");
|
|
5
|
-
const request_js_1 = require("../request/request.js");
|
|
6
|
-
const requestContext_js_1 = require("../requestContext.js");
|
|
7
|
-
function testOperator(name, tests, operator) {
|
|
8
|
-
(0, vitest_1.describe)(name, (it) => {
|
|
9
|
-
for (const test of tests) {
|
|
10
|
-
it(test.name, () => {
|
|
11
|
-
//Given the request
|
|
12
|
-
const request = new request_js_1.AwsRequestImpl('', { resource: '', accountId: '' }, '', new requestContext_js_1.RequestContextImpl(test.requestContext || {}));
|
|
13
|
-
//When the condition is evaluated
|
|
14
|
-
const result = operator.matches(request, test.testValue, test.policyValues);
|
|
15
|
-
//Then the result should be as expected
|
|
16
|
-
(0, vitest_1.expect)(result.matches).toBe(test.expected);
|
|
17
|
-
if (test.explains) {
|
|
18
|
-
for (const explain of test.explains) {
|
|
19
|
-
const found = result.explains.find((e) => e.value === explain.value);
|
|
20
|
-
(0, vitest_1.expect)(found, `Missing explain for ${explain.value}`).toBeDefined();
|
|
21
|
-
(0, vitest_1.expect)(found?.matches, `${explain.value} match`).toBe(explain.matches);
|
|
22
|
-
if (explain.resolvedValue) {
|
|
23
|
-
(0, vitest_1.expect)(found?.resolvedValue, `${explain.value} resolved value`).toBe(explain.resolvedValue);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
(0, vitest_1.expect)(found?.resolvedValue, `${explain.value} resolved value to be undefined`).toBeUndefined();
|
|
27
|
-
}
|
|
28
|
-
if (explain.errors) {
|
|
29
|
-
(0, vitest_1.expect)(found?.errors, `${explain.value} errors`).toEqual(explain.errors.sort());
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=baseConditionperatorTests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseConditionperatorTests.js","sourceRoot":"","sources":["../../../src/condition/baseConditionperatorTests.ts"],"names":[],"mappings":";;AAmBA,oCA2CC;AA9DD,mCAAyC;AACzC,sDAAsD;AACtD,4DAAyD;AAiBzD,SAAgB,YAAY,CAC1B,IAAY,EACZ,KAAyB,EACzB,QAA+B;IAE/B,IAAA,iBAAQ,EAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE;QACpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;gBACjB,mBAAmB;gBACnB,MAAM,OAAO,GAAG,IAAI,2BAAc,CAChC,EAAE,EACF,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAC/B,EAAE,EACF,IAAI,sCAAkB,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,CAClD,CAAA;gBACD,iCAAiC;gBACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;gBAE3E,uCAAuC;gBACvC,IAAA,eAAM,EAAC,MAAM,C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seConditionOperator } from './BaseConditionOperator.js';
|
|
2
|
-
export interface BaseOperatorTest {
|
|
3
|
-
name: string;
|
|
4
|
-
requestContext?: {
|
|
5
|
-
[key: string]: string | string[];
|
|
6
|
-
};
|
|
7
|
-
policyValues: string[];
|
|
8
|
-
testValue: string;
|
|
9
|
-
expected: boolean;
|
|
10
|
-
explains?: {
|
|
11
|
-
value: string;
|
|
12
|
-
matches: boolean;
|
|
13
|
-
resolvedValue?: string;
|
|
14
|
-
errors?: string[];
|
|
15
|
-
}[];
|
|
16
|
-
}
|
|
17
|
-
export declare function testOperator(name: string, tests: BaseOperatorTest[], operator: BaseConditionOperator): void;
|
|
18
|
-
//# sourceMappingURL=baseConditionperatorTests.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseConditionperatorTests.d.ts","sourceRoot":"","sources":["../../../src/condition/baseConditionperatorTests.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAElE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;IACrD,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,OAAO,CAAA;QAChB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAClB,EAAE,CAAA;CACJ;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,gBAAgB,EAAE,EACzB,QAAQ,EAAE,qBAAqB,QAwChC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect } from 'vitest';
|
|
2
|
-
import { AwsRequestImpl } from '../request/request.js';
|
|
3
|
-
import { RequestContextImpl } from '../requestContext.js';
|
|
4
|
-
export function testOperator(name, tests, operator) {
|
|
5
|
-
describe(name, (it) => {
|
|
6
|
-
for (const test of tests) {
|
|
7
|
-
it(test.name, () => {
|
|
8
|
-
//Given the request
|
|
9
|
-
const request = new AwsRequestImpl('', { resource: '', accountId: '' }, '', new RequestContextImpl(test.requestContext || {}));
|
|
10
|
-
//When the condition is evaluated
|
|
11
|
-
const result = operator.matches(request, test.testValue, test.policyValues);
|
|
12
|
-
//Then the result should be as expected
|
|
13
|
-
expect(result.matches).toBe(test.expected);
|
|
14
|
-
if (test.explains) {
|
|
15
|
-
for (const explain of test.explains) {
|
|
16
|
-
const found = result.explains.find((e) => e.value === explain.value);
|
|
17
|
-
expect(found, `Missing explain for ${explain.value}`).toBeDefined();
|
|
18
|
-
expect(found?.matches, `${explain.value} match`).toBe(explain.matches);
|
|
19
|
-
if (explain.resolvedValue) {
|
|
20
|
-
expect(found?.resolvedValue, `${explain.value} resolved value`).toBe(explain.resolvedValue);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
expect(found?.resolvedValue, `${explain.value} resolved value to be undefined`).toBeUndefined();
|
|
24
|
-
}
|
|
25
|
-
if (explain.errors) {
|
|
26
|
-
expect(found?.errors, `${explain.value} errors`).toEqual(explain.errors.sort());
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=baseConditionperatorTests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseConditionperatorTests.js","sourceRoot":"","sources":["../../../src/condition/baseConditionperatorTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAA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