@appland/scanner 1.55.0 → 1.58.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.
Files changed (244) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/built/algorithms/dataStructures/graph/Graph.js +53 -62
  3. package/built/algorithms/dataStructures/graph/GraphEdge.js +13 -16
  4. package/built/algorithms/dataStructures/graph/GraphVertex.js +37 -42
  5. package/built/algorithms/dataStructures/linked-list/LinkedList.js +33 -38
  6. package/built/algorithms/dataStructures/linked-list/LinkedListNode.js +6 -10
  7. package/built/algorithms/graph/depth-first-search/index.js +7 -8
  8. package/built/algorithms/graph/detect-cycle/index.js +15 -16
  9. package/built/algorithms/utils/Comparator.js +19 -21
  10. package/built/analyzer/recordSecrets.js +7 -30
  11. package/built/analyzer/secretsRegexes.js +8 -9
  12. package/built/appMapIndex.js +19 -21
  13. package/built/check.js +17 -21
  14. package/built/checkInstance.js +26 -48
  15. package/built/cli/ci/command.js +61 -156
  16. package/built/cli/ci/options.js +0 -1
  17. package/built/cli/codeVersionArgs.js +0 -1
  18. package/built/cli/exitCode.js +0 -1
  19. package/built/cli/fail.js +2 -3
  20. package/built/cli/merge/command.js +21 -63
  21. package/built/cli/merge/options.js +0 -1
  22. package/built/cli/reportUploadURL.js +2 -3
  23. package/built/cli/resolveAppId.js +34 -85
  24. package/built/cli/scan/command.js +57 -242
  25. package/built/cli/scan/formatReport.js +44 -0
  26. package/built/cli/scan/options.js +0 -1
  27. package/built/cli/scan/scanner.js +38 -117
  28. package/built/cli/scan/singleScan.js +80 -0
  29. package/built/cli/scan/watchScan.js +102 -0
  30. package/built/cli/scan.js +39 -132
  31. package/built/cli/scanArgs.js +0 -1
  32. package/built/cli/scanOptions.js +0 -1
  33. package/built/cli/updateCommitStatus.js +10 -47
  34. package/built/cli/upload/command.js +20 -64
  35. package/built/cli/upload/options.js +0 -1
  36. package/built/cli/upload/pruneAppMap.js +16 -0
  37. package/built/cli/upload.js +91 -172
  38. package/built/cli/validateFile.js +13 -48
  39. package/built/cli.js +34 -21
  40. package/built/configuration/configurationProvider.js +151 -233
  41. package/built/configuration/schema/options.json +76 -76
  42. package/built/configuration/types/checkConfig.js +0 -1
  43. package/built/configuration/types/configuration.js +0 -1
  44. package/built/configuration/types/matchEventConfig.js +0 -1
  45. package/built/configuration/types/matchPatternConfig.js +0 -1
  46. package/built/database/index.js +35 -128
  47. package/built/database/visit.js +20 -68
  48. package/built/errors.js +4 -30
  49. package/built/eventUtil.js +10 -35
  50. package/built/findings.js +3 -4
  51. package/built/integration/appland/app/exists.js +33 -76
  52. package/built/integration/appland/app/listFindingStatus.js +5 -38
  53. package/built/integration/appland/appMap/create.js +38 -89
  54. package/built/integration/appland/location.js +0 -1
  55. package/built/integration/appland/mapset/create.js +34 -85
  56. package/built/integration/appland/retry.js +10 -11
  57. package/built/integration/appland/retryOptions.js +0 -1
  58. package/built/integration/appland/scannerJob/create.js +34 -84
  59. package/built/integration/appland/scannerJob/merge.js +28 -74
  60. package/built/integration/appland/scannerJob.js +0 -1
  61. package/built/integration/github/commitStatus.js +3 -4
  62. package/built/integration/vars.js +1 -2
  63. package/built/openapi/index.js +39 -83
  64. package/built/report/appMapMetadata.js +0 -1
  65. package/built/report/findingSummary.js +0 -1
  66. package/built/report/findingsReport.js +14 -16
  67. package/built/report/scanResults.js +50 -72
  68. package/built/report/scanSummary.js +0 -1
  69. package/built/report/summaryReport.js +12 -13
  70. package/built/ruleChecker.js +146 -297
  71. package/built/rules/authzBeforeAuthn.js +25 -59
  72. package/built/rules/circularDependency.js +69 -101
  73. package/built/rules/deserializationOfUntrustedData.js +29 -63
  74. package/built/rules/execOfUntrustedCommand.js +28 -62
  75. package/built/rules/http-500/metadata.js +0 -1
  76. package/built/rules/http-500/rule.js +2 -3
  77. package/built/rules/illegalPackageDependency.js +16 -18
  78. package/built/rules/incompatibleHttpClientRequest.js +30 -69
  79. package/built/rules/insecureCompare.js +12 -13
  80. package/built/rules/jobNotCancelled.js +13 -45
  81. package/built/rules/lib/hasParameterOrReceiver.js +4 -7
  82. package/built/rules/lib/matchEvent.js +12 -13
  83. package/built/rules/lib/matchPattern.js +6 -7
  84. package/built/rules/lib/metadata.js +0 -1
  85. package/built/rules/lib/parseRuleDescription.js +5 -6
  86. package/built/rules/lib/precedingEvents.js +7 -75
  87. package/built/rules/lib/rpcWithoutProtection.js +5 -28
  88. package/built/rules/lib/sanitizesData.js +0 -1
  89. package/built/rules/lib/util.js +34 -73
  90. package/built/rules/logoutWithoutSessionReset.js +24 -58
  91. package/built/rules/missingAuthentication.js +28 -28
  92. package/built/rules/missingContentType.js +8 -9
  93. package/built/rules/nPlusOneQuery.js +35 -87
  94. package/built/rules/queryFromInvalidPackage.js +17 -19
  95. package/built/rules/queryFromView.js +13 -16
  96. package/built/rules/rpcWithoutCircuitBreaker.js +14 -84
  97. package/built/rules/saveWithoutValidation.js +8 -9
  98. package/built/rules/secretInLog.js +30 -93
  99. package/built/rules/slowFunctionCall.js +16 -20
  100. package/built/rules/slowHttpServerRequest.js +9 -11
  101. package/built/rules/slowQuery.js +9 -12
  102. package/built/rules/tooManyJoins.js +26 -51
  103. package/built/rules/tooManyUpdates.js +25 -105
  104. package/built/rules/unbatchedMaterializedQuery.js +26 -30
  105. package/built/rules/updateInGetRequest.js +30 -45
  106. package/built/scope/commandScope.js +24 -144
  107. package/built/scope/httpClientRequestScope.js +11 -98
  108. package/built/scope/httpServerRequestScope.js +11 -98
  109. package/built/scope/rootScope.js +11 -98
  110. package/built/scope/scopeImpl.js +10 -82
  111. package/built/scope/scopeIterator.js +6 -10
  112. package/built/scope/sqlTransactionScope.js +24 -122
  113. package/built/sqlWarning.js +9 -35
  114. package/built/telemetry.js +215 -0
  115. package/built/wellKnownLabels.js +0 -1
  116. package/package.json +10 -3
  117. package/built/algorithms/dataStructures/graph/Graph.js.map +0 -1
  118. package/built/algorithms/dataStructures/graph/GraphEdge.js.map +0 -1
  119. package/built/algorithms/dataStructures/graph/GraphVertex.js.map +0 -1
  120. package/built/algorithms/dataStructures/linked-list/LinkedList.js.map +0 -1
  121. package/built/algorithms/dataStructures/linked-list/LinkedListNode.js.map +0 -1
  122. package/built/algorithms/graph/depth-first-search/index.js.map +0 -1
  123. package/built/algorithms/graph/detect-cycle/index.js.map +0 -1
  124. package/built/algorithms/utils/Comparator.js.map +0 -1
  125. package/built/analyzer/recordSecrets.js.map +0 -1
  126. package/built/analyzer/secretsRegexes.js.map +0 -1
  127. package/built/appMapIndex.js.map +0 -1
  128. package/built/check.js.map +0 -1
  129. package/built/checkInstance.js.map +0 -1
  130. package/built/cli/ci/command.js.map +0 -1
  131. package/built/cli/ci/options.js.map +0 -1
  132. package/built/cli/codeVersionArgs.js.map +0 -1
  133. package/built/cli/exitCode.js.map +0 -1
  134. package/built/cli/fail.js.map +0 -1
  135. package/built/cli/merge/command.js.map +0 -1
  136. package/built/cli/merge/options.js.map +0 -1
  137. package/built/cli/reportUploadURL.js.map +0 -1
  138. package/built/cli/resolveAppId.js.map +0 -1
  139. package/built/cli/scan/command.js.map +0 -1
  140. package/built/cli/scan/options.js.map +0 -1
  141. package/built/cli/scan/scanner.js.map +0 -1
  142. package/built/cli/scan.js.map +0 -1
  143. package/built/cli/scanArgs.js.map +0 -1
  144. package/built/cli/scanOptions.js.map +0 -1
  145. package/built/cli/updateCommitStatus.js.map +0 -1
  146. package/built/cli/upload/command.js.map +0 -1
  147. package/built/cli/upload/options.js.map +0 -1
  148. package/built/cli/upload.js.map +0 -1
  149. package/built/cli/validateFile.js.map +0 -1
  150. package/built/cli.js.map +0 -1
  151. package/built/configuration/configurationProvider.js.map +0 -1
  152. package/built/configuration/types/checkConfig.js.map +0 -1
  153. package/built/configuration/types/configuration.js.map +0 -1
  154. package/built/configuration/types/matchEventConfig.js.map +0 -1
  155. package/built/configuration/types/matchPatternConfig.js.map +0 -1
  156. package/built/database/index.js.map +0 -1
  157. package/built/database/visit.js.map +0 -1
  158. package/built/errors.js.map +0 -1
  159. package/built/eventUtil.js.map +0 -1
  160. package/built/findings.js.map +0 -1
  161. package/built/integration/appland/app/exists.js.map +0 -1
  162. package/built/integration/appland/app/listFindingStatus.js.map +0 -1
  163. package/built/integration/appland/appMap/create.js.map +0 -1
  164. package/built/integration/appland/location.js.map +0 -1
  165. package/built/integration/appland/mapset/create.js.map +0 -1
  166. package/built/integration/appland/retry.js.map +0 -1
  167. package/built/integration/appland/retryOptions.js.map +0 -1
  168. package/built/integration/appland/scannerJob/create.js.map +0 -1
  169. package/built/integration/appland/scannerJob/merge.js.map +0 -1
  170. package/built/integration/appland/scannerJob.js.map +0 -1
  171. package/built/integration/github/commitStatus.js.map +0 -1
  172. package/built/integration/vars.js.map +0 -1
  173. package/built/openapi/index.js.map +0 -1
  174. package/built/openapi/method.js +0 -120
  175. package/built/openapi/method.js.map +0 -1
  176. package/built/openapi/model.js +0 -49
  177. package/built/openapi/model.js.map +0 -1
  178. package/built/openapi/path.js +0 -36
  179. package/built/openapi/path.js.map +0 -1
  180. package/built/openapi/provider.js +0 -133
  181. package/built/openapi/provider.js.map +0 -1
  182. package/built/openapi/response.js +0 -59
  183. package/built/openapi/response.js.map +0 -1
  184. package/built/openapi/rpcRequest.js +0 -130
  185. package/built/openapi/rpcRequest.js.map +0 -1
  186. package/built/openapi/schema.js +0 -42
  187. package/built/openapi/schema.js.map +0 -1
  188. package/built/openapi/securitySchemes.js +0 -32
  189. package/built/openapi/securitySchemes.js.map +0 -1
  190. package/built/openapi/statusCodes.js +0 -68
  191. package/built/openapi/statusCodes.js.map +0 -1
  192. package/built/openapi/util.js +0 -91
  193. package/built/openapi/util.js.map +0 -1
  194. package/built/report/appMapMetadata.js.map +0 -1
  195. package/built/report/findingSummary.js.map +0 -1
  196. package/built/report/findingsReport.js.map +0 -1
  197. package/built/report/scanResults.js.map +0 -1
  198. package/built/report/scanSummary.js.map +0 -1
  199. package/built/report/summaryReport.js.map +0 -1
  200. package/built/ruleChecker.js.map +0 -1
  201. package/built/rules/authzBeforeAuthn.js.map +0 -1
  202. package/built/rules/circularDependency.js.map +0 -1
  203. package/built/rules/deserializationOfUntrustedData.js.map +0 -1
  204. package/built/rules/execOfUntrustedCommand.js.map +0 -1
  205. package/built/rules/http-500/metadata.js.map +0 -1
  206. package/built/rules/http-500/rule.js.map +0 -1
  207. package/built/rules/illegalPackageDependency.js.map +0 -1
  208. package/built/rules/incompatibleHttpClientRequest.js.map +0 -1
  209. package/built/rules/insecureCompare.js.map +0 -1
  210. package/built/rules/jobNotCancelled.js.map +0 -1
  211. package/built/rules/lib/hasParameterOrReceiver.js.map +0 -1
  212. package/built/rules/lib/matchEvent.js.map +0 -1
  213. package/built/rules/lib/matchPattern.js.map +0 -1
  214. package/built/rules/lib/metadata.js.map +0 -1
  215. package/built/rules/lib/parseRuleDescription.js.map +0 -1
  216. package/built/rules/lib/precedingEvents.js.map +0 -1
  217. package/built/rules/lib/rpcWithoutProtection.js.map +0 -1
  218. package/built/rules/lib/sanitizesData.js.map +0 -1
  219. package/built/rules/lib/util.js.map +0 -1
  220. package/built/rules/logoutWithoutSessionReset.js.map +0 -1
  221. package/built/rules/missingAuthentication.js.map +0 -1
  222. package/built/rules/missingContentType.js.map +0 -1
  223. package/built/rules/nPlusOneQuery.js.map +0 -1
  224. package/built/rules/queryFromInvalidPackage.js.map +0 -1
  225. package/built/rules/queryFromView.js.map +0 -1
  226. package/built/rules/rpcWithoutCircuitBreaker.js.map +0 -1
  227. package/built/rules/saveWithoutValidation.js.map +0 -1
  228. package/built/rules/secretInLog.js.map +0 -1
  229. package/built/rules/slowFunctionCall.js.map +0 -1
  230. package/built/rules/slowHttpServerRequest.js.map +0 -1
  231. package/built/rules/slowQuery.js.map +0 -1
  232. package/built/rules/tooManyJoins.js.map +0 -1
  233. package/built/rules/tooManyUpdates.js.map +0 -1
  234. package/built/rules/unbatchedMaterializedQuery.js.map +0 -1
  235. package/built/rules/updateInGetRequest.js.map +0 -1
  236. package/built/scope/commandScope.js.map +0 -1
  237. package/built/scope/httpClientRequestScope.js.map +0 -1
  238. package/built/scope/httpServerRequestScope.js.map +0 -1
  239. package/built/scope/rootScope.js.map +0 -1
  240. package/built/scope/scopeImpl.js.map +0 -1
  241. package/built/scope/scopeIterator.js.map +0 -1
  242. package/built/scope/sqlTransactionScope.js.map +0 -1
  243. package/built/sqlWarning.js.map +0 -1
  244. package/built/wellKnownLabels.js.map +0 -1
@@ -3,44 +3,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var matchPattern_1 = require("./lib/matchPattern");
7
- var url_1 = require("url");
8
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
6
+ const matchPattern_1 = require("./lib/matchPattern");
7
+ const url_1 = require("url");
8
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
9
9
  // TODO: Use the Query AST for this.
10
- var WHITELIST = [/\bBEGIN\b/i, /\bCOMMIT\b/i, /\bROLLBACK\b/i, /\bRELEASE\b/i, /\bSAVEPOINT\b/i];
11
- var Options = /** @class */ (function () {
12
- function Options() {
10
+ const WHITELIST = [/\bBEGIN\b/i, /\bCOMMIT\b/i, /\bROLLBACK\b/i, /\bRELEASE\b/i, /\bSAVEPOINT\b/i];
11
+ class Options {
12
+ constructor() {
13
13
  this.allowedPackages = [];
14
- this.allowedQueries = WHITELIST.map(function (regexp) { return ({ match: regexp }); });
14
+ this.allowedQueries = WHITELIST.map((regexp) => ({ match: regexp }));
15
15
  }
16
- return Options;
17
- }());
16
+ }
18
17
  function build(options) {
19
- var allowedPackages = (0, matchPattern_1.buildFilters)(options.allowedPackages);
20
- var allowedQueries = (0, matchPattern_1.buildFilters)(options.allowedQueries);
18
+ const allowedPackages = (0, matchPattern_1.buildFilters)(options.allowedPackages);
19
+ const allowedQueries = (0, matchPattern_1.buildFilters)(options.allowedQueries);
21
20
  function matcher(e) {
22
- if (!allowedPackages.some(function (filter) { return filter(e.parent.codeObject.packageOf); })) {
21
+ if (!allowedPackages.some((filter) => filter(e.parent.codeObject.packageOf))) {
23
22
  return [
24
23
  {
25
24
  event: e,
26
- message: "".concat(e.codeObject.id, " is invoked from illegal package ").concat(e.parent.codeObject.packageOf),
25
+ message: `${e.codeObject.id} is invoked from illegal package ${e.parent.codeObject.packageOf}`,
27
26
  relatedEvents: [e.parent],
28
27
  },
29
28
  ];
30
29
  }
31
30
  }
32
31
  function where(e) {
33
- return !!e.sqlQuery && !!e.parent && !allowedQueries.some(function (pattern) { return pattern(e.sqlQuery); });
32
+ return !!e.sqlQuery && !!e.parent && !allowedQueries.some((pattern) => pattern(e.sqlQuery));
34
33
  }
35
34
  return {
36
- matcher: matcher,
37
- where: where,
35
+ matcher,
36
+ where,
38
37
  };
39
38
  }
40
39
  exports.default = {
41
40
  id: 'query-from-invalid-package',
42
41
  title: 'Queries from invalid packages',
43
- Options: Options,
42
+ Options,
44
43
  impactDomain: 'Maintainability',
45
44
  enumerateScope: true,
46
45
  references: {
@@ -48,6 +47,5 @@ exports.default = {
48
47
  },
49
48
  description: (0, parseRuleDescription_1.default)('queryFromInvalidPackage'),
50
49
  url: 'https://appland.com/docs/analysis/rules-reference.html#query-from-invalid-package',
51
- build: build,
50
+ build,
52
51
  };
53
- //# sourceMappingURL=queryFromInvalidPackage.js.map
@@ -3,25 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var url_1 = require("url");
7
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
8
- var Options = /** @class */ (function () {
9
- function Options() {
6
+ const url_1 = require("url");
7
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
8
+ class Options {
9
+ constructor() {
10
10
  this.forbiddenLabel = 'mvc.template';
11
11
  }
12
- return Options;
13
- }());
14
- function build(options) {
15
- if (options === void 0) { options = new Options(); }
12
+ }
13
+ function build(options = new Options()) {
16
14
  function matcher(e) {
17
- var forbiddenAncestor = e
15
+ const forbiddenAncestor = e
18
16
  .ancestors()
19
- .find(function (e) { return e.codeObject.labels.has(options.forbiddenLabel); });
17
+ .find((e) => e.codeObject.labels.has(options.forbiddenLabel));
20
18
  if (forbiddenAncestor) {
21
19
  return [
22
20
  {
23
21
  event: e,
24
- message: "SQL query is invoked from invalid event ".concat(forbiddenAncestor, ", labeled ").concat(options.forbiddenLabel),
22
+ message: `SQL query is invoked from invalid event ${forbiddenAncestor}, labeled ${options.forbiddenLabel}`,
25
23
  relatedEvents: [forbiddenAncestor],
26
24
  },
27
25
  ];
@@ -31,14 +29,14 @@ function build(options) {
31
29
  return !!e.sqlQuery;
32
30
  }
33
31
  return {
34
- matcher: matcher,
35
- where: where,
32
+ matcher,
33
+ where,
36
34
  };
37
35
  }
38
36
  exports.default = {
39
37
  id: 'query-from-view',
40
38
  title: 'Queries from view',
41
- Options: Options,
39
+ Options,
42
40
  impactDomain: 'Maintainability',
43
41
  enumerateScope: true,
44
42
  references: {
@@ -46,6 +44,5 @@ exports.default = {
46
44
  },
47
45
  description: (0, parseRuleDescription_1.default)('queryFromView'),
48
46
  url: 'https://appland.com/docs/analysis/rules-reference.html#query-from-view',
49
- build: build,
47
+ build,
50
48
  };
51
- //# sourceMappingURL=queryFromView.js.map
@@ -1,104 +1,34 @@
1
1
  "use strict";
2
- var __generator = (this && this.__generator) || function (thisArg, body) {
3
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5
- function verb(n) { return function (v) { return step([n, v]); }; }
6
- function step(op) {
7
- if (f) throw new TypeError("Generator is already executing.");
8
- while (_) try {
9
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
10
- if (y = 0, t) op = [op[0] & 2, t.value];
11
- switch (op[0]) {
12
- case 0: case 1: t = op; break;
13
- case 4: _.label++; return { value: op[1], done: false };
14
- case 5: _.label++; y = op[1]; op = [0]; continue;
15
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
16
- default:
17
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
18
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
19
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
20
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
21
- if (t[2]) _.ops.pop();
22
- _.trys.pop(); continue;
23
- }
24
- op = body.call(thisArg, _);
25
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
26
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
27
- }
28
- };
29
- var __values = (this && this.__values) || function(o) {
30
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
31
- if (m) return m.call(o);
32
- if (o && typeof o.length === "number") return {
33
- next: function () {
34
- if (o && i >= o.length) o = void 0;
35
- return { value: o && o[i++], done: !o };
36
- }
37
- };
38
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
39
- };
40
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
41
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
42
4
  };
43
5
  Object.defineProperty(exports, "__esModule", { value: true });
44
- var models_1 = require("@appland/models");
45
- var rpcWithoutProtection_1 = require("./lib/rpcWithoutProtection");
46
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
47
- var Options = /** @class */ (function () {
48
- function Options() {
6
+ const models_1 = require("@appland/models");
7
+ const rpcWithoutProtection_1 = require("./lib/rpcWithoutProtection");
8
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
9
+ class Options {
10
+ constructor() {
49
11
  this.expectedLabel = RPCCircuitBreaker;
50
12
  }
51
- return Options;
52
- }());
13
+ }
53
14
  // The circuit breaker will be found in a descendant of the httpClientRequest.
54
- function descendants(httpClientRequest) {
55
- var _a, _b, candidate, e_1_1;
56
- var e_1, _c;
57
- return __generator(this, function (_d) {
58
- switch (_d.label) {
59
- case 0:
60
- _d.trys.push([0, 5, 6, 7]);
61
- _a = __values(new models_1.EventNavigator(httpClientRequest).descendants()), _b = _a.next();
62
- _d.label = 1;
63
- case 1:
64
- if (!!_b.done) return [3 /*break*/, 4];
65
- candidate = _b.value;
66
- return [4 /*yield*/, candidate.event];
67
- case 2:
68
- _d.sent();
69
- _d.label = 3;
70
- case 3:
71
- _b = _a.next();
72
- return [3 /*break*/, 1];
73
- case 4: return [3 /*break*/, 7];
74
- case 5:
75
- e_1_1 = _d.sent();
76
- e_1 = { error: e_1_1 };
77
- return [3 /*break*/, 7];
78
- case 6:
79
- try {
80
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
81
- }
82
- finally { if (e_1) throw e_1.error; }
83
- return [7 /*endfinally*/];
84
- case 7: return [2 /*return*/];
85
- }
86
- });
15
+ function* descendants(httpClientRequest) {
16
+ for (const candidate of new models_1.EventNavigator(httpClientRequest).descendants()) {
17
+ yield candidate.event;
18
+ }
87
19
  }
88
- function build(options) {
89
- if (options === void 0) { options = new Options(); }
20
+ function build(options = new Options()) {
90
21
  return (0, rpcWithoutProtection_1.rpcWithoutProtection)(descendants, options);
91
22
  }
92
- var RPCCircuitBreaker = 'rpc.circuit_breaker';
23
+ const RPCCircuitBreaker = 'rpc.circuit_breaker';
93
24
  exports.default = {
94
25
  id: 'rpc-without-circuit-breaker',
95
26
  title: 'RPC without circuit breaker',
96
- Options: Options,
27
+ Options,
97
28
  labels: [RPCCircuitBreaker],
98
29
  impactDomain: 'Stability',
99
30
  enumerateScope: true,
100
31
  description: (0, parseRuleDescription_1.default)('rpcWithoutCircuitBreaker'),
101
32
  url: 'https://appland.com/docs/analysis/rules-reference.html#rpc-without-circuit-breaker',
102
- build: build,
33
+ build,
103
34
  };
104
- //# sourceMappingURL=rpcWithoutCircuitBreaker.js.map
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var models_1 = require("@appland/models");
7
- var url_1 = require("url");
8
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
9
- var validatedBy = function (iterator) {
10
- var i = iterator.next();
6
+ const models_1 = require("@appland/models");
7
+ const url_1 = require("url");
8
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
9
+ const validatedBy = (iterator) => {
10
+ let i = iterator.next();
11
11
  while (!i.done) {
12
12
  if (i.value.event.methodId !== undefined &&
13
13
  ['valid?', 'validate'].includes(i.value.event.methodId) // TODO: change this to use labels
@@ -20,8 +20,8 @@ var validatedBy = function (iterator) {
20
20
  };
21
21
  function build() {
22
22
  return {
23
- matcher: function (event) { return !validatedBy(new models_1.EventNavigator(event).descendants()); },
24
- where: function (e) { return e.isFunction && ['save', 'save!'].includes(e.methodId); },
23
+ matcher: (event) => !validatedBy(new models_1.EventNavigator(event).descendants()),
24
+ where: (e) => e.isFunction && ['save', 'save!'].includes(e.methodId),
25
25
  };
26
26
  }
27
27
  exports.default = {
@@ -34,6 +34,5 @@ exports.default = {
34
34
  },
35
35
  description: (0, parseRuleDescription_1.default)('saveWithoutValidation'),
36
36
  url: 'https://appland.com/docs/analysis/rules-reference.html#save-without-validation',
37
- build: build,
37
+ build,
38
38
  };
39
- //# sourceMappingURL=saveWithoutValidation.js.map
@@ -22,114 +22,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __read = (this && this.__read) || function (o, n) {
26
- var m = typeof Symbol === "function" && o[Symbol.iterator];
27
- if (!m) return o;
28
- var i = m.call(o), r, ar = [], e;
29
- try {
30
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
- }
32
- catch (error) { e = { error: error }; }
33
- finally {
34
- try {
35
- if (r && !r.done && (m = i["return"])) m.call(i);
36
- }
37
- finally { if (e) throw e.error; }
38
- }
39
- return ar;
40
- };
41
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
42
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43
- if (ar || !(i in from)) {
44
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
45
- ar[i] = from[i];
46
- }
47
- }
48
- return to.concat(ar || Array.prototype.slice.call(from));
49
- };
50
- var __values = (this && this.__values) || function(o) {
51
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
52
- if (m) return m.call(o);
53
- if (o && typeof o.length === "number") return {
54
- next: function () {
55
- if (o && i >= o.length) o = void 0;
56
- return { value: o && o[i++], done: !o };
57
- }
58
- };
59
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
60
- };
61
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
62
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
27
  };
64
28
  Object.defineProperty(exports, "__esModule", { value: true });
65
- var secretsRegexes_1 = __importStar(require("../analyzer/secretsRegexes"));
66
- var util_1 = require("./lib/util");
67
- var recordSecrets_1 = __importDefault(require("../analyzer/recordSecrets"));
68
- var url_1 = require("url");
69
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
70
- var Match = /** @class */ (function () {
71
- function Match(regexp, value) {
72
- this.regexp = regexp;
29
+ const secretsRegexes_1 = __importStar(require("../analyzer/secretsRegexes"));
30
+ const util_1 = require("./lib/util");
31
+ const recordSecrets_1 = __importDefault(require("../analyzer/recordSecrets"));
32
+ const url_1 = require("url");
33
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
34
+ class Match {
35
+ constructor(pattern, value) {
36
+ this.pattern = pattern;
73
37
  this.value = value;
74
38
  }
75
- return Match;
76
- }());
77
- var secrets = new Set();
78
- var findInLog = function (event) {
79
- var e_1, _a;
39
+ }
40
+ const secrets = new Set();
41
+ const findInLog = (event) => {
80
42
  if (!event.parameters)
81
43
  return;
82
- var matches = [];
83
- var _loop_1 = function (value) {
84
- var e_2, _d;
44
+ const matches = [];
45
+ for (const { value } of event.parameters) {
85
46
  if ((0, util_1.emptyValue)(value))
86
- return "continue";
87
- var patterns = [];
47
+ continue;
48
+ const patterns = [];
88
49
  if ((0, secretsRegexes_1.looksSecret)(value)) {
89
50
  // Only look for the exact matching regexes if it matches the catchall regex
90
- patterns.push.apply(patterns, __spreadArray([], __read(Object.values(secretsRegexes_1.default)
51
+ patterns.push(...Object.values(secretsRegexes_1.default)
91
52
  .flat()
92
- .filter(function (re) { return re.test(value); })), false));
53
+ .filter((re) => re.test(value)));
93
54
  }
94
- try {
95
- for (var secrets_1 = (e_2 = void 0, __values(secrets)), secrets_1_1 = secrets_1.next(); !secrets_1_1.done; secrets_1_1 = secrets_1.next()) {
96
- var secret = secrets_1_1.value;
97
- if (value.includes(secret))
98
- patterns.push(secret);
99
- }
100
- }
101
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
102
- finally {
103
- try {
104
- if (secrets_1_1 && !secrets_1_1.done && (_d = secrets_1.return)) _d.call(secrets_1);
105
- }
106
- finally { if (e_2) throw e_2.error; }
107
- }
108
- matches.push.apply(matches, __spreadArray([], __read(patterns.map(function (pattern) { return new Match(pattern, value); })), false));
109
- };
110
- try {
111
- for (var _b = __values(event.parameters), _c = _b.next(); !_c.done; _c = _b.next()) {
112
- var value = _c.value.value;
113
- _loop_1(value);
114
- }
115
- }
116
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
117
- finally {
118
- try {
119
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
55
+ for (const secret of secrets) {
56
+ if (value.includes(secret))
57
+ patterns.push(secret);
120
58
  }
121
- finally { if (e_1) throw e_1.error; }
59
+ matches.push(...patterns.map((pattern) => new Match(pattern, value)));
122
60
  }
123
61
  if (matches.length > 0) {
124
- return matches.map(function (match) { return ({
125
- event: event,
126
- message: "".concat(match.value, " contains secret ").concat(match.regexp),
127
- }); });
62
+ return matches.map((match) => ({
63
+ event,
64
+ message: `Log event contains secret data: ${match.value}`,
65
+ }));
128
66
  }
129
67
  };
130
68
  function build() {
131
69
  return {
132
- matcher: function (e) {
70
+ matcher: (e) => {
133
71
  if (e.codeObject.labels.has(Secret)) {
134
72
  (0, recordSecrets_1.default)(secrets, e);
135
73
  }
@@ -137,13 +75,13 @@ function build() {
137
75
  return findInLog(e);
138
76
  }
139
77
  },
140
- where: function (e) {
78
+ where: (e) => {
141
79
  return e.codeObject.labels.has(Log) || e.codeObject.labels.has(Secret);
142
80
  },
143
81
  };
144
82
  }
145
- var Secret = 'secret';
146
- var Log = 'log';
83
+ const Secret = 'secret';
84
+ const Log = 'log';
147
85
  exports.default = {
148
86
  id: 'secret-in-log',
149
87
  title: 'Secret in log',
@@ -155,6 +93,5 @@ exports.default = {
155
93
  },
156
94
  description: (0, parseRuleDescription_1.default)('secretInLog'),
157
95
  url: 'https://appland.com/docs/analysis/rules-reference.html#secret-in-log',
158
- build: build,
96
+ build,
159
97
  };
160
- //# sourceMappingURL=secretInLog.js.map
@@ -3,31 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var matchPattern_1 = require("./lib/matchPattern");
7
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
8
- var Options = /** @class */ (function () {
9
- function Options() {
6
+ const matchPattern_1 = require("./lib/matchPattern");
7
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
8
+ class Options {
9
+ constructor() {
10
10
  this.functions = [];
11
11
  this.timeAllowed = 0.1;
12
12
  }
13
- return Options;
14
- }());
13
+ }
15
14
  function build(options) {
16
- var functionPatterns = (0, matchPattern_1.buildFilters)(options.functions || []);
15
+ const functionPatterns = (0, matchPattern_1.buildFilters)(options.functions || []);
17
16
  return {
18
- matcher: function (e) {
17
+ matcher: (e) => {
19
18
  if (e.returnEvent.elapsedTime > options.timeAllowed) {
20
- return "Slow ".concat(e.codeObject.id, " call (").concat(e.returnEvent.elapsedTime, "ms)");
19
+ return `Slow ${e.codeObject.id} call (${e.returnEvent.elapsedTime}ms)`;
21
20
  }
22
21
  },
23
- where: function (e) {
24
- return e.isFunction &&
25
- !!e.returnEvent &&
26
- !!e.returnEvent.elapsedTime &&
27
- !!e.codeObject.id &&
28
- (functionPatterns.length === 0 ||
29
- functionPatterns.some(function (pattern) { return pattern(e.codeObject.id); }));
30
- },
22
+ where: (e) => e.isFunction &&
23
+ !!e.returnEvent &&
24
+ !!e.returnEvent.elapsedTime &&
25
+ !!e.codeObject.id &&
26
+ (functionPatterns.length === 0 ||
27
+ functionPatterns.some((pattern) => pattern(e.codeObject.id))),
31
28
  };
32
29
  }
33
30
  exports.default = {
@@ -38,7 +35,6 @@ exports.default = {
38
35
  enumerateScope: true,
39
36
  description: (0, parseRuleDescription_1.default)('slowFunctionCall'),
40
37
  url: 'https://appland.com/docs/analysis/rules-reference.html#slow-function-call',
41
- Options: Options,
42
- build: build,
38
+ Options,
39
+ build,
43
40
  };
44
- //# sourceMappingURL=slowFunctionCall.js.map
@@ -3,18 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
7
- var Options = /** @class */ (function () {
8
- function Options() {
6
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
7
+ class Options {
8
+ constructor() {
9
9
  this.timeAllowed = 1;
10
10
  }
11
- return Options;
12
- }());
11
+ }
13
12
  function build(options) {
14
13
  return {
15
- matcher: function (e) { return e.elapsedTime > options.timeAllowed; },
16
- message: function () { return "Slow HTTP server request (> ".concat(options.timeAllowed * 1000, "ms)"); },
17
- where: function (e) { return !!e.httpServerRequest && e.elapsedTime !== undefined; },
14
+ matcher: (e) => e.elapsedTime > options.timeAllowed,
15
+ message: () => `Slow HTTP server request (> ${options.timeAllowed * 1000}ms)`,
16
+ where: (e) => !!e.httpServerRequest && e.elapsedTime !== undefined,
18
17
  };
19
18
  }
20
19
  exports.default = {
@@ -25,7 +24,6 @@ exports.default = {
25
24
  impactDomain: 'Performance',
26
25
  description: (0, parseRuleDescription_1.default)('slowHttpServerRequest'),
27
26
  url: 'https://appland.com/docs/analysis/rules-reference.html#slow-http-server-request',
28
- Options: Options,
29
- build: build,
27
+ Options,
28
+ build,
30
29
  };
31
- //# sourceMappingURL=slowHttpServerRequest.js.map
@@ -3,28 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
7
- var Options = /** @class */ (function () {
8
- function Options() {
6
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
7
+ class Options {
8
+ constructor() {
9
9
  this.timeAllowed = 1;
10
10
  }
11
- return Options;
12
- }());
13
- function build(options) {
14
- if (options === void 0) { options = new Options(); }
11
+ }
12
+ function build(options = new Options()) {
15
13
  return {
16
- matcher: function (e) { return e.elapsedTime > options.timeAllowed; },
17
- where: function (e) { return !!e.sqlQuery && !!e.elapsedTime; },
14
+ matcher: (e) => e.elapsedTime > options.timeAllowed,
15
+ where: (e) => !!e.sqlQuery && !!e.elapsedTime,
18
16
  };
19
17
  }
20
18
  exports.default = {
21
19
  id: 'slow-query',
22
20
  title: 'Slow SQL query',
23
- Options: Options,
21
+ Options,
24
22
  impactDomain: 'Performance',
25
23
  enumerateScope: true,
26
24
  description: (0, parseRuleDescription_1.default)('slowQuery'),
27
25
  url: 'https://appland.com/docs/analysis/rules-reference.html#slow-query',
28
- build: build,
26
+ build,
29
27
  };
30
- //# sourceMappingURL=slowQuery.js.map