@forge/lint 1.5.0-next.9 → 1.6.0-next.10

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,120 @@
1
1
  # @forge/lint
2
2
 
3
+ ## 1.6.0-next.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [601527b]
8
+ - @forge/manifest@2.5.0-next.9
9
+ - @forge/cli-shared@2.1.5-next.9
10
+
11
+ ## 1.6.0-next.9
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [a5656f6]
16
+ - Updated dependencies [78d682f]
17
+ - @forge/manifest@2.5.0-next.8
18
+ - @forge/cli-shared@2.1.5-next.8
19
+
20
+ ## 1.6.0-next.8
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [cc8799c]
25
+ - @forge/manifest@2.5.0-next.7
26
+ - @forge/cli-shared@2.1.5-next.7
27
+
28
+ ## 1.6.0-next.7
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [0e82242]
33
+ - @forge/manifest@2.5.0-next.6
34
+ - @forge/cli-shared@2.1.5-next.6
35
+
36
+ ## 1.6.0-next.6
37
+
38
+ ### Patch Changes
39
+
40
+ - fc38deb: Fix bug on the auto-fix permissions linter
41
+ - Updated dependencies [f5eb8e0]
42
+ - @forge/manifest@2.5.0-next.5
43
+ - @forge/cli-shared@2.1.5-next.5
44
+
45
+ ## 1.6.0-next.5
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [4de9850]
50
+ - @forge/manifest@2.5.0-next.4
51
+ - @forge/cli-shared@2.1.5-next.4
52
+
53
+ ## 1.6.0-next.4
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [dec8066]
58
+ - @forge/manifest@2.5.0-next.3
59
+ - @forge/cli-shared@2.1.5-next.3
60
+
61
+ ## 1.6.0-next.3
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [755e35e]
66
+ - Updated dependencies [f013199]
67
+ - @forge/manifest@2.5.0-next.2
68
+ - @forge/cli-shared@2.1.5-next.2
69
+
70
+ ## 1.6.0-next.2
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies [66f60f9]
75
+ - @forge/manifest@2.5.0-next.1
76
+ - @forge/cli-shared@2.1.5-next.1
77
+
78
+ ## 1.6.0-next.1
79
+
80
+ ### Minor Changes
81
+
82
+ - b8aa35d: Support linting external auth api calls.
83
+
84
+ ## 1.5.1-next.0
85
+
86
+ ### Patch Changes
87
+
88
+ - Updated dependencies [bc0c83b]
89
+ - @forge/manifest@2.4.1-next.0
90
+ - @forge/cli-shared@2.1.5-next.0
91
+
92
+ ## 1.5.0
93
+
94
+ ### Minor Changes
95
+
96
+ - fbcb4a3: Add linter detection & auto-fix of deprecated CSP
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [fbcb4a3]
101
+ - Updated dependencies [0bc8683]
102
+ - Updated dependencies [f08a9cb]
103
+ - Updated dependencies [e28cc2c]
104
+ - Updated dependencies [b415d76]
105
+ - Updated dependencies [b91d511]
106
+ - Updated dependencies [daa138b]
107
+ - Updated dependencies [33cbdba]
108
+ - Updated dependencies [ee3919d]
109
+ - Updated dependencies [ba6d463]
110
+ - Updated dependencies [1d7f9f1]
111
+ - Updated dependencies [82167f3]
112
+ - Updated dependencies [873f913]
113
+ - Updated dependencies [a9bdd4f]
114
+ - Updated dependencies [2ea75dd]
115
+ - @forge/manifest@2.4.0
116
+ - @forge/cli-shared@2.1.4
117
+
3
118
  ## 1.5.0-next.9
4
119
 
5
120
  ### Patch Changes
@@ -37,7 +37,7 @@ exports.fixMissingPermissions = async (errors, warnings, state) => {
37
37
  const currentPermissions = (_b = (_a = (await state.configFile.readConfig())) === null || _a === void 0 ? void 0 : _a.permissions) !== null && _b !== void 0 ? _b : {};
38
38
  const currentRemotes = (_d = (_c = (await state.configFile.readConfig())) === null || _c === void 0 ? void 0 : _c.remotes) !== null && _d !== void 0 ? _d : [];
39
39
  const currentScopes = (_e = currentPermissions === null || currentPermissions === void 0 ? void 0 : currentPermissions.scopes) !== null && _e !== void 0 ? _e : [];
40
- currentScopes.forEach(missingScopes.add);
40
+ currentScopes.forEach((e) => missingScopes.add(e));
41
41
  const currentExternalFetchBackend = (_h = (_g = (_f = currentPermissions === null || currentPermissions === void 0 ? void 0 : currentPermissions.external) === null || _f === void 0 ? void 0 : _f.fetch) === null || _g === void 0 ? void 0 : _g.backend) !== null && _h !== void 0 ? _h : [];
42
42
  currentExternalFetchBackend
43
43
  .map((item) => {
@@ -47,10 +47,10 @@ exports.fixMissingPermissions = async (errors, warnings, state) => {
47
47
  return (_a = currentRemotes.find((remote) => remote.key == item.remote)) === null || _a === void 0 ? void 0 : _a.baseUrl;
48
48
  })
49
49
  .filter((item) => typeof item === 'string')
50
- .forEach(missingExternalFetchBackend.add);
50
+ .forEach((e) => missingExternalFetchBackend.add(e));
51
51
  const arrayMissingExternalFetchBackend = [...missingExternalFetchBackend];
52
52
  const currentContentStyles = (_k = (_j = currentPermissions === null || currentPermissions === void 0 ? void 0 : currentPermissions.content) === null || _j === void 0 ? void 0 : _j.styles) !== null && _k !== void 0 ? _k : [];
53
- currentContentStyles.forEach(missingContentStyle.add);
53
+ currentContentStyles.forEach((e) => missingContentStyle.add(e));
54
54
  const arrayMissingContentStyles = [...missingContentStyle];
55
55
  await state.configFile.writeToConfigFile('permissions', Object.assign(Object.assign(Object.assign(Object.assign({}, currentPermissions), { scopes: [...missingScopes] }), (arrayMissingExternalFetchBackend.length > 0
56
56
  ? {
@@ -3,6 +3,7 @@ import { NodeVisitor } from '../../node-visitor-interface';
3
3
  import { ApiCall } from '../api-call-interface';
4
4
  export declare class ExternalApiCallVisitor implements NodeVisitor<ApiCall> {
5
5
  visit(node: TSESTree.Node, parent: TSESTree.Node | undefined, callback: (fetchCall: ApiCall) => void): void;
6
+ private endpointCanBeChecked;
6
7
  private transformArgsToFetchCall;
7
8
  }
8
9
  //# sourceMappingURL=external-fetch-call-visitor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-fetch-call-visitor.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/visitors/external-fetch-call-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAgB,MAAM,uBAAuB,CAAC;AAE9D,qBAAa,sBAAuB,YAAW,WAAW,CAAC,OAAO,CAAC;IAC1D,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IA+ClH,OAAO,CAAC,wBAAwB,CAK7B;CACJ"}
1
+ {"version":3,"file":"external-fetch-call-visitor.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/visitors/external-fetch-call-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAGhF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAgB,MAAM,uBAAuB,CAAC;AAE9D,qBAAa,sBAAuB,YAAW,WAAW,CAAC,OAAO,CAAC;IAC1D,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IA+ClH,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,wBAAwB,CAK7B;CACJ"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExternalApiCallVisitor = void 0;
4
4
  const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
+ const url_1 = require("url");
5
6
  const api_call_interface_1 = require("../api-call-interface");
6
7
  class ExternalApiCallVisitor {
7
8
  constructor() {
@@ -30,15 +31,29 @@ class ExternalApiCallVisitor {
30
31
  node.property.name === 'fetch' &&
31
32
  (parent === null || parent === void 0 ? void 0 : parent.type) === typescript_estree_1.AST_NODE_TYPES.CallExpression) {
32
33
  const [endpointNode] = parent.arguments;
33
- if ((endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.type) === typescript_estree_1.AST_NODE_TYPES.Literal && typeof (endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.value) === 'string') {
34
- if (endpointNode.value.trim() !== '') {
35
- const fetchCall = this.transformArgsToFetchCall(endpointNode);
36
- callback(fetchCall);
37
- }
34
+ if (this.endpointCanBeChecked(endpointNode)) {
35
+ const fetchCall = this.transformArgsToFetchCall(endpointNode);
36
+ callback(fetchCall);
38
37
  }
39
38
  }
40
39
  break;
41
40
  }
42
41
  }
42
+ endpointCanBeChecked(endpointNode) {
43
+ const throws = (thunk) => {
44
+ try {
45
+ thunk();
46
+ return false;
47
+ }
48
+ catch (_a) {
49
+ return true;
50
+ }
51
+ };
52
+ const isPathOnlyUrl = (s) => throws(() => new url_1.URL(s)) && !throws(() => new url_1.URL(s, 'http://example'));
53
+ return ((endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.type) === typescript_estree_1.AST_NODE_TYPES.Literal &&
54
+ typeof (endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.value) === 'string' &&
55
+ endpointNode.value.trim() !== '' &&
56
+ !isPathOnlyUrl(endpointNode.value));
57
+ }
43
58
  }
44
59
  exports.ExternalApiCallVisitor = ExternalApiCallVisitor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/lint",
3
- "version": "1.5.0-next.9",
3
+ "version": "1.6.0-next.10",
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.1.4-next.9",
18
+ "@forge/cli-shared": "2.1.5-next.9",
19
19
  "@forge/csp": "1.8.0",
20
- "@forge/manifest": "2.4.0-next.9",
20
+ "@forge/manifest": "2.5.0-next.9",
21
21
  "@typescript-eslint/typescript-estree": "^3.5.0",
22
22
  "cross-spawn": "^7.0.1",
23
23
  "node-fetch": "^2.6.1"