@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
@@ -1,5 +1,11 @@
1
1
  # @forge/csp
2
2
 
3
+ ## 2.1.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - eeee3d3f: Added ws://localhost to CSP
8
+
3
9
  ## 2.0.1
4
10
 
5
11
  ### Patch Changes
@@ -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, env: LambdaEnvironment, tunnelCSPReporterUri?: string) => string[];
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;IAQvB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,iBAAiB;IAalB,gBAAgB,uBACD,UAAU,OACzB,iBAAiB,yBACC,MAAM,KAC5B,MAAM,EAAE,CAiDT;CACH"}
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, env, tunnelCSPReporterUri) => {
14
- const reportUri = tunnelCSPReporterUri || this.getCSPReportUri(env);
13
+ this.getInjectableCSP = (existingCSPDetails, microsEnv, tunnelCSPReporterUri) => {
14
+ const reportUri = tunnelCSPReporterUri || this.getCSPReportUri(microsEnv);
15
15
  const defaultSrc = `'self'`;
16
- const frameAncestors = ["'self'", ...this.getFrameAncestors(env)].join(' ');
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[env],
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 = ["'self'", ...this.getExistingCSPDetails(types_1.ExternalCspType.CONNECT_SRC, existingCSPDetails)].join(' ');
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(env),
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(env, tunnelCSPReporterUri) {
57
- if (tunnelCSPReporterUri)
58
- return tunnelCSPReporterUri;
59
- if (env === 'prod')
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(env) {
64
- return `https://forge.cdn.${env}.atlassian-dev.net`;
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
- getFrameAncestors(env) {
71
- if (env === 'prod')
72
- return ['*.atlassian.net', 'bitbucket.org', '*.jira.com', '*.atlassian.com'];
73
- return [
74
- '*.jira-dev.com',
75
- 'http://localhost:*',
76
- '*.devbucket.org',
77
- 'https://staging.bb-inf.net',
78
- 'https://integration.bb-inf.net',
79
- '*.atl-paas.net'
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.1",
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.3.0",
15
- "@forge/manifest": "^4.5.1",
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": {