@appland/scanner 1.54.1 → 1.57.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 +31 -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 +18 -20
  13. package/built/check.js +16 -18
  14. package/built/checkInstance.js +26 -48
  15. package/built/cli/ci/command.js +61 -147
  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 +58 -233
  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 +84 -0
  30. package/built/cli/scan.js +39 -132
  31. package/built/cli/scanArgs.js +2 -4
  32. package/built/cli/scanOptions.js +0 -1
  33. package/built/cli/updateCommitStatus.js +10 -47
  34. package/built/cli/upload/command.js +21 -65
  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 +148 -227
  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 +33 -127
  47. package/built/database/visit.js +16 -66
  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 +18 -45
  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 +48 -25
  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 -4
  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
@@ -8,85 +8,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
13
  };
41
14
  Object.defineProperty(exports, "__esModule", { value: true });
42
- var openapi_1 = require("../openapi");
43
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
44
- var Options = /** @class */ (function () {
45
- function Options() {
15
+ const openapi_1 = require("../openapi");
16
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
17
+ class Options {
18
+ constructor() {
46
19
  this.schemata = {};
47
20
  }
48
- return Options;
49
- }());
50
- var changeMessage = function (change) {
51
- return "HTTP client request is incompatible with OpenAPI schema. Change details: ".concat(change.action, " ").concat(change.sourceSpecEntityDetails
21
+ }
22
+ const changeMessage = (change) => {
23
+ return `HTTP client request is incompatible with OpenAPI schema. Change details: ${change.action} ${change.sourceSpecEntityDetails
52
24
  .concat(change.destinationSpecEntityDetails)
53
- .map(function (detail) { return detail.location; })
54
- .join(', '));
25
+ .map((detail) => detail.location)
26
+ .join(', ')}`;
55
27
  };
56
28
  function build(options) {
57
29
  function matcher(event) {
58
- return __awaiter(this, void 0, void 0, function () {
59
- var clientFragment, serverSchema, clientSchema, changes;
60
- return __generator(this, function (_a) {
61
- switch (_a.label) {
62
- case 0:
63
- clientFragment = (0, openapi_1.forClientRequest)(event);
64
- return [4 /*yield*/, (0, openapi_1.forURL)(event.httpClientRequest.url, options.schemata)];
65
- case 1:
66
- serverSchema = _a.sent();
67
- clientSchema = {
68
- openapi: '3.0.0',
69
- info: {
70
- title: 'Schema derived from client request',
71
- version: serverSchema.info.version, // Indicate that it *should* be compatible.
72
- },
73
- paths: clientFragment.paths,
74
- components: { securitySchemes: clientFragment.securitySchemes },
75
- };
76
- return [4 /*yield*/, (0, openapi_1.breakingChanges)(clientSchema, serverSchema)];
77
- case 2:
78
- changes = _a.sent();
79
- return [2 /*return*/, changes.map(function (change) { return ({
80
- event: event,
81
- message: changeMessage(change),
82
- }); })];
83
- }
84
- });
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const clientFragment = (0, openapi_1.forClientRequest)(event);
32
+ const serverSchema = yield (0, openapi_1.forURL)(event.httpClientRequest.url, options.schemata);
33
+ const clientSchema = {
34
+ openapi: '3.0.0',
35
+ info: {
36
+ title: 'Schema derived from client request',
37
+ version: serverSchema.info.version, // Indicate that it *should* be compatible.
38
+ },
39
+ paths: clientFragment.paths,
40
+ components: { securitySchemes: clientFragment.securitySchemes },
41
+ };
42
+ const changes = yield (0, openapi_1.breakingChanges)(clientSchema, serverSchema);
43
+ return changes.map((change) => ({
44
+ event,
45
+ message: changeMessage(change),
46
+ }));
85
47
  });
86
48
  }
87
49
  return {
88
- matcher: matcher,
89
- where: function (e) { return !!e.httpClientRequest && !!e.httpClientRequest.url; },
50
+ matcher,
51
+ where: (e) => !!e.httpClientRequest && !!e.httpClientRequest.url,
90
52
  };
91
53
  }
92
54
  exports.default = {
@@ -98,7 +60,6 @@ exports.default = {
98
60
  impactDomain: 'Stability',
99
61
  description: (0, parseRuleDescription_1.default)('incompatibleHttpClientRequest'),
100
62
  url: 'https://appland.com/docs/analysis/rules-reference.html#incompatible-http-client-request',
101
- Options: Options,
102
- build: build,
63
+ Options,
64
+ build,
103
65
  };
104
- //# sourceMappingURL=incompatibleHttpClientRequest.js.map
@@ -3,17 +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 url_1 = require("url");
7
- var recordSecrets_1 = __importDefault(require("../analyzer/recordSecrets"));
8
- var secretsRegexes_1 = require("../analyzer/secretsRegexes");
9
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
10
- var BCRYPT_REGEXP = /^[$]2[abxy]?[$](?:0[4-9]|[12][0-9]|3[01])[$][./0-9a-zA-Z]{53}$/;
11
- var secrets = new Set();
6
+ const url_1 = require("url");
7
+ const recordSecrets_1 = __importDefault(require("../analyzer/recordSecrets"));
8
+ const secretsRegexes_1 = require("../analyzer/secretsRegexes");
9
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
10
+ const BCRYPT_REGEXP = /^[$]2[abxy]?[$](?:0[4-9]|[12][0-9]|3[01])[$][./0-9a-zA-Z]{53}$/;
11
+ const secrets = new Set();
12
12
  function stringEquals(e) {
13
13
  if (!e.parameters || !e.receiver || e.parameters.length !== 1) {
14
14
  return false;
15
15
  }
16
- var args = [e.receiver.value, e.parameters[0].value];
16
+ const args = [e.receiver.value, e.parameters[0].value];
17
17
  function isBcrypt(str) {
18
18
  return BCRYPT_REGEXP.test(str);
19
19
  }
@@ -36,12 +36,12 @@ function build() {
36
36
  return (e.isFunction && (e.codeObject.labels.has(StringEquals) || e.codeObject.labels.has(Secret)));
37
37
  }
38
38
  return {
39
- matcher: matcher,
40
- where: where,
39
+ matcher,
40
+ where,
41
41
  };
42
42
  }
43
- var Secret = 'secret';
44
- var StringEquals = 'string.equals';
43
+ const Secret = 'secret';
44
+ const StringEquals = 'string.equals';
45
45
  exports.default = {
46
46
  id: 'insecure-compare',
47
47
  title: 'Insecure comparison of secrets',
@@ -53,6 +53,5 @@ exports.default = {
53
53
  },
54
54
  description: (0, parseRuleDescription_1.default)('insecureCompare'),
55
55
  url: 'https://appland.com/docs/analysis/rules-reference.html#insecure-compare',
56
- build: build,
56
+ build,
57
57
  };
58
- //# sourceMappingURL=insecureCompare.js.map
@@ -1,65 +1,34 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
28
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
29
4
  };
30
5
  Object.defineProperty(exports, "__esModule", { value: true });
31
- var wellKnownLabels_1 = __importDefault(require("../wellKnownLabels"));
32
- var sqlTransactionScope_1 = require("../scope/sqlTransactionScope");
33
- var url_1 = require("url");
34
- var parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
6
+ const wellKnownLabels_1 = __importDefault(require("../wellKnownLabels"));
7
+ const sqlTransactionScope_1 = require("../scope/sqlTransactionScope");
8
+ const url_1 = require("url");
9
+ const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
35
10
  function build() {
36
11
  function matcher(event) {
37
12
  if (!(0, sqlTransactionScope_1.hasTransactionDetails)(event))
38
- throw new Error("expected event ".concat(event.id, " to be a transaction"));
13
+ throw new Error(`expected event ${event.id} to be a transaction`);
39
14
  if (event.transaction.status === 'commit')
40
15
  return;
41
- var creationEvents = event.transaction.events.filter(function (_a) {
42
- var labels = _a.labels;
43
- return labels.has(wellKnownLabels_1.default.JobCreate);
44
- });
45
- var cancellationEvents = event.transaction.events.filter(function (_a) {
46
- var labels = _a.labels;
47
- return labels.has(wellKnownLabels_1.default.JobCancel);
48
- });
49
- var missing = creationEvents.length - cancellationEvents.length;
16
+ const creationEvents = event.transaction.events.filter(({ labels }) => labels.has(wellKnownLabels_1.default.JobCreate));
17
+ const cancellationEvents = event.transaction.events.filter(({ labels }) => labels.has(wellKnownLabels_1.default.JobCancel));
18
+ const missing = creationEvents.length - cancellationEvents.length;
50
19
  if (missing === 0)
51
20
  return;
52
- var result = {
21
+ const result = {
53
22
  event: event,
54
- message: "".concat(missing, " jobs created but not cancelled in this rolled back transaction"),
23
+ message: `${missing} jobs created but not cancelled in this rolled back transaction`,
55
24
  // if there's a mismatch and there are cancellations we can't tell
56
25
  // for sure which creations they match, so return everything
57
- relatedEvents: __spreadArray(__spreadArray([], __read(creationEvents), false), __read(cancellationEvents), false),
26
+ relatedEvents: [...creationEvents, ...cancellationEvents],
58
27
  };
59
28
  return [result];
60
29
  }
61
30
  return {
62
- matcher: matcher,
31
+ matcher,
63
32
  };
64
33
  }
65
34
  exports.default = {
@@ -74,6 +43,5 @@ exports.default = {
74
43
  },
75
44
  description: (0, parseRuleDescription_1.default)('jobNotCancelled'),
76
45
  url: 'https://appland.com/docs/analysis/rules-reference.html#job-not-cancelled',
77
- build: build,
46
+ build,
78
47
  };
79
- //# sourceMappingURL=jobNotCancelled.js.map
@@ -2,10 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // Builds a function that returns true if the provided event argument has the specified
4
4
  // objectId as the receiver or as a parameter value.
5
- exports.default = (function (objectId) {
6
- return function (event) {
7
- return (!!event.receiver && event.receiver.object_id === objectId) ||
8
- (!!event.parameters && event.parameters.some(function (param) { return param.object_id === objectId; }));
9
- };
10
- });
11
- //# sourceMappingURL=hasParameterOrReceiver.js.map
5
+ exports.default = (objectId) => {
6
+ return (event) => (!!event.receiver && event.receiver.object_id === objectId) ||
7
+ (!!event.parameters && event.parameters.some((param) => param.object_id === objectId));
8
+ };
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildFilters = exports.buildFilter = void 0;
4
- var matchPattern_1 = require("./matchPattern");
4
+ const matchPattern_1 = require("./matchPattern");
5
5
  function buildFilter(pattern) {
6
- var testFn = (0, matchPattern_1.buildFilter)(pattern.test);
7
- var propertyFn = {
8
- id: function (e) { return e.codeObject.id; },
9
- type: function (e) { return e.codeObject.type; },
10
- fqid: function (e) { return e.codeObject.fqid; },
11
- query: function (e, appMapIndex) { return (e.sql ? appMapIndex.sqlNormalized(e) : null); },
12
- route: function (e) { return e.route; },
6
+ const testFn = (0, matchPattern_1.buildFilter)(pattern.test);
7
+ const propertyFn = {
8
+ id: (e) => e.codeObject.id,
9
+ type: (e) => e.codeObject.type,
10
+ fqid: (e) => e.codeObject.fqid,
11
+ query: (e, appMapIndex) => (e.sql ? appMapIndex.sqlNormalized(e) : null),
12
+ route: (e) => e.route,
13
13
  };
14
- return function (event, appMapIndex) {
15
- var fn = propertyFn[pattern.property];
14
+ return (event, appMapIndex) => {
15
+ const fn = propertyFn[pattern.property];
16
16
  if (!fn) {
17
- throw new Error("Unrecognized Event filter property: ".concat(pattern.property));
17
+ throw new Error(`Unrecognized Event filter property: ${pattern.property}`);
18
18
  }
19
- var value = fn(event, appMapIndex);
19
+ const value = fn(event, appMapIndex);
20
20
  if (!value) {
21
21
  return false;
22
22
  }
@@ -28,4 +28,3 @@ function buildFilters(patterns) {
28
28
  return patterns.map(buildFilter);
29
29
  }
30
30
  exports.buildFilters = buildFilters;
31
- //# sourceMappingURL=matchEvent.js.map
@@ -6,18 +6,18 @@ function buildFilter(pattern) {
6
6
  return pattern.ignoreCase ? value.toLocaleLowerCase() : value;
7
7
  }
8
8
  if (pattern.equal) {
9
- var testStr_1 = respectIgnoreCaseFlag(pattern.equal);
10
- return function (value) { return respectIgnoreCaseFlag(value) === testStr_1; };
9
+ const testStr = respectIgnoreCaseFlag(pattern.equal);
10
+ return (value) => respectIgnoreCaseFlag(value) === testStr;
11
11
  }
12
12
  else if (pattern.include) {
13
- var testStr_2 = respectIgnoreCaseFlag(pattern.include);
14
- return function (value) { return respectIgnoreCaseFlag(value).includes(testStr_2); };
13
+ const testStr = respectIgnoreCaseFlag(pattern.include);
14
+ return (value) => respectIgnoreCaseFlag(value).includes(testStr);
15
15
  }
16
16
  else {
17
- var regexp_1 = pattern.match instanceof RegExp
17
+ const regexp = pattern.match instanceof RegExp
18
18
  ? pattern.match
19
19
  : new RegExp(pattern.match, pattern.ignoreCase ? 'i' : undefined);
20
- return function (value) { return regexp_1.test(value); };
20
+ return (value) => regexp.test(value);
21
21
  }
22
22
  }
23
23
  exports.buildFilter = buildFilter;
@@ -25,4 +25,3 @@ function buildFilters(patterns) {
25
25
  return patterns.map(buildFilter);
26
26
  }
27
27
  exports.buildFilters = buildFilters;
28
- //# sourceMappingURL=matchPattern.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=metadata.js.map
@@ -3,12 +3,12 @@ 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 fs_1 = __importDefault(require("fs"));
7
- var path_1 = require("path");
8
- var util_1 = require("./util");
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = require("path");
8
+ const util_1 = require("./util");
9
9
  function parseRuleDescription(id) {
10
- var content = fs_1.default.readFileSync((0, path_1.join)(__dirname, "../../../doc/rules/".concat((0, util_1.dasherize)(id), ".md")), 'utf-8');
11
- var propertiesContent = content.match(/---\n((?:.*\n)+)---\n((?:.*\n)+?)##?#?/);
10
+ const content = fs_1.default.readFileSync((0, path_1.join)(__dirname, `../../../doc/rules/${(0, util_1.dasherize)(id)}.md`), 'utf-8');
11
+ const propertiesContent = content.match(/---\n((?:.*\n)+)---\n((?:.*\n)+?)##?#?/);
12
12
  if (!propertiesContent) {
13
13
  // This is probably a new doc that doesn't have front matter yet.
14
14
  // It's all description.
@@ -17,4 +17,3 @@ function parseRuleDescription(id) {
17
17
  return propertiesContent[2].replace(/\n/g, ' ').trim();
18
18
  }
19
19
  exports.default = parseRuleDescription;
20
- //# sourceMappingURL=parseRuleDescription.js.map
@@ -1,80 +1,12 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
41
- var models_1 = require("@appland/models");
42
- function precedingEvents(rootEvent, target) {
43
- var _a, _b, event, e_1_1;
44
- var e_1, _c;
45
- return __generator(this, function (_d) {
46
- switch (_d.label) {
47
- case 0:
48
- _d.trys.push([0, 5, 6, 7]);
49
- _a = __values(new models_1.EventNavigator(rootEvent).descendants()), _b = _a.next();
50
- _d.label = 1;
51
- case 1:
52
- if (!!_b.done) return [3 /*break*/, 4];
53
- event = _b.value;
54
- if (event.event === target) {
55
- return [3 /*break*/, 4];
56
- }
57
- return [4 /*yield*/, event];
58
- case 2:
59
- _d.sent();
60
- _d.label = 3;
61
- case 3:
62
- _b = _a.next();
63
- return [3 /*break*/, 1];
64
- case 4: return [3 /*break*/, 7];
65
- case 5:
66
- e_1_1 = _d.sent();
67
- e_1 = { error: e_1_1 };
68
- return [3 /*break*/, 7];
69
- case 6:
70
- try {
71
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
72
- }
73
- finally { if (e_1) throw e_1.error; }
74
- return [7 /*endfinally*/];
75
- case 7: return [2 /*return*/];
3
+ const models_1 = require("@appland/models");
4
+ function* precedingEvents(rootEvent, target) {
5
+ for (const event of new models_1.EventNavigator(rootEvent).descendants()) {
6
+ if (event.event === target) {
7
+ break;
76
8
  }
77
- });
9
+ yield event;
10
+ }
78
11
  }
79
12
  exports.default = precedingEvents;
80
- //# sourceMappingURL=precedingEvents.js.map
@@ -1,40 +1,17 @@
1
1
  "use strict";
2
- var __values = (this && this.__values) || function(o) {
3
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
- if (m) return m.call(o);
5
- if (o && typeof o.length === "number") return {
6
- next: function () {
7
- if (o && i >= o.length) o = void 0;
8
- return { value: o && o[i++], done: !o };
9
- }
10
- };
11
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.rpcWithoutProtection = void 0;
15
4
  function rpcWithoutProtection(candidateGenerator, options) {
16
5
  return {
17
- matcher: function (httpClientRequest) {
18
- var e_1, _a;
19
- try {
20
- for (var _b = __values(candidateGenerator(httpClientRequest)), _c = _b.next(); !_c.done; _c = _b.next()) {
21
- var candidate = _c.value;
22
- if (candidate.codeObject.labels.has(options.expectedLabel)) {
23
- return false;
24
- }
25
- }
26
- }
27
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
28
- finally {
29
- try {
30
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
6
+ matcher: (httpClientRequest) => {
7
+ for (const candidate of candidateGenerator(httpClientRequest)) {
8
+ if (candidate.codeObject.labels.has(options.expectedLabel)) {
9
+ return false;
31
10
  }
32
- finally { if (e_1) throw e_1.error; }
33
11
  }
34
12
  return true;
35
13
  },
36
- where: function (e) { return !!e.httpClientRequest; },
14
+ where: (e) => !!e.httpClientRequest,
37
15
  };
38
16
  }
39
17
  exports.rpcWithoutProtection = rpcWithoutProtection;
40
- //# sourceMappingURL=rpcWithoutProtection.js.map
@@ -7,4 +7,3 @@ function sanitizesData(event, objectId, label) {
7
7
  event.returnValue.object_id === objectId);
8
8
  }
9
9
  exports.default = sanitizesData;
10
- //# sourceMappingURL=sanitizesData.js.map
@@ -1,10 +1,34 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verbose = exports.toRegExpArray = exports.responseContentType = exports.toRegExp = exports.providesAuthentication = exports.pluralize = exports.dasherize = exports.camelize = exports.parseValue = exports.isRoot = exports.ideLink = exports.isTruthy = exports.isFalsey = exports.emptyValue = exports.capitalize = exports.appMapDir = void 0;
4
- var path_1 = require("path");
5
- var isVerbose = false;
6
- function verbose(v) {
7
- if (v === void 0) { v = null; }
12
+ exports.verbose = exports.toRegExpArray = exports.responseContentType = exports.toRegExp = exports.providesAuthentication = exports.pluralize = exports.dasherize = exports.camelize = exports.parseValue = exports.isRoot = exports.ideLink = exports.isTruthy = exports.isFalsey = exports.emptyValue = exports.capitalize = exports.appMapDir = exports.appmapDirFromConfig = void 0;
13
+ const fs_1 = require("fs");
14
+ const promises_1 = require("fs/promises");
15
+ const js_yaml_1 = require("js-yaml");
16
+ const path_1 = require("path");
17
+ const util_1 = require("util");
18
+ function appmapDirFromConfig() {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const appMapConfigExists = yield (0, util_1.promisify)(fs_1.exists)('appmap.yml');
21
+ if (appMapConfigExists) {
22
+ const appMapConfigData = (0, js_yaml_1.load)((yield (0, promises_1.readFile)('appmap.yml')).toString());
23
+ if (appMapConfigData && typeof appMapConfigData === 'object') {
24
+ return appMapConfigData['appmap_dir'];
25
+ }
26
+ }
27
+ });
28
+ }
29
+ exports.appmapDirFromConfig = appmapDirFromConfig;
30
+ let isVerbose = false;
31
+ function verbose(v = null) {
8
32
  if (v === true || v === false) {
9
33
  isVerbose = v;
10
34
  }
@@ -64,55 +88,55 @@ function parseValue(valueObj) {
64
88
  return valueObj.value
65
89
  .slice(1, valueObj.value.length - 1)
66
90
  .split(',')
67
- .map(function (v) { return v.trim(); });
91
+ .map((v) => v.trim());
68
92
  }
69
93
  return [valueObj.value];
70
94
  }
71
95
  exports.parseValue = parseValue;
72
- var isTruthy = function (valueObj) { return !isFalsey(valueObj); };
96
+ const isTruthy = (valueObj) => !isFalsey(valueObj);
73
97
  exports.isTruthy = isTruthy;
74
98
  function providesAuthentication(event, label) {
75
99
  return event.returnValue && event.labels.has(label) && isTruthy(event.returnValue);
76
100
  }
77
101
  exports.providesAuthentication = providesAuthentication;
78
102
  function ideLink(filePath, ide, eventId) {
79
- var OSC = '\u001B]';
80
- var BEL = '\u0007';
81
- var SEP = ';';
103
+ const OSC = '\u001B]';
104
+ const BEL = '\u0007';
105
+ const SEP = ';';
82
106
  // eslint-disable-next-line @typescript-eslint/no-var-requires
83
- var supportsHyperlinks = require('supports-hyperlinks');
107
+ const supportsHyperlinks = require('supports-hyperlinks');
84
108
  if (!supportsHyperlinks.stdout) {
85
109
  return filePath;
86
110
  }
87
- var path;
111
+ let path;
88
112
  if (!(0, path_1.isAbsolute)(filePath)) {
89
- path = "".concat(__dirname, "/../../../../../").concat(filePath);
113
+ path = `${__dirname}/../../../../../${filePath}`;
90
114
  }
91
115
  else {
92
116
  path = filePath;
93
117
  }
94
- var state = { currentView: 'viewFlow', selectedObject: "event:".concat(eventId) };
95
- var encodedState = encodeURIComponent(JSON.stringify(state));
96
- var link = ide == 'vscode'
97
- ? "vscode://appland.appmap/open?uri=".concat(path, "&state=").concat(encodedState)
98
- : "".concat(ide, "://open?file=").concat(path);
118
+ const state = { currentView: 'viewFlow', selectedObject: `event:${eventId}` };
119
+ const encodedState = encodeURIComponent(JSON.stringify(state));
120
+ const link = ide == 'vscode'
121
+ ? `vscode://appland.appmap/open?uri=${path}&state=${encodedState}`
122
+ : `${ide}://open?file=${path}`;
99
123
  return [OSC, '8', SEP, SEP, link, BEL, filePath, OSC, '8', SEP, SEP, BEL].join('');
100
124
  }
101
125
  exports.ideLink = ideLink;
102
- var toRegExp = function (value) {
126
+ const toRegExp = (value) => {
103
127
  return typeof value === 'string' ? new RegExp(value) : value;
104
128
  };
105
129
  exports.toRegExp = toRegExp;
106
- var toRegExpArray = function (value) {
130
+ const toRegExpArray = (value) => {
107
131
  return value.map(toRegExp);
108
132
  };
109
133
  exports.toRegExpArray = toRegExpArray;
110
- var RootLabels = ['command', 'job'];
111
- var isRoot = function (event) {
134
+ const RootLabels = ['command', 'job'];
135
+ const isRoot = (event) => {
112
136
  if (!event) {
113
137
  return true;
114
138
  }
115
- return (!!event.httpServerRequest || RootLabels.some(function (label) { return event.codeObject.labels.has(label); }));
139
+ return (!!event.httpServerRequest || RootLabels.some((label) => event.codeObject.labels.has(label)));
116
140
  };
117
141
  exports.isRoot = isRoot;
118
142
  // Attribution: https://github.com/shahata/dasherize
@@ -127,7 +151,7 @@ function dasherize(str) {
127
151
  exports.dasherize = dasherize;
128
152
  // Literally StackOverflow
129
153
  function camelize(text) {
130
- text = text.replace(/[-_\s.]+(.)?/g, function (_, c) { return (c ? c.toUpperCase() : ''); });
154
+ text = text.replace(/[-_\s.]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''));
131
155
  return text.slice(0, 1).toLowerCase() + text.slice(1);
132
156
  }
133
157
  exports.camelize = camelize;
@@ -135,4 +159,3 @@ function pluralize(word, count) {
135
159
  return count === 1 ? word : [word, 's'].join('');
136
160
  }
137
161
  exports.pluralize = pluralize;
138
- //# sourceMappingURL=util.js.map