@forge/csp 0.0.0-experimental-c3d0263 → 0.0.0-experimental-f85f9b1
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/CHANGELOG.md +61 -1
- package/out/csp/csp-injection-service.d.ts +2 -1
- package/out/csp/csp-injection-service.d.ts.map +1 -1
- package/out/csp/csp-injection-service.js +36 -26
- package/out/csp/csp-processing-service.d.ts.map +1 -1
- package/out/csp/csp-processing-service.js +2 -2
- package/out/index.d.ts +0 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +0 -1
- package/package.json +5 -6
- package/out/egress/egress-filtering-service.d.ts +0 -11
- package/out/egress/egress-filtering-service.d.ts.map +0 -1
- package/out/egress/egress-filtering-service.js +0 -46
- package/out/egress/index.d.ts +0 -3
- package/out/egress/index.d.ts.map +0 -1
- package/out/egress/index.js +0 -5
- package/out/egress/utils.d.ts +0 -3
- package/out/egress/utils.d.ts.map +0 -1
- package/out/egress/utils.js +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
# @forge/csp
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 907ce6c: Add navigate-to CSP directive
|
|
8
|
+
|
|
9
|
+
## 2.1.1-next.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 907ce6c: Add navigate-to CSP directive
|
|
14
|
+
|
|
15
|
+
## 2.1.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- eeee3d3: Added ws://localhost to CSP
|
|
20
|
+
|
|
21
|
+
## 2.1.0-next.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- eeee3d3f: Added ws://localhost to CSP
|
|
26
|
+
|
|
27
|
+
## 2.0.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 2a60561: Allow Forge Content Security Policy to load stylesheets from unpkg.com to enable an interim theme mounting solution for Atlassian Design System: Design Tokens
|
|
32
|
+
|
|
33
|
+
## 2.0.1-next.0
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 2a605619: Allow Forge Content Security Policy to load stylesheets from unpkg.com to enable an interim theme mounting solution for Atlassian Design System: Design Tokens
|
|
38
|
+
|
|
39
|
+
## 2.0.0
|
|
40
|
+
|
|
41
|
+
### Major Changes
|
|
42
|
+
|
|
43
|
+
- 3c0ac54: Move egress related services out of @forge/csp into new @forge/egress package
|
|
44
|
+
|
|
45
|
+
## 2.0.0-next.0
|
|
46
|
+
|
|
47
|
+
### Major Changes
|
|
48
|
+
|
|
49
|
+
- 3c0ac54: Move egress related services out of @forge/csp into new @forge/egress package
|
|
50
|
+
|
|
51
|
+
## 1.11.0
|
|
52
|
+
|
|
53
|
+
### Minor Changes
|
|
54
|
+
|
|
55
|
+
- 671a6a63: Skip generating hashes for inline scripts if unsafe-inline is provided
|
|
56
|
+
|
|
57
|
+
## 1.11.0-next.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- 671a6a6: Skip generating hashes for inline scripts if unsafe-inline is provided
|
|
62
|
+
|
|
63
|
+
## 1.10.0
|
|
4
64
|
|
|
5
65
|
### Minor Changes
|
|
6
66
|
|
|
@@ -4,7 +4,8 @@ export declare class CSPInjectionService {
|
|
|
4
4
|
private getCSPReportUri;
|
|
5
5
|
private getForgeGlobalCSP;
|
|
6
6
|
private getExistingCSPDetails;
|
|
7
|
+
private getConnectSrc;
|
|
7
8
|
private getFrameAncestors;
|
|
8
|
-
getInjectableCSP: (existingCSPDetails: CSPDetails,
|
|
9
|
+
getInjectableCSP: (existingCSPDetails: CSPDetails, microsEnv: LambdaEnvironment, tunnelCSPReporterUri?: string) => string[];
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=csp-injection-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-injection-service.d.ts","sourceRoot":"","sources":["../../src/csp/csp-injection-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAmB,MAAM,UAAU,CAAC;AAUvD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"csp-injection-service.d.ts","sourceRoot":"","sources":["../../src/csp/csp-injection-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAmB,MAAM,UAAU,CAAC;AAUvD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,iBAAiB;IAiBlB,gBAAgB,uBACD,UAAU,aACnB,iBAAiB,yBACL,MAAM,KAC5B,MAAM,EAAE,CAqDT;CACH"}
|
|
@@ -10,10 +10,10 @@ const atlassianImageHosts = {
|
|
|
10
10
|
const gravatarUrl = 'https://secure.gravatar.com';
|
|
11
11
|
class CSPInjectionService {
|
|
12
12
|
constructor() {
|
|
13
|
-
this.getInjectableCSP = (existingCSPDetails,
|
|
14
|
-
const reportUri = tunnelCSPReporterUri || this.getCSPReportUri(
|
|
13
|
+
this.getInjectableCSP = (existingCSPDetails, microsEnv, tunnelCSPReporterUri) => {
|
|
14
|
+
const reportUri = tunnelCSPReporterUri || this.getCSPReportUri(microsEnv);
|
|
15
15
|
const defaultSrc = `'self'`;
|
|
16
|
-
const frameAncestors = ["'self'", ...this.getFrameAncestors(
|
|
16
|
+
const frameAncestors = ["'self'", ...this.getFrameAncestors(microsEnv)].join(' ');
|
|
17
17
|
const frameSrc = ["'self'", ...this.getExistingCSPDetails(types_1.ExternalCspType.FRAME_SRC, existingCSPDetails)].join(' ');
|
|
18
18
|
const fontSrc = ["'self'", ...this.getExistingCSPDetails(types_1.ExternalCspType.FONT_SRC, existingCSPDetails)].join(' ');
|
|
19
19
|
const imgSrc = [
|
|
@@ -21,7 +21,7 @@ class CSPInjectionService {
|
|
|
21
21
|
'data:',
|
|
22
22
|
'blob:',
|
|
23
23
|
gravatarUrl,
|
|
24
|
-
...atlassianImageHosts[
|
|
24
|
+
...atlassianImageHosts[microsEnv],
|
|
25
25
|
...this.getExistingCSPDetails(types_1.ExternalCspType.IMG_SRC, existingCSPDetails)
|
|
26
26
|
].join(' ');
|
|
27
27
|
const mediaSrc = [
|
|
@@ -30,13 +30,18 @@ class CSPInjectionService {
|
|
|
30
30
|
'blob:',
|
|
31
31
|
...this.getExistingCSPDetails(types_1.ExternalCspType.MEDIA_SRC, existingCSPDetails)
|
|
32
32
|
].join(' ');
|
|
33
|
-
const connectSrc = [
|
|
33
|
+
const connectSrc = [
|
|
34
|
+
"'self'",
|
|
35
|
+
...this.getConnectSrc(!!tunnelCSPReporterUri),
|
|
36
|
+
...this.getExistingCSPDetails(types_1.ExternalCspType.CONNECT_SRC, existingCSPDetails)
|
|
37
|
+
].join(' ');
|
|
34
38
|
const scriptSrc = [
|
|
35
39
|
"'self'",
|
|
36
|
-
this.getForgeGlobalCSP(
|
|
40
|
+
this.getForgeGlobalCSP(microsEnv),
|
|
37
41
|
...this.getExistingCSPDetails(types_1.ExternalCspType.SCRIPT_SRC, existingCSPDetails)
|
|
38
42
|
].join(' ');
|
|
39
43
|
const styleSrc = ["'self'", ...this.getExistingCSPDetails(types_1.ExternalCspType.STYLE_SRC, existingCSPDetails)].join(' ');
|
|
44
|
+
const navigateTo = ["'self'"];
|
|
40
45
|
return [
|
|
41
46
|
`default-src ${defaultSrc}`,
|
|
42
47
|
`frame-ancestors ${frameAncestors}`,
|
|
@@ -46,38 +51,43 @@ class CSPInjectionService {
|
|
|
46
51
|
`media-src ${mediaSrc}`,
|
|
47
52
|
`connect-src ${connectSrc}`,
|
|
48
53
|
`script-src ${scriptSrc}`,
|
|
49
|
-
`
|
|
54
|
+
`navigate-to ${navigateTo}`,
|
|
55
|
+
`style-src ${styleSrc} https://unpkg.com/@atlaskit/tokens@0.10.30/css/atlassian-light.css https://unpkg.com/@atlaskit/tokens@0.10.30/css/atlassian-dark.css`,
|
|
50
56
|
`form-action 'self'`,
|
|
51
57
|
`sandbox allow-downloads allow-forms allow-modals allow-pointer-lock allow-same-origin allow-scripts`,
|
|
52
58
|
`report-uri ${reportUri}`
|
|
53
59
|
];
|
|
54
60
|
};
|
|
55
61
|
}
|
|
56
|
-
getCSPReportUri(
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
return 'https://web-security-reports.services.atlassian.com/csp-report/forge-cdn';
|
|
61
|
-
return 'https://web-security-reports.stg.services.atlassian.com/csp-report/forge-cdn';
|
|
62
|
+
getCSPReportUri(microsEnv) {
|
|
63
|
+
if (microsEnv === 'dev' || microsEnv === 'stg')
|
|
64
|
+
return 'https://web-security-reports.stg.services.atlassian.com/csp-report/forge-cdn';
|
|
65
|
+
return 'https://web-security-reports.services.atlassian.com/csp-report/forge-cdn';
|
|
62
66
|
}
|
|
63
|
-
getForgeGlobalCSP(
|
|
64
|
-
return `https://forge.cdn.${
|
|
67
|
+
getForgeGlobalCSP(microsEnv) {
|
|
68
|
+
return `https://forge.cdn.${microsEnv}.atlassian-dev.net`;
|
|
65
69
|
}
|
|
66
70
|
getExistingCSPDetails(cspType, cspDetails) {
|
|
67
71
|
var _a;
|
|
68
72
|
return (_a = cspDetails[cspType]) !== null && _a !== void 0 ? _a : [];
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
return ['
|
|
73
|
-
return [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
getConnectSrc(isTunnelling) {
|
|
75
|
+
if (isTunnelling)
|
|
76
|
+
return ['ws://localhost:*', 'http://localhost:*'];
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
getFrameAncestors(microsEnv) {
|
|
80
|
+
if (microsEnv === 'dev' || microsEnv === 'stg') {
|
|
81
|
+
return [
|
|
82
|
+
'*.jira-dev.com',
|
|
83
|
+
'http://localhost:*',
|
|
84
|
+
'*.devbucket.org',
|
|
85
|
+
'https://staging.bb-inf.net',
|
|
86
|
+
'https://integration.bb-inf.net',
|
|
87
|
+
'*.atl-paas.net'
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
return ['*.atlassian.net', 'bitbucket.org', '*.jira.com', '*.atlassian.com'];
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
exports.CSPInjectionService = CSPInjectionService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-processing-service.d.ts","sourceRoot":"","sources":["../../src/csp/csp-processing-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,iBAAiB,CAAC;AAK1D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,YAAY,EAAuB,MAAM,UAAU,CAAC;AAE7F,qBAAa,iBAAkB,SAAQ,KAAK;;CAI3C;AAMD,qBAAa,oBAAoB;IAanB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAXnC,OAAO,CAAC,mBAAmB,CAAuB;IAElD,OAAO,CAAC,2BAA2B,CAAqD;IACxF,OAAO,CAAC,6BAA6B,CAAa;IAClD,OAAO,CAAC,oBAAoB,CAAgF;IAE5G,OAAO,CAAC,qBAAqB,CAI3B;gBAC2B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAElD,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,GAAG,UAAU;IAkBvE,wBAAwB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,MAAM,EAAE;IASjF,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,2BAA2B;IAgBnC,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"csp-processing-service.d.ts","sourceRoot":"","sources":["../../src/csp/csp-processing-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,iBAAiB,CAAC;AAK1D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,YAAY,EAAuB,MAAM,UAAU,CAAC;AAE7F,qBAAa,iBAAkB,SAAQ,KAAK;;CAI3C;AAMD,qBAAa,oBAAoB;IAanB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAXnC,OAAO,CAAC,mBAAmB,CAAuB;IAElD,OAAO,CAAC,2BAA2B,CAAqD;IACxF,OAAO,CAAC,6BAA6B,CAAa;IAClD,OAAO,CAAC,oBAAoB,CAAgF;IAE5G,OAAO,CAAC,qBAAqB,CAI3B;gBAC2B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAElD,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,GAAG,UAAU;IAkBvE,wBAAwB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,MAAM,EAAE;IASjF,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,2BAA2B;IAgBnC,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,oBAAoB;CAa7B"}
|
|
@@ -71,8 +71,8 @@ class CSPProcessingService {
|
|
|
71
71
|
}
|
|
72
72
|
getScriptSrc($, userScriptSrc) {
|
|
73
73
|
var _a;
|
|
74
|
-
const generatedScriptHashes = this.getInlineScriptHashes($);
|
|
75
74
|
const validUserScriptSrc = (_a = userScriptSrc === null || userScriptSrc === void 0 ? void 0 : userScriptSrc.filter((x) => this.isValidUserScriptSrc(x))) !== null && _a !== void 0 ? _a : [];
|
|
75
|
+
const generatedScriptHashes = validUserScriptSrc.includes('unsafe-inline') ? [] : this.getInlineScriptHashes($);
|
|
76
76
|
const { scriptSrc, userScriptHashes } = this.extractUniqueHashes(validUserScriptSrc, generatedScriptHashes);
|
|
77
77
|
return [...scriptSrc, ...generatedScriptHashes, ...userScriptHashes].map((x) => this.formatScriptSrc(x));
|
|
78
78
|
}
|
|
@@ -133,7 +133,7 @@ class CSPProcessingService {
|
|
|
133
133
|
this.logger.info('discarding potentially-malicious CSP');
|
|
134
134
|
return {};
|
|
135
135
|
}
|
|
136
|
-
return content_security_policy_parser_1.default(cspContent);
|
|
136
|
+
return (0, content_security_policy_parser_1.default)(cspContent);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
exports.CSPProcessingService = CSPProcessingService;
|
package/out/index.d.ts
CHANGED
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,OAAO,CAAC;AACtB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
package/out/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/csp",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-f85f9b1",
|
|
4
4
|
"description": "Contains the CSP configuration for Custom UI resources in Forge",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -11,13 +11,12 @@
|
|
|
11
11
|
"clean": "rm -rf ./out && rm -f tsconfig.tsbuildinfo"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@forge/cli-shared": "
|
|
15
|
-
"@forge/manifest": "
|
|
16
|
-
"@types/jest": "^
|
|
14
|
+
"@forge/cli-shared": "0.0.0-experimental-f85f9b1",
|
|
15
|
+
"@forge/manifest": "0.0.0-experimental-f85f9b1",
|
|
16
|
+
"@types/jest": "^29.1.2"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"cheerio": "^0.22.0",
|
|
20
|
-
"content-security-policy-parser": "^0.3.0"
|
|
21
|
-
"micromatch": "^4.0.2"
|
|
20
|
+
"content-security-policy-parser": "^0.3.0"
|
|
22
21
|
}
|
|
23
22
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class EgressFilteringService {
|
|
2
|
-
private readonly URLs;
|
|
3
|
-
private readonly wildcardDomains;
|
|
4
|
-
private readonly allowsEverything;
|
|
5
|
-
constructor(allowList: string[]);
|
|
6
|
-
private safeURL;
|
|
7
|
-
isValidUrl(url: string): boolean;
|
|
8
|
-
private domainCheck;
|
|
9
|
-
private domainIsAllowed;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=egress-filtering-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"egress-filtering-service.d.ts","sourceRoot":"","sources":["../../src/egress/egress-filtering-service.ts"],"names":[],"mappings":"AAGA,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;gBAE/B,SAAS,EAAE,MAAM,EAAE;IAY/B,OAAO,CAAC,OAAO;IAOR,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQvC,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,eAAe;CAWxB"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EgressFilteringService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
|
|
6
|
-
const url_1 = require("url");
|
|
7
|
-
class EgressFilteringService {
|
|
8
|
-
constructor(allowList) {
|
|
9
|
-
this.URLs = allowList
|
|
10
|
-
.filter((domainOrURL) => !domainOrURL.startsWith('*'))
|
|
11
|
-
.map((url) => this.safeURL(url));
|
|
12
|
-
this.wildcardDomains = allowList
|
|
13
|
-
.filter((domainOrURL) => domainOrURL !== '*')
|
|
14
|
-
.map((url) => this.safeURL(url))
|
|
15
|
-
.filter((url) => url.hostname.startsWith('*'));
|
|
16
|
-
this.allowsEverything = allowList.includes('*');
|
|
17
|
-
}
|
|
18
|
-
safeURL(url, defaultProtocol = 'https://') {
|
|
19
|
-
const protocolRegex = /^(.*:\/\/)/;
|
|
20
|
-
return new url_1.URL(protocolRegex.test(url) ? url : `${defaultProtocol}${url}`);
|
|
21
|
-
}
|
|
22
|
-
isValidUrl(url) {
|
|
23
|
-
if (this.allowsEverything) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return this.domainIsAllowed(this.safeURL(url));
|
|
27
|
-
}
|
|
28
|
-
domainCheck(domain, allowList) {
|
|
29
|
-
const hostnameMatchedProtocol = allowList
|
|
30
|
-
.filter((allowed) => allowed.protocol === domain.protocol)
|
|
31
|
-
.map((url) => url.hostname);
|
|
32
|
-
return (micromatch_1.default([domain.hostname], hostnameMatchedProtocol, {
|
|
33
|
-
dot: true
|
|
34
|
-
}).length > 0);
|
|
35
|
-
}
|
|
36
|
-
domainIsAllowed(domain) {
|
|
37
|
-
if (this.domainCheck(domain, this.URLs)) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
if (this.domainCheck(domain, this.wildcardDomains)) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.EgressFilteringService = EgressFilteringService;
|
package/out/egress/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/egress/index.ts"],"names":[],"mappings":"AAEA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC"}
|
package/out/egress/index.js
DELETED
package/out/egress/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/egress/utils.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,qCAAqC,oBAAqB,MAAM,EAAE,KAAG,KAAK,CAAC,MAAM,CA2BtF,CAAC;AAEF,OAAO,EAAE,qCAAqC,EAAE,CAAC"}
|
package/out/egress/utils.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortAndGroupEgressPermissionsByDomain = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
|
|
6
|
-
const url_1 = require("url");
|
|
7
|
-
const sortAndGroupEgressPermissionsByDomain = (egressAddresses) => {
|
|
8
|
-
const protocolRegex = /^(.*?:\/\/)/;
|
|
9
|
-
const domainSet = new Set();
|
|
10
|
-
const groupSet = new Set();
|
|
11
|
-
const removeSet = new Set();
|
|
12
|
-
if ((egressAddresses === null || egressAddresses === void 0 ? void 0 : egressAddresses.length) === 0) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
egressAddresses.forEach((item) => {
|
|
16
|
-
const itemWithProtocol = protocolRegex.test(item) ? item : `https://${item}`;
|
|
17
|
-
const url = new url_1.URL(itemWithProtocol);
|
|
18
|
-
if (url.hostname.startsWith('*')) {
|
|
19
|
-
groupSet.add(url.hostname.substring(2));
|
|
20
|
-
removeSet.add('!' + url.hostname);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
domainSet.add(url.hostname);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
if (removeSet.size === 0) {
|
|
27
|
-
return [...domainSet];
|
|
28
|
-
}
|
|
29
|
-
return [...new Set(micromatch_1.default([...domainSet], [...removeSet]).concat([...groupSet]))].sort();
|
|
30
|
-
};
|
|
31
|
-
exports.sortAndGroupEgressPermissionsByDomain = sortAndGroupEgressPermissionsByDomain;
|