@cloud-copilot/iam-simulate 0.1.106 → 0.1.108
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/cjs/StatementAnalysis.d.ts.map +1 -1
- package/dist/cjs/StatementAnalysis.js +0 -18
- package/dist/cjs/StatementAnalysis.js.map +1 -1
- package/dist/cjs/analysis/analyzeResults.d.ts +33 -2
- package/dist/cjs/analysis/analyzeResults.d.ts.map +1 -1
- package/dist/cjs/analysis/analyzeResults.js +35 -15
- package/dist/cjs/analysis/analyzeResults.js.map +1 -1
- package/dist/cjs/evaluate.d.ts +17 -0
- package/dist/cjs/evaluate.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/DefaultServiceAuthorizer.d.ts +16 -0
- package/dist/cjs/services/DefaultServiceAuthorizer.d.ts.map +1 -1
- package/dist/cjs/services/DefaultServiceAuthorizer.js +149 -107
- package/dist/cjs/services/DefaultServiceAuthorizer.js.map +1 -1
- package/dist/esm/StatementAnalysis.d.ts.map +1 -1
- package/dist/esm/StatementAnalysis.js +0 -18
- package/dist/esm/StatementAnalysis.js.map +1 -1
- package/dist/esm/analysis/analyzeResults.d.ts +33 -2
- package/dist/esm/analysis/analyzeResults.d.ts.map +1 -1
- package/dist/esm/analysis/analyzeResults.js +35 -15
- package/dist/esm/analysis/analyzeResults.js.map +1 -1
- package/dist/esm/evaluate.d.ts +17 -0
- package/dist/esm/evaluate.d.ts.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/DefaultServiceAuthorizer.d.ts +16 -0
- package/dist/esm/services/DefaultServiceAuthorizer.d.ts.map +1 -1
- package/dist/esm/services/DefaultServiceAuthorizer.js +147 -107
- package/dist/esm/services/DefaultServiceAuthorizer.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatementAnalysis.d.ts","sourceRoot":"","sources":["../../src/StatementAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAEpE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAA;IAEtB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IAEpB;;OAEG;IACH,cAAc,EAAE,oBAAoB,CAAA;IAEpC;;OAEG;IACH,cAAc,EAAE,oBAAoB,CAAA;IAEpC;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAA;IAEzB;;OAEG;IACH,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAA;IAE/B;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAU7E;
|
|
1
|
+
{"version":3,"file":"StatementAnalysis.d.ts","sourceRoot":"","sources":["../../src/StatementAnalysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAEpE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAA;IAEtB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IAEpB;;OAEG;IACH,cAAc,EAAE,oBAAoB,CAAA;IAEpC;;OAEG;IACH,cAAc,EAAE,oBAAoB,CAAA;IAEpC;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAA;IAEzB;;OAEG;IACH,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAA;IAE/B;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAU7E;AAED,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAUnF;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,IAAI,CACZ,iBAAiB,EACjB,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,eAAe,CACtE,GACA,OAAO,CAST;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,gBAAgB,GAAG,eAAe,CAAC,GACpF,OAAO,CAQT"}
|
|
@@ -19,24 +19,6 @@ function identityStatementAllows(statement) {
|
|
|
19
19
|
}
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
// export function identityStatementUknownAllow(statement: StatementAnalysis): boolean {
|
|
23
|
-
// if(statement.resourceMatch &&
|
|
24
|
-
// statement.actionMatch &&
|
|
25
|
-
// statement.conditionMatch === 'Unknown' &&
|
|
26
|
-
// statement.statement.effect() === 'Allow') {
|
|
27
|
-
// return true;
|
|
28
|
-
// }
|
|
29
|
-
// return false
|
|
30
|
-
// }
|
|
31
|
-
// export function identityStatementUknownDeny(statement: StatementAnalysis): boolean {
|
|
32
|
-
// if(statement.resourceMatch &&
|
|
33
|
-
// statement.actionMatch &&
|
|
34
|
-
// statement.conditionMatch === 'Unknown' &&
|
|
35
|
-
// statement.statement.effect() === 'Deny') {
|
|
36
|
-
// return true;
|
|
37
|
-
// }
|
|
38
|
-
// return false
|
|
39
|
-
// }
|
|
40
22
|
function identityStatementExplicitDeny(statement) {
|
|
41
23
|
if (statement.resourceMatch &&
|
|
42
24
|
statement.actionMatch &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatementAnalysis.js","sourceRoot":"","sources":["../../src/StatementAnalysis.ts"],"names":[],"mappings":";;AA8DA,0DAUC;
|
|
1
|
+
{"version":3,"file":"StatementAnalysis.js","sourceRoot":"","sources":["../../src/StatementAnalysis.ts"],"names":[],"mappings":";;AA8DA,0DAUC;AAED,sEAUC;AAED,4CAcC;AAQD,0DAUC;AA9DD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,SAA4B;IAClE,IACE,SAAS,CAAC,aAAa;QACvB,SAAS,CAAC,WAAW;QACrB,SAAS,CAAC,cAAc,KAAK,OAAO;QACpC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,OAAO,EACxC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAgB,6BAA6B,CAAC,SAA4B;IACxE,IACE,SAAS,CAAC,aAAa;QACvB,SAAS,CAAC,WAAW;QACrB,SAAS,CAAC,cAAc,KAAK,OAAO;QACpC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,MAAM,EACvC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAgB,gBAAgB,CAC9B,QAGC;IAED,OAAO,CACL,QAAQ,CAAC,aAAa;QACtB,QAAQ,CAAC,WAAW;QACpB,QAAQ,CAAC,cAAc,KAAK,OAAO;QACnC,CAAC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAC7E,QAAQ,CAAC,cAAc,CACxB,CACF,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,QAAqF;IAErF,OAAO,CACL,QAAQ,CAAC,aAAa;QACtB,QAAQ,CAAC,WAAW;QACpB,CAAC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAC7E,QAAQ,CAAC,cAAc,CACxB,CACF,CAAA;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestAnalysis } from '../evaluate.js';
|
|
1
|
+
import { type BlockedReason, type RequestAnalysis } from '../evaluate.js';
|
|
2
2
|
/**
|
|
3
3
|
* Analyze a RequestAnalysis to see if the request was allowed by identity policies.
|
|
4
4
|
*
|
|
@@ -6,15 +6,46 @@ import { type RequestAnalysis } from '../evaluate.js';
|
|
|
6
6
|
* @returns true if the request was allowed by identity policies, false otherwise
|
|
7
7
|
*/
|
|
8
8
|
export declare function isAllowedByIdentityPolicies(requestAnalysis: RequestAnalysis): boolean;
|
|
9
|
-
export type DenialPolicyType =
|
|
9
|
+
export type DenialPolicyType = BlockedReason;
|
|
10
10
|
export type RequestDenial = {
|
|
11
|
+
/**
|
|
12
|
+
* The type of policy that caused the denial.
|
|
13
|
+
*/
|
|
11
14
|
policyType: DenialPolicyType;
|
|
15
|
+
/**
|
|
16
|
+
* This denial blocks a request that otherwise could have been allowed.
|
|
17
|
+
*/
|
|
18
|
+
blocking?: true;
|
|
19
|
+
/**
|
|
20
|
+
* The identifier of the policy that caused the denial, if applicable. This could be a
|
|
21
|
+
* policy identifier or an organizational unit identifier for SCPs and RCPs.
|
|
22
|
+
*/
|
|
12
23
|
identifier?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The type of denial.
|
|
26
|
+
*/
|
|
13
27
|
denialType: 'Implicit';
|
|
14
28
|
} | {
|
|
29
|
+
/**
|
|
30
|
+
* The type of policy that caused the denial.
|
|
31
|
+
*/
|
|
15
32
|
policyType: DenialPolicyType;
|
|
33
|
+
/**
|
|
34
|
+
* This denial blocks a request that otherwise could have been allowed.
|
|
35
|
+
*/
|
|
36
|
+
blocking?: true;
|
|
37
|
+
/**
|
|
38
|
+
* The identifier of the policy that caused the denial. May be undefined, for example
|
|
39
|
+
* in a resource policy.
|
|
40
|
+
*/
|
|
16
41
|
policyIdentifier?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The statement ID (or index) of the denying statement, if applicable.
|
|
44
|
+
*/
|
|
17
45
|
statementId: string;
|
|
46
|
+
/**
|
|
47
|
+
* The type of denial.
|
|
48
|
+
*/
|
|
18
49
|
denialType: 'Explicit';
|
|
19
50
|
};
|
|
20
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeResults.d.ts","sourceRoot":"","sources":["../../../src/analysis/analyzeResults.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"analyzeResults.d.ts","sourceRoot":"","sources":["../../../src/analysis/analyzeResults.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAIlB,KAAK,eAAe,EAGrB,MAAM,gBAAgB,CAAA;AAEvB;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAOrF;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAE5C,MAAM,MAAM,aAAa,GACrB;IACE;;OAEG;IACH,UAAU,EAAE,gBAAgB,CAAA;IAE5B;;OAEG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAA;IAEf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB,GACD;IACE;;OAEG;IACH,UAAU,EAAE,gBAAgB,CAAA;IAE5B;;OAEG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAA;IAEf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAEL;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,aAAa,EAAE,CAqClF"}
|
|
@@ -34,28 +34,38 @@ function isAllowedByIdentityPolicies(requestAnalysis) {
|
|
|
34
34
|
function getDenialReasons(requestAnalysis) {
|
|
35
35
|
const denials = [];
|
|
36
36
|
const overallResult = requestAnalysis.result;
|
|
37
|
-
|
|
38
|
-
addSimplePolicyDenials(requestAnalysis.
|
|
39
|
-
|
|
40
|
-
addOuPolicyDenials(requestAnalysis.
|
|
41
|
-
|
|
42
|
-
addSimplePolicyDenials(requestAnalysis.
|
|
37
|
+
const blockedBy = new Set(requestAnalysis.blockedBy ?? []);
|
|
38
|
+
addSimplePolicyDenials(requestAnalysis.identityAnalysis, 'identity', overallResult, blockedBy, denials);
|
|
39
|
+
addSimplePolicyDenials(requestAnalysis.resourceAnalysis, 'resource', overallResult, blockedBy, denials);
|
|
40
|
+
addOuPolicyDenials(requestAnalysis.scpAnalysis, 'scp', overallResult, blockedBy, denials);
|
|
41
|
+
addOuPolicyDenials(requestAnalysis.rcpAnalysis, 'rcp', overallResult, blockedBy, denials);
|
|
42
|
+
addSimplePolicyDenials(requestAnalysis.permissionBoundaryAnalysis, 'pb', overallResult, blockedBy, denials);
|
|
43
|
+
addSimplePolicyDenials(requestAnalysis.endpointAnalysis, 'vpce', overallResult, blockedBy, denials);
|
|
43
44
|
return denials;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Helper for identity-style policies (identity, resource, permissionBoundary, endpoint).
|
|
47
48
|
* Adds denial reasons from a simple policy analysis.
|
|
48
49
|
*/
|
|
49
|
-
function addSimplePolicyDenials(analysis, policyType, overallResult, denials) {
|
|
50
|
+
function addSimplePolicyDenials(analysis, policyType, overallResult, blockedBy, denials) {
|
|
50
51
|
if (!analysis)
|
|
51
52
|
return;
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
const isBlocking = blockedBy.has(policyType);
|
|
54
|
+
const blocking = isBlocking ? { blocking: true } : {};
|
|
55
|
+
if (analysis.result === 'ImplicitlyDenied' &&
|
|
56
|
+
(isBlocking || overallResult === 'ImplicitlyDenied')) {
|
|
57
|
+
denials.push({
|
|
58
|
+
policyType,
|
|
59
|
+
denialType: 'Implicit',
|
|
60
|
+
...blocking
|
|
61
|
+
});
|
|
54
62
|
}
|
|
55
|
-
else if (analysis.result === 'ExplicitlyDenied' &&
|
|
63
|
+
else if (analysis.result === 'ExplicitlyDenied' &&
|
|
64
|
+
(isBlocking || overallResult === 'ExplicitlyDenied')) {
|
|
56
65
|
for (const stmt of analysis.denyStatements) {
|
|
57
66
|
denials.push({
|
|
58
67
|
policyType,
|
|
68
|
+
...blocking,
|
|
59
69
|
policyIdentifier: stmt.policyId,
|
|
60
70
|
statementId: stmt.statement.sid() || stmt.statement.index().toString(),
|
|
61
71
|
denialType: 'Explicit'
|
|
@@ -67,17 +77,26 @@ function addSimplePolicyDenials(analysis, policyType, overallResult, denials) {
|
|
|
67
77
|
* Helper for OU-based policies (scp, rcp).
|
|
68
78
|
* Adds denial reasons from an organizational policy analysis.
|
|
69
79
|
*/
|
|
70
|
-
function addOuPolicyDenials(analysis, policyType, overallResult, denials) {
|
|
80
|
+
function addOuPolicyDenials(analysis, policyType, overallResult, blockedBy, denials) {
|
|
71
81
|
if (!analysis)
|
|
72
82
|
return;
|
|
73
|
-
|
|
83
|
+
const isBlocking = blockedBy.has(policyType);
|
|
84
|
+
const blocking = isBlocking ? { blocking: true } : {};
|
|
85
|
+
if (analysis.result === 'ImplicitlyDenied' &&
|
|
86
|
+
(isBlocking || overallResult === 'ImplicitlyDenied')) {
|
|
74
87
|
for (const ou of analysis.ouAnalysis) {
|
|
75
88
|
if (ou.result === 'ImplicitlyDenied') {
|
|
76
|
-
denials.push({
|
|
89
|
+
denials.push({
|
|
90
|
+
policyType,
|
|
91
|
+
identifier: ou.orgIdentifier,
|
|
92
|
+
denialType: 'Implicit',
|
|
93
|
+
...blocking
|
|
94
|
+
});
|
|
77
95
|
}
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
|
-
else if (analysis.result === 'ExplicitlyDenied' &&
|
|
98
|
+
else if (analysis.result === 'ExplicitlyDenied' &&
|
|
99
|
+
(isBlocking || overallResult === 'ExplicitlyDenied')) {
|
|
81
100
|
for (const ou of analysis.ouAnalysis) {
|
|
82
101
|
if (ou.result === 'ExplicitlyDenied') {
|
|
83
102
|
for (const stmt of ou.denyStatements) {
|
|
@@ -85,7 +104,8 @@ function addOuPolicyDenials(analysis, policyType, overallResult, denials) {
|
|
|
85
104
|
policyType,
|
|
86
105
|
policyIdentifier: stmt.policyId,
|
|
87
106
|
statementId: stmt.statement.sid() || stmt.statement.index().toString(),
|
|
88
|
-
denialType: 'Explicit'
|
|
107
|
+
denialType: 'Explicit',
|
|
108
|
+
...blocking
|
|
89
109
|
});
|
|
90
110
|
}
|
|
91
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeResults.js","sourceRoot":"","sources":["../../../src/analysis/analyzeResults.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"analyzeResults.js","sourceRoot":"","sources":["../../../src/analysis/analyzeResults.ts"],"names":[],"mappings":";;AAgBA,kEAOC;AAuED,4CAqCC;AAzHD;;;;;GAKG;AACH,SAAgB,2BAA2B,CAAC,eAAgC;IAC1E,MAAM,gBAAgB,GAAG,eAAe,CAAC,gBAAgB,CAAA;IACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,KAAK,CAAA;IACd,CAAC;IAED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C,OAAO,CAAC,IAAI,CAAC;oBACX,UAAU;oBACV,UAAU,EAAE,EAAE,CAAC,aAAa;oBAC5B,UAAU,EAAE,UAAU;oBACtB,GAAG,QAAQ;iBACZ,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;SAAM,IACL,QAAQ,CAAC,MAAM,KAAK,kBAAkB;QACtC,CAAC,UAAU,IAAI,aAAa,KAAK,kBAAkB,CAAC,EACpD,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,EAAE,CAAC,MAAM,KAAK,kBAAkB,EAAE,CAAC;gBACrC,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC;oBACrC,OAAO,CAAC,IAAI,CAAC;wBACX,UAAU;wBACV,gBAAgB,EAAE,IAAI,CAAC,QAAQ;wBAC/B,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;wBACtE,UAAU,EAAE,UAAU;wBACtB,GAAG,QAAQ;qBACZ,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/cjs/evaluate.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type StatementAnalysis } from './StatementAnalysis.js';
|
|
2
2
|
export type EvaluationResult = 'Allowed' | 'ExplicitlyDenied' | 'ImplicitlyDenied';
|
|
3
3
|
export type ResourceEvaluationResult = 'NotApplicable' | 'Allowed' | 'ExplicitlyDenied' | 'AllowedForAccount' | 'DeniedForAccount' | 'ImplicitlyDenied';
|
|
4
|
+
export type BlockedReason = 'scp' | 'rcp' | 'vpce' | 'identity' | 'resource' | 'pb';
|
|
4
5
|
export interface IdentityAnalysis {
|
|
5
6
|
result: EvaluationResult;
|
|
6
7
|
denyStatements: StatementAnalysis[];
|
|
@@ -127,5 +128,21 @@ export interface RequestAnalysis {
|
|
|
127
128
|
* If the role session name was ignored during discovery mode.
|
|
128
129
|
*/
|
|
129
130
|
ignoredRoleSessionName?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* If the request has policies to allow the request in session, identity, and/or resource policies required, but was blocked
|
|
133
|
+
* by another policy, this includes the policy types that blocked the request.
|
|
134
|
+
*
|
|
135
|
+
* It is possible for a request to have been allowed by the identity policy but blocked by the resource policy and vice versa.
|
|
136
|
+
*
|
|
137
|
+
* If this array is undefined or empty, it means that the core session, identity, and/or resource policies did
|
|
138
|
+
* not grant permission. It does not mean that there are no guardrails in place, just that the request was
|
|
139
|
+
* not allowed by the core policies, so there is no need to look for guardrails that block an otherwise allowed request.
|
|
140
|
+
*
|
|
141
|
+
* "Allowed by core policies" means that it would have been allowed if not for the policies identified in `blockedBy`. So
|
|
142
|
+
* by removing the policies identified in `blockedBy`, the request would be allowed.
|
|
143
|
+
*
|
|
144
|
+
* Use this to discover what guardrails are in place that might block access even if it may be allowed by other policies.
|
|
145
|
+
*/
|
|
146
|
+
blockedBy?: BlockedReason[];
|
|
130
147
|
}
|
|
131
148
|
//# sourceMappingURL=evaluate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,kBAAkB,GAAG,kBAAkB,CAAA;AAClF,MAAM,MAAM,wBAAwB,GAChC,eAAe,GACf,SAAS,GACT,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,GAClB,kBAAkB,CAAA;AAEtB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,gBAAgB,CAAA;IACxB,cAAc,EAAE,iBAAiB,EAAE,CAAA;IACnC,eAAe,EAAE,iBAAiB,EAAE,CAAA;IACpC,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Ac,CAAC,EAAE;QACf,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAA;QAC1B,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAA;KAC1B,CAAA;CACF;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAA;IAExB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IAEpB;;OAEG;IACH,eAAe,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;IAE9C;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IAEnC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IAEnC;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IAEzB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IAEzB;;OAEG;IACH,0BAA0B,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;IAEzD;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;IAE/C;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IAErC;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAEhC;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE,aAAa,EAAE,CAAA;CAC5B"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { getDenialReasons, type DenialPolicyType, type RequestDenial } from './analysis/analyzeResults.js';
|
|
2
2
|
export { typeForContextKey } from './context_keys/contextKeys.js';
|
|
3
|
-
export { type BaseConditionKeyType,
|
|
3
|
+
export { isConditionKeyArray, type BaseConditionKeyType, type ConditionKeyType } from './context_keys/contextKeyTypes.js';
|
|
4
4
|
export { findContextKeys } from './context_keys/findContextKeys.js';
|
|
5
5
|
export type { SimulationMode } from './core_engine/CoreSimulatorEngine.js';
|
|
6
|
-
export type { EvaluationResult, IgnoredCondition, IgnoredConditions, RequestAnalysis } from './evaluate.js';
|
|
6
|
+
export type { BlockedReason, EvaluationResult, IgnoredCondition, IgnoredConditions, RequestAnalysis } from './evaluate.js';
|
|
7
7
|
export type { ActionExplain, ConditionExplain, ConditionValueExplain, ExplainPrincipalMatch, PrincipalExplain, ResourceExplain, StatementExplain } from './explain/statementExplain.js';
|
|
8
8
|
export { allowedContextKeysForRequest } from './simulation_engine/contextKeys.js';
|
|
9
9
|
export type { Simulation, SimulationIdentityPolicy, SimulationOrgPolicies } from './simulation_engine/simulation.js';
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EACL,KAAK,oBAAoB,EACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACtB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,YAAY,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAC1E,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EAChB,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAA;AACjF,YAAY,EACV,UAAU,EACV,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AACvE,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAC9B,iCAAiC,EACjC,gCAAgC,EACjC,MAAM,yCAAyC,CAAA;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,kEAIqC;AAHnC,qHAAA,gBAAgB,OAAA;AAIlB,gEAAiE;AAAxD,mHAAA,iBAAiB,OAAA;AAC1B,wEAI0C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,kEAIqC;AAHnC,qHAAA,gBAAgB,OAAA;AAIlB,gEAAiE;AAAxD,mHAAA,iBAAiB,OAAA;AAC1B,wEAI0C;AAHxC,yHAAA,mBAAmB,OAAA;AAIrB,wEAAmE;AAA1D,qHAAA,eAAe,OAAA;AAkBxB,qEAAiF;AAAxE,8HAAA,4BAA4B,OAAA;AAMrC,+EAAuE;AAA9D,oHAAA,aAAa,OAAA;AAatB,2FAAmF;AAA1E,gIAAA,mBAAmB,OAAA;AAC5B,qCAAgD;AAAvC,+GAAA,oBAAoB,OAAA"}
|
|
@@ -20,5 +20,21 @@ export declare class DefaultServiceAuthorizer implements ServiceAuthorizer {
|
|
|
20
20
|
* @returns true if the service trusts the principal's account IAM policies
|
|
21
21
|
*/
|
|
22
22
|
serviceTrustsPrincipalAccount(sameAccount: boolean, resourceAnalysis: ResourceAnalysis, resource: RequestResource): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Evaluations whether the minimum requirements for the request to be allowed are met based on the core policies
|
|
25
|
+
* - Identity
|
|
26
|
+
* - Resource
|
|
27
|
+
* - Session
|
|
28
|
+
*
|
|
29
|
+
* Depending on the service, and whether the principal and resources are in the same account, the requirements may differ.
|
|
30
|
+
* For same account requests, for most services an Allow in the resource policy or the identity policy is sufficient to
|
|
31
|
+
* allow the request, so this function will return 'Allowed'. If there is an explicit deny elsewhere, that is not considered.
|
|
32
|
+
* This function only determines if there are enough core policies to allow the request, and final determination of the
|
|
33
|
+
* request is done elsewhere.
|
|
34
|
+
*
|
|
35
|
+
* @param request the service authorization request containing all analyses
|
|
36
|
+
* @returns 'Allowed' if the core policies allow the request, otherwise may return 'ImplicitlyDenied' or 'ExplicitlyDenied' depending on the analyses
|
|
37
|
+
*/
|
|
38
|
+
private initialEvaluationResult;
|
|
23
39
|
}
|
|
24
40
|
//# sourceMappingURL=DefaultServiceAuthorizer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultServiceAuthorizer.d.ts","sourceRoot":"","sources":["../../../src/services/DefaultServiceAuthorizer.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"DefaultServiceAuthorizer.d.ts","sourceRoot":"","sources":["../../../src/services/DefaultServiceAuthorizer.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAuEjG;;GAEG;AACH,qBAAa,wBAAyB,YAAW,iBAAiB;IAChE;;;;;OAKG;IACI,SAAS,CAAC,OAAO,EAAE,2BAA2B,GAAG,eAAe;IAuIvE;;;;;;OAMG;IACH,6BAA6B,CAC3B,WAAW,EAAE,OAAO,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,eAAe,GACxB,OAAO;IAUV;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,uBAAuB;CA+ChC"}
|
|
@@ -2,6 +2,71 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultServiceAuthorizer = void 0;
|
|
4
4
|
const iam_utils_1 = require("@cloud-copilot/iam-utils");
|
|
5
|
+
/**
|
|
6
|
+
* This helper class keeps track of which factors are blocking a request and what the overall result is
|
|
7
|
+
* based on those blocks.
|
|
8
|
+
*/
|
|
9
|
+
class BlockedByLog {
|
|
10
|
+
coreResult;
|
|
11
|
+
blockedBy = new Set();
|
|
12
|
+
result;
|
|
13
|
+
/**
|
|
14
|
+
* Create the BlockedByLog
|
|
15
|
+
*
|
|
16
|
+
* @param coreResult the core result of the authorization. Is the request allowed or denied based on the core policies (identity, resource, session).
|
|
17
|
+
*/
|
|
18
|
+
constructor(coreResult) {
|
|
19
|
+
this.coreResult = coreResult;
|
|
20
|
+
this.result = coreResult;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Add a blocking factor to the log and update the overall result accordingly.
|
|
24
|
+
*
|
|
25
|
+
* @param reason the reason for the block.
|
|
26
|
+
* @param result the result of the block (ImplicitlyDenied, ExplicitlyDenied)
|
|
27
|
+
*/
|
|
28
|
+
add(reason, result) {
|
|
29
|
+
if (this.coreResult === 'Allowed' && result !== 'Allowed') {
|
|
30
|
+
this.blockedBy.add(reason);
|
|
31
|
+
}
|
|
32
|
+
this.setResult(result);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calculates and sets the new overall result based on the new block reason and the previous result.
|
|
36
|
+
*
|
|
37
|
+
* The result can only be modified down so Allowed -> ImplicitlyDenied -> ExplicitlyDenied.
|
|
38
|
+
*
|
|
39
|
+
* @param newResult the result of the new block reason being added.
|
|
40
|
+
*/
|
|
41
|
+
setResult(newResult) {
|
|
42
|
+
// Explicit denies override everything
|
|
43
|
+
if (this.result === 'ExplicitlyDenied') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (newResult === 'ExplicitlyDenied') {
|
|
47
|
+
this.result = 'ExplicitlyDenied';
|
|
48
|
+
}
|
|
49
|
+
else if (newResult === 'ImplicitlyDenied') {
|
|
50
|
+
this.result = 'ImplicitlyDenied';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the overall result after all blocks (if any) have been added.
|
|
55
|
+
*
|
|
56
|
+
* @returns the overall result after all blocks (if any) have been added.
|
|
57
|
+
*/
|
|
58
|
+
getResult() {
|
|
59
|
+
return this.result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the list of reasons that are blocking the request after the core result.
|
|
63
|
+
*
|
|
64
|
+
* @returns an array of reasons that are blocking the request after the core result.
|
|
65
|
+
*/
|
|
66
|
+
getBlockedBy() {
|
|
67
|
+
return Array.from(this.blockedBy);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
5
70
|
/**
|
|
6
71
|
* The default authorizer for services.
|
|
7
72
|
*/
|
|
@@ -15,7 +80,6 @@ class DefaultServiceAuthorizer {
|
|
|
15
80
|
authorize(request) {
|
|
16
81
|
const scpResult = request.scpAnalysis.result;
|
|
17
82
|
const rcpResult = request.rcpAnalysis.result;
|
|
18
|
-
const sessionResult = request.sessionAnalysis?.result;
|
|
19
83
|
const identityStatementResult = request.identityAnalysis.result;
|
|
20
84
|
const resourcePolicyResult = request.resourceAnalysis?.result;
|
|
21
85
|
const permissionBoundaryResult = request.permissionBoundaryAnalysis?.result;
|
|
@@ -33,66 +97,26 @@ class DefaultServiceAuthorizer {
|
|
|
33
97
|
permissionBoundaryAnalysis: request.permissionBoundaryAnalysis,
|
|
34
98
|
endpointAnalysis: request.endpointAnalysis
|
|
35
99
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (rcpResult !== 'Allowed') {
|
|
43
|
-
return {
|
|
44
|
-
result: rcpResult,
|
|
45
|
-
...baseResult
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (sessionResult && sessionResult !== 'Allowed') {
|
|
49
|
-
return {
|
|
50
|
-
result: sessionResult,
|
|
51
|
-
...baseResult
|
|
52
|
-
};
|
|
53
|
-
}
|
|
100
|
+
const coreResult = this.initialEvaluationResult(request);
|
|
101
|
+
const blockedByLog = new BlockedByLog(coreResult);
|
|
102
|
+
blockedByLog.add('scp', scpResult);
|
|
103
|
+
blockedByLog.add('rcp', rcpResult);
|
|
54
104
|
if (endpointPolicyResult === 'ExplicitlyDenied' ||
|
|
55
105
|
endpointPolicyResult === 'ImplicitlyDenied') {
|
|
56
|
-
|
|
57
|
-
result: endpointPolicyResult,
|
|
58
|
-
...baseResult
|
|
59
|
-
};
|
|
106
|
+
blockedByLog.add('vpce', endpointPolicyResult);
|
|
60
107
|
}
|
|
61
108
|
if (resourcePolicyResult === 'ExplicitlyDenied' ||
|
|
62
109
|
resourcePolicyResult === 'DeniedForAccount') {
|
|
63
|
-
|
|
64
|
-
result: 'ExplicitlyDenied',
|
|
65
|
-
...baseResult
|
|
66
|
-
};
|
|
110
|
+
blockedByLog.add('resource', 'ExplicitlyDenied');
|
|
67
111
|
}
|
|
68
112
|
if (identityStatementResult === 'ExplicitlyDenied') {
|
|
69
|
-
|
|
70
|
-
result: 'ExplicitlyDenied',
|
|
71
|
-
...baseResult
|
|
72
|
-
};
|
|
113
|
+
blockedByLog.add('identity', 'ExplicitlyDenied');
|
|
73
114
|
}
|
|
74
115
|
if (permissionBoundaryResult === 'ExplicitlyDenied') {
|
|
75
|
-
|
|
76
|
-
result: 'ExplicitlyDenied',
|
|
77
|
-
...baseResult
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
// Service Principals
|
|
81
|
-
if ((0, iam_utils_1.isServicePrincipal)(request.request.principal.value())) {
|
|
82
|
-
// Service principals are allowed if the resource policy allows them
|
|
83
|
-
if (resourcePolicyResult === 'Allowed') {
|
|
84
|
-
return {
|
|
85
|
-
result: 'Allowed',
|
|
86
|
-
...baseResult
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
result: 'ImplicitlyDenied',
|
|
91
|
-
...baseResult
|
|
92
|
-
};
|
|
116
|
+
blockedByLog.add('pb', 'ExplicitlyDenied');
|
|
93
117
|
}
|
|
94
118
|
//Same Account
|
|
95
|
-
if (
|
|
119
|
+
if (sameAccount) {
|
|
96
120
|
if (permissionBoundaryResult === 'ImplicitlyDenied') {
|
|
97
121
|
/**
|
|
98
122
|
* If the permission boundary is an implicit deny
|
|
@@ -106,80 +130,48 @@ class DefaultServiceAuthorizer {
|
|
|
106
130
|
const principal = request.request.principal.value();
|
|
107
131
|
if ((0, iam_utils_1.isIamRoleArn)(principal) &&
|
|
108
132
|
request.simulationParameters.simulationMode === 'Discovery') {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
...baseResult
|
|
113
|
-
};
|
|
133
|
+
// Principal is a role and may match a session. Check since we are in Discovery mode.
|
|
134
|
+
if (!request.resourceAnalysis.allowStatements.some((statement) => statement.principalMatch === 'Match' && statement.ignoredRoleSessionName)) {
|
|
135
|
+
blockedByLog.add('pb', 'ImplicitlyDenied');
|
|
114
136
|
}
|
|
115
137
|
}
|
|
116
|
-
if ((0, iam_utils_1.isAssumedRoleArn)(principal) ||
|
|
138
|
+
else if ((0, iam_utils_1.isAssumedRoleArn)(principal) ||
|
|
117
139
|
(0, iam_utils_1.isIamUserArn)(principal) ||
|
|
118
140
|
(0, iam_utils_1.isFederatedUserArn)(principal)) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
141
|
+
// If the principal is an assumed role, IAM user, or federated user ARN, check if the resource
|
|
142
|
+
// policy allows the exact ARN.
|
|
143
|
+
if (!request.resourceAnalysis.allowStatements.some((statement) => statement.principalMatch === 'Match')) {
|
|
144
|
+
blockedByLog.add('pb', 'ImplicitlyDenied');
|
|
124
145
|
}
|
|
125
146
|
}
|
|
147
|
+
else {
|
|
148
|
+
// Not in discovery mode or doesn't match a session/user exactly, so the permission boundary implicit deny applies.
|
|
149
|
+
blockedByLog.add('pb', 'ImplicitlyDenied');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Resource policy doesn't allow the principal, so the permission boundary implicit deny applies.
|
|
154
|
+
blockedByLog.add('pb', 'ImplicitlyDenied');
|
|
126
155
|
}
|
|
127
|
-
return {
|
|
128
|
-
result: 'ImplicitlyDenied',
|
|
129
|
-
...baseResult
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
/*
|
|
133
|
-
TODO: Implicit denies in identity policies
|
|
134
|
-
I think if the identity policy has an implicit deny for assumed roles or federated users,
|
|
135
|
-
then the resource policy must have the federated or assumed role ARN exactly.
|
|
136
|
-
|
|
137
|
-
That doesn't seem right though. I know many cases where the resource policy has the role ARN and it works
|
|
138
|
-
|
|
139
|
-
Need to add some tests for this.
|
|
140
|
-
*/
|
|
141
|
-
const trustedAccount = this.serviceTrustsPrincipalAccount(sameAccount, request.resourceAnalysis, request.request.resource);
|
|
142
|
-
if (resourcePolicyResult === 'Allowed' ||
|
|
143
|
-
(trustedAccount && identityStatementResult === 'Allowed')) {
|
|
144
|
-
return {
|
|
145
|
-
result: 'Allowed',
|
|
146
|
-
...baseResult
|
|
147
|
-
};
|
|
148
156
|
}
|
|
149
|
-
return {
|
|
150
|
-
result: 'ImplicitlyDenied',
|
|
151
|
-
...baseResult
|
|
152
|
-
};
|
|
153
157
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
...baseResult
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
if (resourcePolicyResult === 'Allowed' || resourcePolicyResult === 'AllowedForAccount') {
|
|
162
|
-
if (identityStatementResult === 'Allowed') {
|
|
163
|
-
return {
|
|
164
|
-
result: 'Allowed',
|
|
165
|
-
...baseResult
|
|
166
|
-
};
|
|
158
|
+
else {
|
|
159
|
+
//Cross Account
|
|
160
|
+
if (permissionBoundaryResult === 'ImplicitlyDenied') {
|
|
161
|
+
blockedByLog.add('pb', 'ImplicitlyDenied');
|
|
167
162
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
}
|
|
164
|
+
const blockedReasons = blockedByLog.getBlockedBy();
|
|
165
|
+
if (blockedReasons.length !== 0) {
|
|
166
|
+
baseResult.blockedBy = blockedReasons;
|
|
172
167
|
}
|
|
173
168
|
return {
|
|
174
|
-
result:
|
|
169
|
+
result: blockedByLog.getResult(),
|
|
175
170
|
...baseResult
|
|
176
171
|
};
|
|
177
172
|
/**
|
|
178
173
|
* Add checks for:
|
|
179
174
|
* * root user - can override resource policies for most resource types
|
|
180
|
-
* * service linked roles - ignore SCPs and RCPs
|
|
181
|
-
* * session policies
|
|
182
|
-
* * vpc endpoint policies
|
|
183
175
|
* * organization APIs and delegated admin policy
|
|
184
176
|
*/
|
|
185
177
|
}
|
|
@@ -196,6 +188,56 @@ class DefaultServiceAuthorizer {
|
|
|
196
188
|
}
|
|
197
189
|
return resourceAnalysis.allowStatements.some((statement) => statement.principalMatch === 'AccountLevelMatch');
|
|
198
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Evaluations whether the minimum requirements for the request to be allowed are met based on the core policies
|
|
193
|
+
* - Identity
|
|
194
|
+
* - Resource
|
|
195
|
+
* - Session
|
|
196
|
+
*
|
|
197
|
+
* Depending on the service, and whether the principal and resources are in the same account, the requirements may differ.
|
|
198
|
+
* For same account requests, for most services an Allow in the resource policy or the identity policy is sufficient to
|
|
199
|
+
* allow the request, so this function will return 'Allowed'. If there is an explicit deny elsewhere, that is not considered.
|
|
200
|
+
* This function only determines if there are enough core policies to allow the request, and final determination of the
|
|
201
|
+
* request is done elsewhere.
|
|
202
|
+
*
|
|
203
|
+
* @param request the service authorization request containing all analyses
|
|
204
|
+
* @returns 'Allowed' if the core policies allow the request, otherwise may return 'ImplicitlyDenied' or 'ExplicitlyDenied' depending on the analyses
|
|
205
|
+
*/
|
|
206
|
+
initialEvaluationResult(request) {
|
|
207
|
+
const sessionResult = request.sessionAnalysis?.result;
|
|
208
|
+
const identityStatementResult = request.identityAnalysis.result;
|
|
209
|
+
const resourcePolicyResult = request.resourceAnalysis?.result;
|
|
210
|
+
const principalAccount = request.request.principal.accountId();
|
|
211
|
+
const resourceAccount = request.request.resource?.accountId();
|
|
212
|
+
const sameAccount = principalAccount === resourceAccount;
|
|
213
|
+
if (sessionResult && sessionResult !== 'Allowed') {
|
|
214
|
+
return sessionResult;
|
|
215
|
+
}
|
|
216
|
+
// Service Principals
|
|
217
|
+
if ((0, iam_utils_1.isServicePrincipal)(request.request.principal.value())) {
|
|
218
|
+
// Service principals are allowed if the resource policy allows them
|
|
219
|
+
if (resourcePolicyResult === 'Allowed') {
|
|
220
|
+
return 'Allowed';
|
|
221
|
+
}
|
|
222
|
+
return 'ImplicitlyDenied';
|
|
223
|
+
}
|
|
224
|
+
//Same Account
|
|
225
|
+
if (sameAccount) {
|
|
226
|
+
const trustedAccount = this.serviceTrustsPrincipalAccount(sameAccount, request.resourceAnalysis, request.request.resource);
|
|
227
|
+
if (resourcePolicyResult === 'Allowed' ||
|
|
228
|
+
(trustedAccount && identityStatementResult === 'Allowed')) {
|
|
229
|
+
return 'Allowed';
|
|
230
|
+
}
|
|
231
|
+
return 'ImplicitlyDenied';
|
|
232
|
+
}
|
|
233
|
+
//Cross Account
|
|
234
|
+
if (resourcePolicyResult === 'Allowed' || resourcePolicyResult === 'AllowedForAccount') {
|
|
235
|
+
if (identityStatementResult === 'Allowed') {
|
|
236
|
+
return 'Allowed';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return 'ImplicitlyDenied';
|
|
240
|
+
}
|
|
199
241
|
}
|
|
200
242
|
exports.DefaultServiceAuthorizer = DefaultServiceAuthorizer;
|
|
201
243
|
//# sourceMappingURL=DefaultServiceAuthorizer.js.map
|