@forge/csp 2.0.1 → 2.1.0-next.0
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
CHANGED
|
@@ -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,CAmDT;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,10 +30,14 @@ 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(' ');
|
|
@@ -53,31 +57,35 @@ class CSPInjectionService {
|
|
|
53
57
|
];
|
|
54
58
|
};
|
|
55
59
|
}
|
|
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';
|
|
60
|
+
getCSPReportUri(microsEnv) {
|
|
61
|
+
if (microsEnv === 'dev' || microsEnv === 'stg')
|
|
62
|
+
return 'https://web-security-reports.stg.services.atlassian.com/csp-report/forge-cdn';
|
|
63
|
+
return 'https://web-security-reports.services.atlassian.com/csp-report/forge-cdn';
|
|
62
64
|
}
|
|
63
|
-
getForgeGlobalCSP(
|
|
64
|
-
return `https://forge.cdn.${
|
|
65
|
+
getForgeGlobalCSP(microsEnv) {
|
|
66
|
+
return `https://forge.cdn.${microsEnv}.atlassian-dev.net`;
|
|
65
67
|
}
|
|
66
68
|
getExistingCSPDetails(cspType, cspDetails) {
|
|
67
69
|
var _a;
|
|
68
70
|
return (_a = cspDetails[cspType]) !== null && _a !== void 0 ? _a : [];
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
return ['
|
|
73
|
-
return [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
getConnectSrc(isTunnelling) {
|
|
73
|
+
if (isTunnelling)
|
|
74
|
+
return ['ws://localhost:*', 'http://localhost:*'];
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
getFrameAncestors(microsEnv) {
|
|
78
|
+
if (microsEnv === 'dev' || microsEnv === 'stg') {
|
|
79
|
+
return [
|
|
80
|
+
'*.jira-dev.com',
|
|
81
|
+
'http://localhost:*',
|
|
82
|
+
'*.devbucket.org',
|
|
83
|
+
'https://staging.bb-inf.net',
|
|
84
|
+
'https://integration.bb-inf.net',
|
|
85
|
+
'*.atl-paas.net'
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
return ['*.atlassian.net', 'bitbucket.org', '*.jira.com', '*.atlassian.com'];
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
exports.CSPInjectionService = CSPInjectionService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/csp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-next.0",
|
|
4
4
|
"description": "Contains the CSP configuration for Custom UI resources in Forge",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"clean": "rm -rf ./out && rm -f tsconfig.tsbuildinfo"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@forge/cli-shared": "^3.
|
|
15
|
-
"@forge/manifest": "^4.5.
|
|
14
|
+
"@forge/cli-shared": "^3.4.0-next.2",
|
|
15
|
+
"@forge/manifest": "^4.5.2-next.0",
|
|
16
16
|
"@types/jest": "^29.1.2"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|