@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
@@ -2,192 +2,192 @@
2
2
  "$id": "https://appland.com/schemas/scanner/options.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "definitions": {
5
- "CircularDependency.Options": {
6
- "additionalProperties": false,
5
+ "TimeAllowed": {
6
+ "type": "object",
7
7
  "properties": {
8
- "depth": {
8
+ "timeAllowed": {
9
9
  "type": "number"
10
- },
11
- "ignoredPackages": {
12
- "items": {
13
- "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
14
- },
15
- "type": "array"
16
10
  }
17
11
  },
18
- "type": "object"
12
+ "additionalProperties": false
13
+ },
14
+ "WarningLimit": {
15
+ "type": "object",
16
+ "properties": {
17
+ "warningLimit": {
18
+ "type": "number"
19
+ }
20
+ },
21
+ "additionalProperties": false
19
22
  },
20
23
  "IllegalPackageDependency.Options": {
21
- "additionalProperties": false,
24
+ "type": "object",
22
25
  "properties": {
23
- "calleePackage": {
24
- "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
25
- },
26
26
  "callerPackages": {
27
+ "type": "array",
27
28
  "items": {
28
29
  "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
29
- },
30
- "type": "array"
30
+ }
31
+ },
32
+ "calleePackage": {
33
+ "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
31
34
  }
32
35
  },
33
36
  "required": [
34
37
  "callerPackages",
35
38
  "calleePackage"
36
39
  ],
37
- "type": "object"
40
+ "additionalProperties": false
41
+ },
42
+ "CircularDependency.Options": {
43
+ "type": "object",
44
+ "properties": {
45
+ "ignoredPackages": {
46
+ "type": "array",
47
+ "items": {
48
+ "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
49
+ }
50
+ },
51
+ "depth": {
52
+ "type": "number"
53
+ }
54
+ },
55
+ "additionalProperties": false
38
56
  },
39
57
  "IncompatibleHttpClientRequest.Options": {
40
- "additionalProperties": false,
58
+ "type": "object",
41
59
  "properties": {
42
60
  "schemata": {
61
+ "type": "object",
43
62
  "additionalProperties": {
44
63
  "type": "string"
45
- },
46
- "type": "object"
64
+ }
47
65
  }
48
66
  },
49
67
  "required": [
50
68
  "schemata"
51
69
  ],
52
- "type": "object"
70
+ "additionalProperties": false
53
71
  },
54
72
  "MissingAuthentication.Options": {
55
- "additionalProperties": false,
73
+ "type": "object",
56
74
  "properties": {
57
- "excludeContentTypes": {
75
+ "includeContentTypes": {
76
+ "type": "array",
58
77
  "items": {
59
78
  "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
60
- },
61
- "type": "array"
79
+ }
62
80
  },
63
- "includeContentTypes": {
81
+ "excludeContentTypes": {
82
+ "type": "array",
64
83
  "items": {
65
84
  "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
66
- },
67
- "type": "array"
85
+ }
68
86
  }
69
87
  },
70
- "type": "object"
88
+ "additionalProperties": false
71
89
  },
72
90
  "NPlusOneQuery.Options": {
73
- "additionalProperties": false,
91
+ "type": "object",
74
92
  "properties": {
75
- "errorLimit": {
93
+ "warningLimit": {
76
94
  "type": "number"
77
95
  },
78
- "warningLimit": {
96
+ "errorLimit": {
79
97
  "type": "number"
80
98
  }
81
99
  },
82
- "type": "object"
100
+ "additionalProperties": false
83
101
  },
84
102
  "QueryFromInvalidPackage.Options": {
85
- "additionalProperties": false,
103
+ "type": "object",
86
104
  "properties": {
87
105
  "allowedPackages": {
106
+ "type": "array",
88
107
  "items": {
89
108
  "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
90
- },
91
- "type": "array"
109
+ }
92
110
  },
93
111
  "allowedQueries": {
112
+ "type": "array",
94
113
  "items": {
95
114
  "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
96
- },
97
- "type": "array"
115
+ }
98
116
  }
99
117
  },
100
118
  "required": [
101
119
  "allowedPackages"
102
120
  ],
103
- "type": "object"
121
+ "additionalProperties": false
104
122
  },
105
123
  "QueryFromView.Options": {
106
- "additionalProperties": false,
124
+ "type": "object",
107
125
  "properties": {
108
126
  "forbiddenLabel": {
109
127
  "type": "string"
110
128
  }
111
129
  },
112
- "type": "object"
130
+ "additionalProperties": false
113
131
  },
114
132
  "RPCWithoutCircuitBreaker.Options": {
115
- "additionalProperties": false,
133
+ "type": "object",
116
134
  "properties": {
117
135
  "expectedLabel": {
118
136
  "type": "string"
119
137
  }
120
138
  },
121
- "type": "object"
139
+ "additionalProperties": false
122
140
  },
123
141
  "SlowFunctionCall.Options": {
124
- "additionalProperties": false,
142
+ "type": "object",
125
143
  "properties": {
144
+ "timeAllowed": {
145
+ "type": "number"
146
+ },
126
147
  "functions": {
148
+ "type": "array",
127
149
  "items": {
128
150
  "$ref": "https://appland.com/schemas/scanner/match-pattern-config.json"
129
- },
130
- "type": "array"
131
- },
132
- "timeAllowed": {
133
- "type": "number"
151
+ }
134
152
  }
135
153
  },
136
- "type": "object"
154
+ "additionalProperties": false
137
155
  },
138
156
  "SlowHTTPServerRequest.Options": {
157
+ "type": "object",
139
158
  "additionalProperties": false,
140
159
  "properties": {
141
160
  "timeAllowed": {
142
161
  "type": "number"
143
162
  }
144
- },
145
- "type": "object"
163
+ }
146
164
  },
147
165
  "SlowQuery.Options": {
166
+ "type": "object",
148
167
  "additionalProperties": false,
149
168
  "properties": {
150
169
  "timeAllowed": {
151
170
  "type": "number"
152
171
  }
153
- },
154
- "type": "object"
155
- },
156
- "TimeAllowed": {
157
- "additionalProperties": false,
158
- "properties": {
159
- "timeAllowed": {
160
- "type": "number"
161
- }
162
- },
163
- "type": "object"
172
+ }
164
173
  },
165
174
  "TooManyJoins.Options": {
175
+ "type": "object",
166
176
  "additionalProperties": false,
167
177
  "properties": {
168
178
  "warningLimit": {
169
179
  "type": "number"
170
180
  }
171
- },
172
- "type": "object"
181
+ }
173
182
  },
174
183
  "TooManyUpdates.Options": {
184
+ "type": "object",
175
185
  "additionalProperties": false,
176
186
  "properties": {
177
187
  "warningLimit": {
178
188
  "type": "number"
179
189
  }
180
- },
181
- "type": "object"
182
- },
183
- "WarningLimit": {
184
- "additionalProperties": false,
185
- "properties": {
186
- "warningLimit": {
187
- "type": "number"
188
- }
189
- },
190
- "type": "object"
190
+ }
191
191
  }
192
192
  }
193
193
  }
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=checkConfig.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=configuration.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=matchEventConfig.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=matchPatternConfig.js.map
@@ -1,72 +1,9 @@
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 __read = (this && this.__read) || function (o, n) {
30
- var m = typeof Symbol === "function" && o[Symbol.iterator];
31
- if (!m) return o;
32
- var i = m.call(o), r, ar = [], e;
33
- try {
34
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
35
- }
36
- catch (error) { e = { error: error }; }
37
- finally {
38
- try {
39
- if (r && !r.done && (m = i["return"])) m.call(i);
40
- }
41
- finally { if (e) throw e.error; }
42
- }
43
- return ar;
44
- };
45
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
46
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
47
- if (ar || !(i in from)) {
48
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
49
- ar[i] = from[i];
50
- }
51
- }
52
- return to.concat(ar || Array.prototype.slice.call(from));
53
- };
54
- var __values = (this && this.__values) || function(o) {
55
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56
- if (m) return m.call(o);
57
- if (o && typeof o.length === "number") return {
58
- next: function () {
59
- if (o && i >= o.length) o = void 0;
60
- return { value: o && o[i++], done: !o };
61
- }
62
- };
63
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
64
- };
65
2
  Object.defineProperty(exports, "__esModule", { value: true });
66
3
  exports.countJoins = exports.sqlStrings = exports.isSelect = exports.getSqlLabelFromString = exports.getHttpLabel = exports.capitalizeString = void 0;
67
- var models_1 = require("@appland/models");
68
- var visit_1 = require("./visit");
69
- var url_1 = require("url");
4
+ const models_1 = require("@appland/models");
5
+ const visit_1 = require("./visit");
6
+ const url_1 = require("url");
70
7
  function capitalizeString(str) {
71
8
  if (typeof str !== 'string') {
72
9
  return '';
@@ -78,13 +15,13 @@ function getHttpLabel(event) {
78
15
  if (!event.httpServerRequest) {
79
16
  return;
80
17
  }
81
- var requestMethod = event.httpServerRequest.request_method;
82
- var pathInfo = event.httpServerRequest.path_info;
83
- var label;
18
+ const requestMethod = event.httpServerRequest.request_method;
19
+ const pathInfo = event.httpServerRequest.path_info;
20
+ let label;
84
21
  try {
85
22
  // the url is fake, we only care about the path info anyway
86
- var url = new url_1.URL(pathInfo, 'http://hostname');
87
- label = "".concat(requestMethod, " ").concat(url.pathname);
23
+ const url = new url_1.URL(pathInfo, 'http://hostname');
24
+ label = `${requestMethod} ${url.pathname}`;
88
25
  }
89
26
  catch (ex) {
90
27
  label = 'HTTP Request';
@@ -92,7 +29,7 @@ function getHttpLabel(event) {
92
29
  return label;
93
30
  }
94
31
  exports.getHttpLabel = getHttpLabel;
95
- var sqlLabels = new Set([
32
+ const sqlLabels = new Set([
96
33
  'insert',
97
34
  'update',
98
35
  'select',
@@ -124,7 +61,7 @@ var sqlLabels = new Set([
124
61
  'xa',
125
62
  ]);
126
63
  function getSqlLabelFromString(sqlString) {
127
- var sqlChars = __spreadArray([], __read(sqlString.trimLeft()), false);
64
+ const sqlChars = [...sqlString.trimLeft()];
128
65
  if (sqlChars.length > 0 && sqlChars[0] === '(') {
129
66
  // if the query is wrapped in parenthesis, drop the opening parenthesis
130
67
  // it doesn't matter if we leave a hanging closing parenthesis.
@@ -132,9 +69,9 @@ function getSqlLabelFromString(sqlString) {
132
69
  sqlChars.shift();
133
70
  }
134
71
  // drop sub-queries and parenthesized expressions
135
- var depth = 0;
136
- var topLevelSql = sqlChars
137
- .reduce(function (arr, c) {
72
+ let depth = 0;
73
+ const topLevelSql = sqlChars
74
+ .reduce((arr, c) => {
138
75
  if (c === '(') {
139
76
  depth += 1;
140
77
  }
@@ -147,7 +84,7 @@ function getSqlLabelFromString(sqlString) {
147
84
  return arr;
148
85
  }, [])
149
86
  .join('');
150
- var queryType;
87
+ let queryType;
151
88
  if (topLevelSql.search(/\s/) === -1) {
152
89
  // There's only a single token
153
90
  // e.g. BEGIN, COMMIT, CHECKPOINT
@@ -161,7 +98,7 @@ function getSqlLabelFromString(sqlString) {
161
98
  .replace(/[^\w]+/g, ' ')
162
99
  .toLowerCase()
163
100
  .split(' ')
164
- .find(function (t) { return sqlLabels.has(t); }) || 'unknown';
101
+ .find((t) => sqlLabels.has(t)) || 'unknown';
165
102
  }
166
103
  return ['SQL', capitalizeString(queryType) || null].join(' ');
167
104
  }
@@ -170,65 +107,35 @@ function isSelect(sql) {
170
107
  return getSqlLabelFromString(sql) === 'SQL Select';
171
108
  }
172
109
  exports.isSelect = isSelect;
173
- function sqlStrings(event, appMapIndex, filter) {
174
- var _a, _b, e, sql, e_1_1;
175
- var e_1, _c;
176
- if (filter === void 0) { filter = function () { return true; }; }
177
- return __generator(this, function (_d) {
178
- switch (_d.label) {
179
- case 0:
180
- _d.trys.push([0, 5, 6, 7]);
181
- _a = __values(new models_1.EventNavigator(event).descendants()), _b = _a.next();
182
- _d.label = 1;
183
- case 1:
184
- if (!!_b.done) return [3 /*break*/, 4];
185
- e = _b.value;
186
- if (!e.event.sql) {
187
- return [3 /*break*/, 3];
188
- }
189
- if (!filter(e.event, appMapIndex)) {
190
- return [3 /*break*/, 3];
191
- }
192
- if (!isSelect(e.event.sqlQuery)) {
193
- return [3 /*break*/, 3];
194
- }
195
- if (!filter(event, appMapIndex)) {
196
- return [3 /*break*/, 3];
197
- }
198
- sql = appMapIndex.sqlNormalized(e.event);
199
- return [4 /*yield*/, { event: e.event, sql: sql }];
200
- case 2:
201
- _d.sent();
202
- _d.label = 3;
203
- case 3:
204
- _b = _a.next();
205
- return [3 /*break*/, 1];
206
- case 4: return [3 /*break*/, 7];
207
- case 5:
208
- e_1_1 = _d.sent();
209
- e_1 = { error: e_1_1 };
210
- return [3 /*break*/, 7];
211
- case 6:
212
- try {
213
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
214
- }
215
- finally { if (e_1) throw e_1.error; }
216
- return [7 /*endfinally*/];
217
- case 7: return [2 /*return*/];
110
+ function* sqlStrings(event, appMapIndex, filter = () => true) {
111
+ for (const e of new models_1.EventNavigator(event).descendants()) {
112
+ if (!e.event.sql) {
113
+ continue;
218
114
  }
219
- });
115
+ if (!filter(e.event, appMapIndex)) {
116
+ continue;
117
+ }
118
+ if (!isSelect(e.event.sqlQuery)) {
119
+ continue;
120
+ }
121
+ if (!filter(event, appMapIndex)) {
122
+ continue;
123
+ }
124
+ const sql = appMapIndex.sqlNormalized(e.event);
125
+ yield { event: e.event, sql };
126
+ }
220
127
  }
221
128
  exports.sqlStrings = sqlStrings;
222
129
  function countJoins(ast) {
223
130
  if (!ast)
224
131
  return 0;
225
- var joins = 0;
132
+ let joins = 0;
226
133
  (0, visit_1.visit)(ast, {
227
- 'map.join': function (node) {
228
- joins += node.map.length;
134
+ 'map.join': (node) => {
135
+ var _a;
136
+ joins += ((_a = node.map) !== null && _a !== void 0 ? _a : []).length;
229
137
  },
230
138
  });
231
139
  return joins;
232
140
  }
233
141
  exports.countJoins = countJoins;
234
- //# sourceMappingURL=index.js.map
@@ -1,82 +1,34 @@
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
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
2
  Object.defineProperty(exports, "__esModule", { value: true });
30
3
  exports.visit = void 0;
31
4
  function visit(node, callbacks) {
32
5
  if (node === null)
33
6
  return;
34
- var type = node.type, variant = node.variant;
35
- var key = [type, variant].filter(Boolean).join('.');
36
- if (callbacks !== undefined && key in callbacks)
37
- callbacks[key](node, callbacks);
7
+ const { type, variant } = node;
8
+ const key = [type, variant].filter(Boolean).join('.');
9
+ if (key in callbacks) {
10
+ const callback = callbacks[key];
11
+ callback(node);
12
+ }
38
13
  visitNode(node, callbacks);
39
14
  }
40
15
  exports.visit = visit;
41
16
  function visitNode(node, callbacks) {
42
- var e_1, _a, e_2, _b;
43
- try {
44
- for (var _c = __values(Object.entries(node)), _d = _c.next(); !_d.done; _d = _c.next()) {
45
- var _e = __read(_d.value, 2), key = _e[0], property = _e[1];
46
- if (['type', 'variant', 'name', 'value'].includes(key))
47
- continue;
48
- if (Array.isArray(property)) {
49
- try {
50
- for (var property_1 = (e_2 = void 0, __values(property)), property_1_1 = property_1.next(); !property_1_1.done; property_1_1 = property_1.next()) {
51
- var subNode = property_1_1.value;
52
- visit(subNode, callbacks);
53
- }
54
- }
55
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
56
- finally {
57
- try {
58
- if (property_1_1 && !property_1_1.done && (_b = property_1.return)) _b.call(property_1);
59
- }
60
- finally { if (e_2) throw e_2.error; }
61
- }
62
- }
63
- else if (typeof property === 'object') {
64
- visit(property, callbacks);
65
- }
66
- else if (typeof property === 'string' || typeof property === 'boolean') {
67
- // pass
68
- }
69
- else {
70
- console.warn("Unrecognized subexpression: ".concat(typeof property, " ").concat(property));
71
- }
17
+ for (const [key, property] of Object.entries(node)) {
18
+ if (['type', 'variant', 'name', 'value'].includes(key))
19
+ continue;
20
+ if (Array.isArray(property)) {
21
+ for (const subNode of property)
22
+ visit(subNode, callbacks);
72
23
  }
73
- }
74
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
75
- finally {
76
- try {
77
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
24
+ else if (typeof property === 'object') {
25
+ visit(property, callbacks);
26
+ }
27
+ else if (typeof property === 'string' || typeof property === 'boolean') {
28
+ // pass
29
+ }
30
+ else {
31
+ console.warn(`Unrecognized subexpression: ${typeof property} ${property}`);
78
32
  }
79
- finally { if (e_1) throw e_1.error; }
80
33
  }
81
34
  }
82
- //# sourceMappingURL=visit.js.map
package/built/errors.js CHANGED
@@ -1,35 +1,9 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.AbortError = exports.ValidationError = void 0;
19
- var ValidationError = /** @class */ (function (_super) {
20
- __extends(ValidationError, _super);
21
- function ValidationError() {
22
- return _super !== null && _super.apply(this, arguments) || this;
23
- }
24
- return ValidationError;
25
- }(Error));
4
+ class ValidationError extends Error {
5
+ }
26
6
  exports.ValidationError = ValidationError;
27
- var AbortError = /** @class */ (function (_super) {
28
- __extends(AbortError, _super);
29
- function AbortError() {
30
- return _super !== null && _super.apply(this, arguments) || this;
31
- }
32
- return AbortError;
33
- }(Error));
7
+ class AbortError extends Error {
8
+ }
34
9
  exports.AbortError = AbortError;
35
- //# sourceMappingURL=errors.js.map