@forge/csp 0.0.0-experimental-32f9210 → 0.0.0-experimental-7c72fec

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,6 +1,178 @@
1
1
  # @forge/csp
2
2
 
3
- ## 0.0.0-experimental-32f9210
3
+ ## 1.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1c196ff: Add support for external fetch client to reference remote
8
+
9
+ ### Patch Changes
10
+
11
+ - 1dba082: Enabling new frame ancestors '_.atl-paas.net' and '_.atlassian.com'
12
+
13
+ ## 1.9.0-next.1
14
+
15
+ ### Minor Changes
16
+
17
+ - 1c196ff: Add support for external fetch client to reference remote
18
+
19
+ ## 1.8.1-next.0
20
+
21
+ ### Patch Changes
22
+
23
+ - 04e4152: Enabling new frame ancestors '_.atl-paas.net' and '_.atlassian.com'
24
+
25
+ ## 1.8.0
26
+
27
+ ### Minor Changes
28
+
29
+ - d5f3fac: Remove deprecated method for handling CSP user config
30
+ - f002362: Revert change for deprecated CSP
31
+
32
+ ## 1.8.0-next.1
33
+
34
+ ### Minor Changes
35
+
36
+ - f002362: Revert change for deprecated CSP
37
+
38
+ ## 1.8.0-next.0
39
+
40
+ ### Minor Changes
41
+
42
+ - d5f3fac: Remove deprecated method for handling CSP user config
43
+
44
+ ## 1.7.1
45
+
46
+ ### Patch Changes
47
+
48
+ - 4b41a80: Added egress messaging to install prompts
49
+
50
+ ## 1.7.1-next.0
51
+
52
+ ### Patch Changes
53
+
54
+ - 4b41a80: Added egress messaging to install prompts
55
+
56
+ ## 1.7.0
57
+
58
+ ### Minor Changes
59
+
60
+ - ef00257: Add \*.jira.com to allowed host site list
61
+
62
+ ### Patch Changes
63
+
64
+ - d7a1fe3: Update dependencies to remove any transitive dependencies on request
65
+
66
+ ## 1.7.0-next.1
67
+
68
+ ### Patch Changes
69
+
70
+ - d7a1fe3: Update dependencies to remove any transitive dependencies on request
71
+
72
+ ## 1.7.0-next.0
73
+
74
+ ### Minor Changes
75
+
76
+ - ef00257: Add \*.jira.com to allowed host site list
77
+
78
+ ## 1.6.0
79
+
80
+ ### Minor Changes
81
+
82
+ - 8714f5a: Add support for fonts and frames as part of Egress Permissions for Custom UI apps
83
+
84
+ ### Patch Changes
85
+
86
+ - f8ae8a2: Add support for Bitbucket origin in Custom UI
87
+
88
+ ## 1.6.0-next.1
89
+
90
+ ### Patch Changes
91
+
92
+ - f8ae8a2: Add support for Bitbucket origin in Custom UI
93
+
94
+ ## 1.6.0-next.0
95
+
96
+ ### Minor Changes
97
+
98
+ - 8714f5a: Add support for fonts and frames as part of Egress Permissions for Custom UI apps
99
+
100
+ ## 1.5.0
101
+
102
+ ### Minor Changes
103
+
104
+ - 638194f: Fix logic to detect missing fetch egress permission
105
+
106
+ ## 1.5.0-next.0
107
+
108
+ ### Minor Changes
109
+
110
+ - 638194f: Fix logic to detect missing fetch egress permission
111
+
112
+ ## 1.4.0
113
+
114
+ ### Minor Changes
115
+
116
+ - 05f608f: Added external fetch linting
117
+
118
+ ### Patch Changes
119
+
120
+ - bd9194a: Added error protection to egress filtering for URLs with no protocol
121
+
122
+ ## 1.4.0-next.1
123
+
124
+ ### Patch Changes
125
+
126
+ - bd9194a: Added error protection to egress filtering for URLs with no protocol
127
+
128
+ ## 1.4.0-next.0
129
+
130
+ ### Minor Changes
131
+
132
+ - 05f608f: Added external fetch linting
133
+
134
+ ## 1.3.0
135
+
136
+ ### Minor Changes
137
+
138
+ - 9ec2911: Allow style-src as part of Egress Permissions for Custom UI apps
139
+
140
+ ### Patch Changes
141
+
142
+ - 2ddcdb2: Update frame-ancestors for dev
143
+ - 2b3c55d: Fix to restrict frame ancestors of Custom UI apps
144
+
145
+ ## 1.3.0-next.2
146
+
147
+ ### Patch Changes
148
+
149
+ - 2ddcdb2: Update frame-ancestors for dev
150
+
151
+ ## 1.3.0-next.1
152
+
153
+ ### Minor Changes
154
+
155
+ - 9ec2911: Allow style-src as part of Egress Permissions for Custom UI apps
156
+
157
+ ## 1.2.1-next.0
158
+
159
+ ### Patch Changes
160
+
161
+ - 2b3c55d: Fix to restrict frame ancestors of Custom UI apps
162
+
163
+ ## 1.2.0
164
+
165
+ ### Minor Changes
166
+
167
+ - 6c482ef: Add `allow-downloads allow-modals` to sandbox
168
+
169
+ ## 1.2.0-next.0
170
+
171
+ ### Minor Changes
172
+
173
+ - 6c482ef: Add `allow-downloads allow-modals` to sandbox
174
+
175
+ ## 1.1.0
4
176
 
5
177
  ### Minor Changes
6
178
 
@@ -1,9 +1,10 @@
1
1
  import type { LambdaEnvironment } from '@forge/cli-shared';
2
- import { CSPDetails } from './types';
2
+ import { CSPDetails } from '../types';
3
3
  export declare class CSPInjectionService {
4
4
  private getCSPReportUri;
5
5
  private getForgeGlobalCSP;
6
6
  private getExistingCSPDetails;
7
+ private getFrameAncestors;
7
8
  getInjectableCSP: (existingCSPDetails: CSPDetails, env: LambdaEnvironment, tunnelCSPReporterUri?: string | undefined) => string[];
8
9
  }
9
10
  //# sourceMappingURL=csp-injection-service.d.ts.map
@@ -0,0 +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,gDAErB,MAAM,EAAE,CA4CT;CACH"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CSPInjectionService = void 0;
4
- const types_1 = require("./types");
4
+ const types_1 = require("../types");
5
5
  const atlassianImageHosts = {
6
6
  dev: ['https://avatar-management--avatars.us-west-2.staging.public.atl-paas.net', 'https://api.dev.atlassian.com'],
7
7
  stg: ['https://avatar-management--avatars.us-west-2.staging.public.atl-paas.net', 'https://api.stg.atlassian.com'],
@@ -13,6 +13,9 @@ class CSPInjectionService {
13
13
  this.getInjectableCSP = (existingCSPDetails, env, tunnelCSPReporterUri) => {
14
14
  const reportUri = tunnelCSPReporterUri || this.getCSPReportUri(env);
15
15
  const defaultSrc = `'self'`;
16
+ const frameAncestors = ["'self'", ...this.getFrameAncestors(env)].join(' ');
17
+ const frameSrc = ["'self'", ...this.getExistingCSPDetails(types_1.ExternalCspType.FRAME_SRC, existingCSPDetails)].join(' ');
18
+ const fontSrc = ["'self'", ...this.getExistingCSPDetails(types_1.ExternalCspType.FONT_SRC, existingCSPDetails)].join(' ');
16
19
  const imgSrc = [
17
20
  "'self'",
18
21
  'data:',
@@ -33,16 +36,19 @@ class CSPInjectionService {
33
36
  this.getForgeGlobalCSP(env),
34
37
  ...this.getExistingCSPDetails(types_1.ExternalCspType.SCRIPT_SRC, existingCSPDetails)
35
38
  ].join(' ');
36
- const styleSrc = ["'self'", ...this.getExistingCSPDetails('style-src', existingCSPDetails)].join(' ');
39
+ const styleSrc = ["'self'", ...this.getExistingCSPDetails(types_1.ExternalCspType.STYLE_SRC, existingCSPDetails)].join(' ');
37
40
  return [
38
41
  `default-src ${defaultSrc}`,
42
+ `frame-ancestors ${frameAncestors}`,
43
+ `frame-src ${frameSrc}`,
44
+ `font-src ${fontSrc}`,
39
45
  `img-src ${imgSrc}`,
40
46
  `media-src ${mediaSrc}`,
41
47
  `connect-src ${connectSrc}`,
42
48
  `script-src ${scriptSrc}`,
43
49
  `style-src ${styleSrc}`,
44
50
  `form-action 'self'`,
45
- `sandbox allow-forms allow-scripts allow-same-origin`,
51
+ `sandbox allow-downloads allow-forms allow-modals allow-same-origin allow-scripts`,
46
52
  `report-uri ${reportUri}`
47
53
  ];
48
54
  };
@@ -61,5 +67,17 @@ class CSPInjectionService {
61
67
  var _a;
62
68
  return (_a = cspDetails[cspType]) !== null && _a !== void 0 ? _a : [];
63
69
  }
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
+ ];
81
+ }
64
82
  }
65
83
  exports.CSPInjectionService = CSPInjectionService;
@@ -1,11 +1,15 @@
1
1
  import type { Logger } from '@forge/cli-shared';
2
2
  import type { Permissions } from '@forge/manifest';
3
- import { ContentPermissions, CSPDetails, DocumentBody } from './types';
3
+ import { ContentPermissions, CSPDetails, DocumentBody } from '../types';
4
+ export declare class InvalidConnectSrc extends Error {
5
+ constructor();
6
+ }
4
7
  export declare class CSPProcessingService {
5
8
  private readonly logger;
6
9
  constructor(logger: Pick<Logger, 'info'>);
7
10
  getCspDetails(body: DocumentBody, permissions: Permissions): CSPDetails;
8
11
  getInvalidCspPermissions(contentPermissions: ContentPermissions): string[];
12
+ private assertValidFetchClient;
9
13
  private mapExternalPermissionsToCsp;
10
14
  private getStyleSrc;
11
15
  private getScriptSrc;
@@ -0,0 +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;AAa7F,qBAAa,iBAAkB,SAAQ,KAAK;;CAI3C;AAMD,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,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;IAWpB,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,oBAAoB;CAa7B"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CSPProcessingService = void 0;
3
+ exports.CSPProcessingService = exports.InvalidConnectSrc = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const cheerio_1 = tslib_1.__importDefault(require("cheerio"));
6
6
  const content_security_policy_parser_1 = tslib_1.__importDefault(require("content-security-policy-parser"));
@@ -12,6 +12,12 @@ const BASE_64_HASH_PATTERNS = [
12
12
  /^'sha384-[a-zA-Z0-9=+/]{64}'$/,
13
13
  /^'sha512-[a-zA-Z0-9=+/]{88}'$/
14
14
  ];
15
+ class InvalidConnectSrc extends Error {
16
+ constructor() {
17
+ super('fetch.client should be an array of strings');
18
+ }
19
+ }
20
+ exports.InvalidConnectSrc = InvalidConnectSrc;
15
21
  class CSPProcessingService {
16
22
  constructor(logger) {
17
23
  this.logger = logger;
@@ -21,8 +27,8 @@ class CSPProcessingService {
21
27
  const { scripts, styles } = (_a = permissions === null || permissions === void 0 ? void 0 : permissions.content) !== null && _a !== void 0 ? _a : { scripts: [], styles: [] };
22
28
  const external = (_b = permissions === null || permissions === void 0 ? void 0 : permissions.external) !== null && _b !== void 0 ? _b : {};
23
29
  const $ = cheerio_1.default.load(body);
24
- const _c = this.mapExternalPermissionsToCsp(external), { 'script-src': scriptSrc } = _c, mappedExternalCsp = tslib_1.__rest(_c, ['script-src']);
25
- return Object.assign({ 'style-src': this.getStyleSrc($, styles), 'script-src': [...this.getScriptSrc($, scripts), ...scriptSrc] }, mappedExternalCsp);
30
+ const _c = this.mapExternalPermissionsToCsp(external), { 'script-src': scriptSrc, 'style-src': styleSrc } = _c, mappedExternalCsp = tslib_1.__rest(_c, ['script-src', 'style-src']);
31
+ return Object.assign({ 'style-src': [...this.getStyleSrc($, styles), ...styleSrc], 'script-src': [...this.getScriptSrc($, scripts), ...scriptSrc] }, mappedExternalCsp);
26
32
  }
27
33
  getInvalidCspPermissions(contentPermissions) {
28
34
  var _a, _b;
@@ -31,14 +37,27 @@ class CSPProcessingService {
31
37
  const invalidScripts = (_b = scripts === null || scripts === void 0 ? void 0 : scripts.filter((scriptSrc) => !this.isValidUserScriptSrc(`'${scriptSrc}'`))) !== null && _b !== void 0 ? _b : [];
32
38
  return [...invalidStyles, ...invalidScripts];
33
39
  }
40
+ assertValidFetchClient(fetch) {
41
+ if (fetch === null || fetch === void 0 ? void 0 : fetch.client) {
42
+ for (const client of fetch === null || fetch === void 0 ? void 0 : fetch.client) {
43
+ if (typeof client !== 'string') {
44
+ throw new InvalidConnectSrc();
45
+ }
46
+ }
47
+ }
48
+ }
34
49
  mapExternalPermissionsToCsp(externalPermissions) {
35
50
  var _a;
36
- const { images, media, scripts, fetch } = externalPermissions;
51
+ const { images, media, scripts, fetch, styles, fonts, frames } = externalPermissions;
52
+ this.assertValidFetchClient(fetch);
37
53
  return {
38
54
  'img-src': images !== null && images !== void 0 ? images : [],
39
55
  'media-src': media !== null && media !== void 0 ? media : [],
40
56
  'script-src': scripts !== null && scripts !== void 0 ? scripts : [],
41
- 'connect-src': (_a = fetch === null || fetch === void 0 ? void 0 : fetch.client) !== null && _a !== void 0 ? _a : []
57
+ 'style-src': styles !== null && styles !== void 0 ? styles : [],
58
+ 'connect-src': (_a = fetch === null || fetch === void 0 ? void 0 : fetch.client) !== null && _a !== void 0 ? _a : [],
59
+ 'font-src': fonts !== null && fonts !== void 0 ? fonts : [],
60
+ 'frame-src': frames !== null && frames !== void 0 ? frames : []
42
61
  };
43
62
  }
44
63
  getStyleSrc($, userStyleSrc) {
@@ -0,0 +1,3 @@
1
+ export * from './csp-injection-service';
2
+ export * from './csp-processing-service';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/csp/index.ts"],"names":[],"mappings":"AAEA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./csp-injection-service"), exports);
5
+ tslib_1.__exportStar(require("./csp-processing-service"), exports);
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,46 @@
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;
@@ -0,0 +1,3 @@
1
+ export * from './egress-filtering-service';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/egress/index.ts"],"names":[],"mappings":"AAEA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./egress-filtering-service"), exports);
5
+ tslib_1.__exportStar(require("./utils"), exports);
@@ -0,0 +1,3 @@
1
+ declare const sortAndGroupEgressPermissionsByDomain: (egressAddresses: string[]) => Array<string>;
2
+ export { sortAndGroupEgressPermissionsByDomain };
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,31 @@
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;
package/out/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './csp-injection-service';
2
- export * from './csp-processing-service';
1
+ export * from './csp';
2
+ export * from './egress';
3
3
  export * from './types';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/out/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./csp-injection-service"), exports);
5
- tslib_1.__exportStar(require("./csp-processing-service"), exports);
4
+ tslib_1.__exportStar(require("./csp"), exports);
5
+ tslib_1.__exportStar(require("./egress"), exports);
6
6
  tslib_1.__exportStar(require("./types"), exports);
package/out/types.d.ts CHANGED
@@ -7,10 +7,10 @@ export declare enum ExternalCspType {
7
7
  IMG_SRC = "img-src",
8
8
  MEDIA_SRC = "media-src",
9
9
  SCRIPT_SRC = "script-src",
10
- CONNECT_SRC = "connect-src"
11
- }
12
- export declare type MappedExternalCsp = Record<ExternalCspType, string[]>;
13
- export interface CSPDetails extends MappedExternalCsp {
14
- 'style-src': string[];
10
+ STYLE_SRC = "style-src",
11
+ CONNECT_SRC = "connect-src",
12
+ FONT_SRC = "font-src",
13
+ FRAME_SRC = "frame-src"
15
14
  }
15
+ export declare type CSPDetails = Record<ExternalCspType, string[]>;
16
16
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,oBAAY,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3C,oBAAY,kBAAkB,GAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACrE,oBAAY,mBAAmB,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;AACvE,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B;AACD,oBAAY,iBAAiB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC;AAElE,MAAM,WAAW,UAAW,SAAQ,iBAAiB;IACnD,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,oBAAY,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3C,oBAAY,kBAAkB,GAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACrE,oBAAY,mBAAmB,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;AACvE,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AACD,oBAAY,UAAU,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC"}
package/out/types.js CHANGED
@@ -6,5 +6,8 @@ var ExternalCspType;
6
6
  ExternalCspType["IMG_SRC"] = "img-src";
7
7
  ExternalCspType["MEDIA_SRC"] = "media-src";
8
8
  ExternalCspType["SCRIPT_SRC"] = "script-src";
9
+ ExternalCspType["STYLE_SRC"] = "style-src";
9
10
  ExternalCspType["CONNECT_SRC"] = "connect-src";
11
+ ExternalCspType["FONT_SRC"] = "font-src";
12
+ ExternalCspType["FRAME_SRC"] = "frame-src";
10
13
  })(ExternalCspType = exports.ExternalCspType || (exports.ExternalCspType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/csp",
3
- "version": "0.0.0-experimental-32f9210",
3
+ "version": "0.0.0-experimental-7c72fec",
4
4
  "description": "Contains the CSP configuration for Custom UI resources in Forge",
5
5
  "main": "out/index.js",
6
6
  "author": "Atlassian",
@@ -11,12 +11,13 @@
11
11
  "clean": "rm -rf ./out && rm -f tsconfig.tsbuildinfo"
12
12
  },
13
13
  "devDependencies": {
14
- "@forge/cli-shared": "^0.0.0-experimental-32f9210",
15
- "@forge/manifest": "^0.0.0-experimental-32f9210",
14
+ "@forge/cli-shared": "^0.0.0-experimental-7c72fec",
15
+ "@forge/manifest": "^0.0.0-experimental-7c72fec",
16
16
  "@types/jest": "^26.0.0"
17
17
  },
18
18
  "dependencies": {
19
- "cheerio": "^0.20.0",
20
- "content-security-policy-parser": "^0.3.0"
19
+ "cheerio": "^0.22.0",
20
+ "content-security-policy-parser": "^0.3.0",
21
+ "micromatch": "^4.0.2"
21
22
  }
22
23
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"csp-injection-service.d.ts","sourceRoot":"","sources":["../src/csp-injection-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAmB,MAAM,SAAS,CAAC;AAUtD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,qBAAqB;IAKtB,gBAAgB,uBACD,UAAU,OACzB,iBAAiB,gDAErB,MAAM,EAAE,CAsCT;CACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"csp-processing-service.d.ts","sourceRoot":"","sources":["../src/csp-processing-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,YAAY,EAA0C,MAAM,SAAS,CAAC;AAiB/G,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAElD,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,GAAG,UAAU;IAgBvE,wBAAwB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,MAAM,EAAE;IASjF,OAAO,CAAC,2BAA2B;IAWnC,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,oBAAoB;CAa7B"}