@forge/lint 2.0.0 → 2.0.1-next.3
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 +32 -0
- package/out/lint/linters/permission-linter/verifiers/product-verifier.d.ts +1 -0
- package/out/lint/linters/permission-linter/verifiers/product-verifier.d.ts.map +1 -1
- package/out/lint/linters/permission-linter/verifiers/product-verifier.js +25 -3
- package/out/lint/linters/permission-linter/verifiers/ui-hook-verifier.d.ts.map +1 -1
- package/out/lint/linters/permission-linter/verifiers/ui-hook-verifier.js +37 -19
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @forge/lint
|
|
2
2
|
|
|
3
|
+
## 2.0.1-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1f7c428: Accept both deprecated scopes and granular scopes when verifying scopes required for REST product endpoints.
|
|
8
|
+
|
|
9
|
+
## 2.0.1-next.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ffa0050: Accept both deprecated scopes and granular scopes when verifying scopes required for Forge UI hooks.
|
|
14
|
+
- Updated dependencies [14102be]
|
|
15
|
+
- @forge/manifest@3.1.0-next.2
|
|
16
|
+
- @forge/cli-shared@2.2.1-next.2
|
|
17
|
+
|
|
18
|
+
## 2.0.1-next.1
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [8ee1c58]
|
|
23
|
+
- @forge/manifest@3.1.0-next.1
|
|
24
|
+
- @forge/cli-shared@2.2.1-next.1
|
|
25
|
+
|
|
26
|
+
## 2.0.1-next.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [813f8f3]
|
|
31
|
+
- Updated dependencies [5152239]
|
|
32
|
+
- @forge/manifest@3.1.0-next.0
|
|
33
|
+
- @forge/cli-shared@2.2.1-next.0
|
|
34
|
+
|
|
3
35
|
## 2.0.0
|
|
4
36
|
|
|
5
37
|
### Major Changes
|
|
@@ -27,6 +27,7 @@ export declare class ProductVerifier extends BaseLintIssueVerifier implements Li
|
|
|
27
27
|
private lookupApiCall;
|
|
28
28
|
private getMissingPermissionScopes;
|
|
29
29
|
private getRequiredScopes;
|
|
30
|
+
private getRequiredDeprecatedScopes;
|
|
30
31
|
}
|
|
31
32
|
export {};
|
|
32
33
|
//# sourceMappingURL=product-verifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/verifiers/product-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,QAAQ,EAAE,aAAa,EAAE,CAAC;QAC1B,2BAA2B,CAAC,EAAE,qBAAqB,EAAE,CAAC;KACvD,CAAC;CACH;AAED,UAAU,aAAa;IACrB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC9B;AAED,oBAAY,uBAAuB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEjE,qBAAa,eAAgB,SAAQ,qBAAsB,YAAW,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAI9F,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,EACD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,MAAM;IAKlC,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAoC3E,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,0BAA0B;
|
|
1
|
+
{"version":3,"file":"product-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/verifiers/product-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,QAAQ,EAAE,aAAa,EAAE,CAAC;QAC1B,2BAA2B,CAAC,EAAE,qBAAqB,EAAE,CAAC;KACvD,CAAC;CACH;AAED,UAAU,aAAa;IACrB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC9B;AAED,oBAAY,uBAAuB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEjE,qBAAa,eAAgB,SAAQ,qBAAsB,YAAW,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAI9F,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,EACD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,MAAM;IAKlC,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAoC3E,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,0BAA0B;IA8BlC,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,2BAA2B;CAWpC"}
|
|
@@ -53,11 +53,24 @@ class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
|
|
|
53
53
|
}
|
|
54
54
|
getMissingPermissionScopes(apiCall) {
|
|
55
55
|
var _a, _b, _c;
|
|
56
|
-
const
|
|
56
|
+
const currentScopes = this.getRequiredScopes(apiCall);
|
|
57
|
+
const deprecatedScopes = this.getRequiredDeprecatedScopes(apiCall);
|
|
57
58
|
if (!((_c = (_b = (_a = this.manifest) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.scopes) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
58
|
-
return
|
|
59
|
+
return currentScopes;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
const missingCurrentScopes = currentScopes.filter((scope) => { var _a, _b; return !((_b = (_a = this.manifest.permissions) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.includes(scope)); });
|
|
62
|
+
if (!missingCurrentScopes.length)
|
|
63
|
+
return [];
|
|
64
|
+
const missingDeprecatedScopes = deprecatedScopes.filter((scope) => { var _a, _b; return !((_b = (_a = this.manifest.permissions) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.includes(scope)); });
|
|
65
|
+
if (deprecatedScopes.length && !missingDeprecatedScopes.length)
|
|
66
|
+
return [];
|
|
67
|
+
if (missingCurrentScopes.length < currentScopes.length) {
|
|
68
|
+
return missingCurrentScopes;
|
|
69
|
+
}
|
|
70
|
+
if (missingDeprecatedScopes.length < deprecatedScopes.length) {
|
|
71
|
+
return missingDeprecatedScopes;
|
|
72
|
+
}
|
|
73
|
+
return missingCurrentScopes;
|
|
61
74
|
}
|
|
62
75
|
getRequiredScopes({ regex, method }) {
|
|
63
76
|
var _a, _b, _c;
|
|
@@ -72,5 +85,14 @@ class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
|
|
|
72
85
|
return [];
|
|
73
86
|
return swaggerEntries === null || swaggerEntries === void 0 ? void 0 : swaggerEntries.reduce((prev, curr) => [...prev, ...(curr['OAuth2'] || []), ...(curr['oAuthDefinitions'] || [])], []);
|
|
74
87
|
}
|
|
88
|
+
getRequiredDeprecatedScopes({ regex, method }) {
|
|
89
|
+
var _a;
|
|
90
|
+
if (!regex)
|
|
91
|
+
return [];
|
|
92
|
+
const oAuth2Scopes = (_a = this.pathMap.get(regex)) === null || _a === void 0 ? void 0 : _a.methods[method]['x-atlassian-oauth2-scopes'];
|
|
93
|
+
if (!oAuth2Scopes)
|
|
94
|
+
return [];
|
|
95
|
+
return array_prototype_flatmap_1.default(oAuth2Scopes.filter((scope) => scope.state === 'Deprecated').map((scope) => scope.scopes), (x) => x);
|
|
96
|
+
}
|
|
75
97
|
}
|
|
76
98
|
exports.ProductVerifier = ProductVerifier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-hook-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/verifiers/ui-hook-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ui-hook-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/verifiers/ui-hook-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AA2BpF,qBAAa,cAAe,SAAQ,qBAAsB,YAAW,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAC/F,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAoC1E,OAAO,CAAC,WAAW;CAepB"}
|
|
@@ -5,17 +5,22 @@ const linter_interface_1 = require("../../../linter-interface");
|
|
|
5
5
|
const verifier_interface_1 = require("../../verifier-interface");
|
|
6
6
|
const text_1 = require("../../../text");
|
|
7
7
|
const FORGE_UI_HOOK_PERMISSIONS = {
|
|
8
|
-
useContentProperty:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'read:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
useContentProperty: {
|
|
9
|
+
current: [
|
|
10
|
+
'read:content-details:confluence',
|
|
11
|
+
'read:content.property:confluence',
|
|
12
|
+
'write:content.property:confluence'
|
|
13
|
+
],
|
|
14
|
+
deprecated: ['read:confluence-props', 'write:confluence-props']
|
|
15
|
+
},
|
|
16
|
+
useSpaceProperty: {
|
|
17
|
+
current: ['read:content-details:confluence', 'read:space.property:confluence', 'write:space.property:confluence'],
|
|
18
|
+
deprecated: ['read:confluence-props', 'write:confluence-props']
|
|
19
|
+
},
|
|
20
|
+
useIssueProperty: {
|
|
21
|
+
current: ['read:issue.property:jira'],
|
|
22
|
+
deprecated: ['read:jira-work', 'write:jira-work']
|
|
23
|
+
}
|
|
19
24
|
};
|
|
20
25
|
class UIHookVerifier extends verifier_interface_1.BaseLintIssueVerifier {
|
|
21
26
|
getLintClass() {
|
|
@@ -23,17 +28,30 @@ class UIHookVerifier extends verifier_interface_1.BaseLintIssueVerifier {
|
|
|
23
28
|
}
|
|
24
29
|
async process(apiCalls) {
|
|
25
30
|
const rules = [];
|
|
26
|
-
|
|
31
|
+
for (const apiCall of apiCalls) {
|
|
27
32
|
const requiredPermissions = FORGE_UI_HOOK_PERMISSIONS[apiCall.hookName];
|
|
28
33
|
if (!requiredPermissions)
|
|
29
34
|
return rules;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const { current, deprecated } = requiredPermissions;
|
|
36
|
+
const missingCurrentPerms = current.filter((perm) => { var _a, _b; return !((_b = (_a = this.manifest.permissions) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.includes(perm)); });
|
|
37
|
+
if (!missingCurrentPerms.length)
|
|
38
|
+
continue;
|
|
39
|
+
let missingDeprecatedPerms = null;
|
|
40
|
+
if (deprecated) {
|
|
41
|
+
missingDeprecatedPerms = deprecated.filter((perm) => { var _a, _b; return !((_b = (_a = this.manifest.permissions) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.includes(perm)); });
|
|
42
|
+
if (!missingDeprecatedPerms.length)
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (missingCurrentPerms.length < current.length) {
|
|
46
|
+
missingCurrentPerms.forEach((perm) => rules.push(this.getHookRule(apiCall, perm)));
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (deprecated && missingDeprecatedPerms && (missingDeprecatedPerms === null || missingDeprecatedPerms === void 0 ? void 0 : missingDeprecatedPerms.length) < deprecated.length) {
|
|
50
|
+
missingDeprecatedPerms.forEach((perm) => rules.push(this.getHookRule(apiCall, perm)));
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
missingCurrentPerms.forEach((perm) => rules.push(this.getHookRule(apiCall, perm)));
|
|
54
|
+
}
|
|
37
55
|
return rules;
|
|
38
56
|
}
|
|
39
57
|
getHookRule(apiCall, permission) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/lint",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1-next.3",
|
|
4
4
|
"description": "Linting for forge apps",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"@types/node-fetch": "^2.5.7"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@forge/cli-shared": "2.2.
|
|
18
|
+
"@forge/cli-shared": "2.2.1-next.2",
|
|
19
19
|
"@forge/csp": "1.9.0",
|
|
20
|
-
"@forge/manifest": "3.0.
|
|
20
|
+
"@forge/manifest": "3.1.0-next.2",
|
|
21
21
|
"@typescript-eslint/typescript-estree": "^3.5.0",
|
|
22
22
|
"cross-spawn": "^7.0.1",
|
|
23
23
|
"node-fetch": "^2.6.1",
|