@forge/lint 1.5.0 → 1.6.0-next.11

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,102 @@
1
1
  # @forge/lint
2
2
 
3
+ ## 1.6.0-next.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [fde4ba7]
8
+ - @forge/manifest@2.5.0-next.10
9
+ - @forge/cli-shared@2.1.5-next.10
10
+
11
+ ## 1.6.0-next.10
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [601527b]
16
+ - @forge/manifest@2.5.0-next.9
17
+ - @forge/cli-shared@2.1.5-next.9
18
+
19
+ ## 1.6.0-next.9
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [a5656f6]
24
+ - Updated dependencies [78d682f]
25
+ - @forge/manifest@2.5.0-next.8
26
+ - @forge/cli-shared@2.1.5-next.8
27
+
28
+ ## 1.6.0-next.8
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [cc8799c]
33
+ - @forge/manifest@2.5.0-next.7
34
+ - @forge/cli-shared@2.1.5-next.7
35
+
36
+ ## 1.6.0-next.7
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [0e82242]
41
+ - @forge/manifest@2.5.0-next.6
42
+ - @forge/cli-shared@2.1.5-next.6
43
+
44
+ ## 1.6.0-next.6
45
+
46
+ ### Patch Changes
47
+
48
+ - fc38deb: Fix bug on the auto-fix permissions linter
49
+ - Updated dependencies [f5eb8e0]
50
+ - @forge/manifest@2.5.0-next.5
51
+ - @forge/cli-shared@2.1.5-next.5
52
+
53
+ ## 1.6.0-next.5
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [4de9850]
58
+ - @forge/manifest@2.5.0-next.4
59
+ - @forge/cli-shared@2.1.5-next.4
60
+
61
+ ## 1.6.0-next.4
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [dec8066]
66
+ - @forge/manifest@2.5.0-next.3
67
+ - @forge/cli-shared@2.1.5-next.3
68
+
69
+ ## 1.6.0-next.3
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies [755e35e]
74
+ - Updated dependencies [f013199]
75
+ - @forge/manifest@2.5.0-next.2
76
+ - @forge/cli-shared@2.1.5-next.2
77
+
78
+ ## 1.6.0-next.2
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [66f60f9]
83
+ - @forge/manifest@2.5.0-next.1
84
+ - @forge/cli-shared@2.1.5-next.1
85
+
86
+ ## 1.6.0-next.1
87
+
88
+ ### Minor Changes
89
+
90
+ - b8aa35d: Support linting external auth api calls.
91
+
92
+ ## 1.5.1-next.0
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [bc0c83b]
97
+ - @forge/manifest@2.4.1-next.0
98
+ - @forge/cli-shared@2.1.5-next.0
99
+
3
100
  ## 1.5.0
4
101
 
5
102
  ### Minor 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",
3
+ "version": "1.6.0-next.11",
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",
18
+ "@forge/cli-shared": "2.1.5-next.10",
19
19
  "@forge/csp": "1.8.0",
20
- "@forge/manifest": "2.4.0",
20
+ "@forge/manifest": "2.5.0-next.10",
21
21
  "@typescript-eslint/typescript-estree": "^3.5.0",
22
22
  "cross-spawn": "^7.0.1",
23
23
  "node-fetch": "^2.6.1"