@appland/scanner 1.33.1

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 (196) hide show
  1. package/LICENSE.txt +25 -0
  2. package/README.md +122 -0
  3. package/built/algorithms/dataStructures/graph/Graph.js +155 -0
  4. package/built/algorithms/dataStructures/graph/Graph.js.map +1 -0
  5. package/built/algorithms/dataStructures/graph/GraphEdge.js +27 -0
  6. package/built/algorithms/dataStructures/graph/GraphEdge.js.map +1 -0
  7. package/built/algorithms/dataStructures/graph/GraphVertex.js +79 -0
  8. package/built/algorithms/dataStructures/graph/GraphVertex.js.map +1 -0
  9. package/built/algorithms/dataStructures/linked-list/LinkedList.js +134 -0
  10. package/built/algorithms/dataStructures/linked-list/LinkedList.js.map +1 -0
  11. package/built/algorithms/dataStructures/linked-list/LinkedListNode.js +16 -0
  12. package/built/algorithms/dataStructures/linked-list/LinkedListNode.js.map +1 -0
  13. package/built/algorithms/graph/depth-first-search/index.js +49 -0
  14. package/built/algorithms/graph/depth-first-search/index.js.map +1 -0
  15. package/built/algorithms/graph/detect-cycle/index.js +77 -0
  16. package/built/algorithms/graph/detect-cycle/index.js.map +1 -0
  17. package/built/algorithms/utils/Comparator.js +35 -0
  18. package/built/algorithms/utils/Comparator.js.map +1 -0
  19. package/built/analyzer/recordSecrets.js +17 -0
  20. package/built/analyzer/recordSecrets.js.map +1 -0
  21. package/built/analyzer/secretsRegexes.js +13 -0
  22. package/built/analyzer/secretsRegexes.js.map +1 -0
  23. package/built/analyzer/secretsRegexesData.json +51 -0
  24. package/built/check.js +47 -0
  25. package/built/check.js.map +1 -0
  26. package/built/checkInstance.js +69 -0
  27. package/built/checkInstance.js.map +1 -0
  28. package/built/cli/ci/command.js +183 -0
  29. package/built/cli/ci/command.js.map +1 -0
  30. package/built/cli/ci/options.js +3 -0
  31. package/built/cli/ci/options.js.map +1 -0
  32. package/built/cli/exitCode.js +11 -0
  33. package/built/cli/exitCode.js.map +1 -0
  34. package/built/cli/progressReporter.js +16 -0
  35. package/built/cli/progressReporter.js.map +1 -0
  36. package/built/cli/resolveAppId.js +83 -0
  37. package/built/cli/resolveAppId.js.map +1 -0
  38. package/built/cli/scan/command.js +174 -0
  39. package/built/cli/scan/command.js.map +1 -0
  40. package/built/cli/scan/options.js +3 -0
  41. package/built/cli/scan/options.js.map +1 -0
  42. package/built/cli/scan/scanner.js +154 -0
  43. package/built/cli/scan/scanner.js.map +1 -0
  44. package/built/cli/scan.js +103 -0
  45. package/built/cli/scan.js.map +1 -0
  46. package/built/cli/scanArgs.js +26 -0
  47. package/built/cli/scanArgs.js.map +1 -0
  48. package/built/cli/scanOptions.js +3 -0
  49. package/built/cli/scanOptions.js.map +1 -0
  50. package/built/cli/upload/command.js +95 -0
  51. package/built/cli/upload/command.js.map +1 -0
  52. package/built/cli/upload/options.js +3 -0
  53. package/built/cli/upload/options.js.map +1 -0
  54. package/built/cli/validateFile.js +66 -0
  55. package/built/cli/validateFile.js.map +1 -0
  56. package/built/cli.js +32 -0
  57. package/built/cli.js.map +1 -0
  58. package/built/configuration/configurationProvider.js +169 -0
  59. package/built/configuration/configurationProvider.js.map +1 -0
  60. package/built/configuration/schema/match-pattern-config.json +32 -0
  61. package/built/configuration/schema/options.json +193 -0
  62. package/built/configuration/types/checkConfig.js +3 -0
  63. package/built/configuration/types/checkConfig.js.map +1 -0
  64. package/built/configuration/types/configuration.js +3 -0
  65. package/built/configuration/types/configuration.js.map +1 -0
  66. package/built/configuration/types/matchEventConfig.js +3 -0
  67. package/built/configuration/types/matchEventConfig.js.map +1 -0
  68. package/built/configuration/types/matchPatternConfig.js +3 -0
  69. package/built/configuration/types/matchPatternConfig.js.map +1 -0
  70. package/built/database/index.js +259 -0
  71. package/built/database/index.js.map +1 -0
  72. package/built/database/visit.js +80 -0
  73. package/built/database/visit.js.map +1 -0
  74. package/built/errors.js +35 -0
  75. package/built/errors.js.map +1 -0
  76. package/built/findings.js +15 -0
  77. package/built/findings.js.map +1 -0
  78. package/built/integration/appland/fetchStatus.js +51 -0
  79. package/built/integration/appland/fetchStatus.js.map +1 -0
  80. package/built/integration/appland/upload.js +193 -0
  81. package/built/integration/appland/upload.js.map +1 -0
  82. package/built/integration/github/commitStatus.js +19 -0
  83. package/built/integration/github/commitStatus.js.map +1 -0
  84. package/built/integration/vars.js +68 -0
  85. package/built/integration/vars.js.map +1 -0
  86. package/built/openapi/index.js +100 -0
  87. package/built/openapi/index.js.map +1 -0
  88. package/built/openapi/method.js +120 -0
  89. package/built/openapi/method.js.map +1 -0
  90. package/built/openapi/model.js +49 -0
  91. package/built/openapi/model.js.map +1 -0
  92. package/built/openapi/path.js +36 -0
  93. package/built/openapi/path.js.map +1 -0
  94. package/built/openapi/provider.js +133 -0
  95. package/built/openapi/provider.js.map +1 -0
  96. package/built/openapi/response.js +59 -0
  97. package/built/openapi/response.js.map +1 -0
  98. package/built/openapi/rpcRequest.js +130 -0
  99. package/built/openapi/rpcRequest.js.map +1 -0
  100. package/built/openapi/schema.js +42 -0
  101. package/built/openapi/schema.js.map +1 -0
  102. package/built/openapi/securitySchemes.js +32 -0
  103. package/built/openapi/securitySchemes.js.map +1 -0
  104. package/built/openapi/statusCodes.js +68 -0
  105. package/built/openapi/statusCodes.js.map +1 -0
  106. package/built/openapi/util.js +91 -0
  107. package/built/openapi/util.js.map +1 -0
  108. package/built/report/appMapMetadata.js +2 -0
  109. package/built/report/appMapMetadata.js.map +1 -0
  110. package/built/report/findingSummary.js +3 -0
  111. package/built/report/findingSummary.js.map +1 -0
  112. package/built/report/findingsReport.js +37 -0
  113. package/built/report/findingsReport.js.map +1 -0
  114. package/built/report/scanResults.js +103 -0
  115. package/built/report/scanResults.js.map +1 -0
  116. package/built/report/scanSummary.js +3 -0
  117. package/built/report/scanSummary.js.map +1 -0
  118. package/built/report/summaryReport.js +70 -0
  119. package/built/report/summaryReport.js.map +1 -0
  120. package/built/ruleChecker.js +260 -0
  121. package/built/ruleChecker.js.map +1 -0
  122. package/built/rules/authzBeforeAuthn.js +82 -0
  123. package/built/rules/authzBeforeAuthn.js.map +1 -0
  124. package/built/rules/circularDependency.js +227 -0
  125. package/built/rules/circularDependency.js.map +1 -0
  126. package/built/rules/http500.js +18 -0
  127. package/built/rules/http500.js.map +1 -0
  128. package/built/rules/illegalPackageDependency.js +38 -0
  129. package/built/rules/illegalPackageDependency.js.map +1 -0
  130. package/built/rules/incompatibleHttpClientRequest.js +96 -0
  131. package/built/rules/incompatibleHttpClientRequest.js.map +1 -0
  132. package/built/rules/insecureCompare.js +59 -0
  133. package/built/rules/insecureCompare.js.map +1 -0
  134. package/built/rules/jobNotCancelled.js +72 -0
  135. package/built/rules/jobNotCancelled.js.map +1 -0
  136. package/built/rules/lib/hasParameterOrReceiver.js +11 -0
  137. package/built/rules/lib/hasParameterOrReceiver.js.map +1 -0
  138. package/built/rules/lib/matchEvent.js +32 -0
  139. package/built/rules/lib/matchEvent.js.map +1 -0
  140. package/built/rules/lib/matchPattern.js +28 -0
  141. package/built/rules/lib/matchPattern.js.map +1 -0
  142. package/built/rules/lib/rpcWithoutProtection.js +40 -0
  143. package/built/rules/lib/rpcWithoutProtection.js.map +1 -0
  144. package/built/rules/missingAuthentication.js +65 -0
  145. package/built/rules/missingAuthentication.js.map +1 -0
  146. package/built/rules/missingContentType.js +27 -0
  147. package/built/rules/missingContentType.js.map +1 -0
  148. package/built/rules/nPlusOneQuery.js +84 -0
  149. package/built/rules/nPlusOneQuery.js.map +1 -0
  150. package/built/rules/queryFromInvalidPackage.js +37 -0
  151. package/built/rules/queryFromInvalidPackage.js.map +1 -0
  152. package/built/rules/queryFromView.js +29 -0
  153. package/built/rules/queryFromView.js.map +1 -0
  154. package/built/rules/rpcWithoutCircuitBreaker.js +97 -0
  155. package/built/rules/rpcWithoutCircuitBreaker.js.map +1 -0
  156. package/built/rules/saveWithoutValidation.js +27 -0
  157. package/built/rules/saveWithoutValidation.js.map +1 -0
  158. package/built/rules/secretInLog.js +76 -0
  159. package/built/rules/secretInLog.js.map +1 -0
  160. package/built/rules/slowFunctionCall.js +37 -0
  161. package/built/rules/slowFunctionCall.js.map +1 -0
  162. package/built/rules/slowHttpServerRequest.js +24 -0
  163. package/built/rules/slowHttpServerRequest.js.map +1 -0
  164. package/built/rules/slowQuery.js +23 -0
  165. package/built/rules/slowQuery.js.map +1 -0
  166. package/built/rules/tooManyJoins.js +77 -0
  167. package/built/rules/tooManyJoins.js.map +1 -0
  168. package/built/rules/tooManyUpdates.js +143 -0
  169. package/built/rules/tooManyUpdates.js.map +1 -0
  170. package/built/rules/unbatchedMaterializedQuery.js +65 -0
  171. package/built/rules/unbatchedMaterializedQuery.js.map +1 -0
  172. package/built/rules/updateInGetRequest.js +66 -0
  173. package/built/rules/updateInGetRequest.js.map +1 -0
  174. package/built/rules/util.js +102 -0
  175. package/built/rules/util.js.map +1 -0
  176. package/built/sampleConfig/bike_index.yml +10 -0
  177. package/built/sampleConfig/default.yml +19 -0
  178. package/built/sampleConfig/railsSampleApp6thEd.yml +29 -0
  179. package/built/sampleConfig/solidus.yml +31 -0
  180. package/built/scope/commandScope.js +156 -0
  181. package/built/scope/commandScope.js.map +1 -0
  182. package/built/scope/httpClientRequestScope.js +105 -0
  183. package/built/scope/httpClientRequestScope.js.map +1 -0
  184. package/built/scope/httpServerRequestScope.js +105 -0
  185. package/built/scope/httpServerRequestScope.js.map +1 -0
  186. package/built/scope/rootScope.js +105 -0
  187. package/built/scope/rootScope.js.map +1 -0
  188. package/built/scope/scopeImpl.js +88 -0
  189. package/built/scope/scopeImpl.js.map +1 -0
  190. package/built/scope/scopeIterator.js +21 -0
  191. package/built/scope/scopeIterator.js.map +1 -0
  192. package/built/scope/sqlTransactionScope.js +175 -0
  193. package/built/scope/sqlTransactionScope.js.map +1 -0
  194. package/built/wellKnownLabels.js +9 -0
  195. package/built/wellKnownLabels.js.map +1 -0
  196. package/package.json +89 -0
@@ -0,0 +1,83 @@
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
+ };
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var fs_1 = require("fs");
40
+ var promises_1 = require("fs/promises");
41
+ var js_yaml_1 = require("js-yaml");
42
+ var path_1 = require("path");
43
+ var errors_1 = require("../errors");
44
+ function default_1(appIdArg, appMapDir) {
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var searchPath, configPath, _a, configContent, config;
47
+ return __generator(this, function (_b) {
48
+ switch (_b.label) {
49
+ case 0:
50
+ if (appIdArg) {
51
+ return [2 /*return*/, appIdArg];
52
+ }
53
+ if (!appMapDir) return [3 /*break*/, 7];
54
+ searchPath = (0, path_1.resolve)(appMapDir);
55
+ _b.label = 1;
56
+ case 1:
57
+ if (!(searchPath !== '/' && searchPath !== '.')) return [3 /*break*/, 7];
58
+ configPath = (0, path_1.join)(searchPath, 'appmap.yml');
59
+ _b.label = 2;
60
+ case 2:
61
+ _b.trys.push([2, 4, , 5]);
62
+ return [4 /*yield*/, (0, promises_1.access)(configPath, fs_1.constants.R_OK)];
63
+ case 3:
64
+ _b.sent();
65
+ return [3 /*break*/, 5];
66
+ case 4:
67
+ _a = _b.sent();
68
+ searchPath = (0, path_1.dirname)(searchPath);
69
+ return [3 /*break*/, 1];
70
+ case 5: return [4 /*yield*/, (0, promises_1.readFile)(configPath, 'utf-8')];
71
+ case 6:
72
+ configContent = _b.sent();
73
+ config = (0, js_yaml_1.load)(configContent);
74
+ if (config.name)
75
+ return [2 /*return*/, config.name];
76
+ return [3 /*break*/, 1];
77
+ case 7: throw new errors_1.ValidationError('app id was not provided and could not be resolved');
78
+ }
79
+ });
80
+ });
81
+ }
82
+ exports.default = default_1;
83
+ //# sourceMappingURL=resolveAppId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAppId.js","sourceRoot":"","sources":["../../src/cli/resolveAppId.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAA8C;AAC9C,wCAA+C;AAC/C,mCAA+B;AAC/B,6BAA8C;AAC9C,oCAA4C;AAE5C,mBACE,QAA4B,EAC5B,SAA6B;;;;;;oBAE7B,IAAI,QAAQ,EAAE;wBACZ,sBAAO,QAAQ,EAAC;qBACjB;yBAEG,SAAS,EAAT,wBAAS;oBACP,UAAU,GAAG,IAAA,cAAO,EAAC,SAAS,CAAC,CAAC;;;yBAC7B,CAAA,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG,CAAA;oBACvC,UAAU,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;;;;oBAGhD,qBAAM,IAAA,iBAAM,EAAC,UAAU,EAAE,cAAW,CAAC,IAAI,CAAC,EAAA;;oBAA1C,SAA0C,CAAC;;;;oBAE3C,UAAU,GAAG,IAAA,cAAO,EAAC,UAAU,CAAC,CAAC;oBACjC,wBAAS;wBAGW,qBAAM,IAAA,mBAAQ,EAAC,UAAU,EAAE,OAAO,CAAC,EAAA;;oBAAnD,aAAa,GAAG,SAAmC;oBACnD,MAAM,GAAG,IAAA,cAAI,EAAC,aAAa,CAAsB,CAAC;oBACxD,IAAI,MAAM,CAAC,IAAI;wBAAE,sBAAO,MAAM,CAAC,IAAI,EAAC;;wBAIxC,MAAM,IAAI,wBAAe,CAAC,mDAAmD,CAAC,CAAC;;;;CAChF;AA3BD,4BA2BC"}
@@ -0,0 +1,174 @@
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
+ };
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
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __importDefault = (this && this.__importDefault) || function (mod) {
55
+ return (mod && mod.__esModule) ? mod : { "default": mod };
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ var glob_1 = require("glob");
59
+ var promises_1 = require("fs/promises");
60
+ var util_1 = require("util");
61
+ var configurationProvider_1 = require("../../configuration/configurationProvider");
62
+ var errors_1 = require("../../errors");
63
+ var util_2 = require("../../rules/util");
64
+ var findings_1 = require("../../findings");
65
+ var findingsReport_1 = __importDefault(require("../../report/findingsReport"));
66
+ var summaryReport_1 = __importDefault(require("../../report/summaryReport"));
67
+ var exitCode_1 = require("../exitCode");
68
+ var validateFile_1 = __importDefault(require("../validateFile"));
69
+ var scanner_1 = __importDefault(require("./scanner"));
70
+ var scanArgs_1 = __importDefault(require("../scanArgs"));
71
+ exports.default = {
72
+ command: 'scan',
73
+ describe: 'Scan AppMaps for code behavior findings',
74
+ builder: function (args) {
75
+ (0, scanArgs_1.default)(args);
76
+ args.option('appmap-file', {
77
+ describe: 'single file to scan',
78
+ alias: 'f',
79
+ });
80
+ args.option('ide', {
81
+ describe: 'choose your IDE protocol to open AppMaps directly in your IDE.',
82
+ options: ['vscode', 'x-mine', 'idea', 'pycharm'],
83
+ });
84
+ args.option('all', {
85
+ describe: 'report all findings, including duplicates of known findings',
86
+ default: false,
87
+ type: 'boolean',
88
+ });
89
+ return args.strict();
90
+ },
91
+ handler: function (options) {
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var _a, appmapDir, appmapFile, config, isVerbose, reportAllFindings, appIdArg, apiKey, ide, reportFile, files, glob, configData, scanner, _b, rawScanResults, findingStatuses, scanResults, err_1;
94
+ return __generator(this, function (_c) {
95
+ switch (_c.label) {
96
+ case 0:
97
+ _a = options, appmapDir = _a.appmapDir, appmapFile = _a.appmapFile, config = _a.config, isVerbose = _a.verbose, reportAllFindings = _a.all, appIdArg = _a.app, apiKey = _a.apiKey, ide = _a.ide, reportFile = _a.reportFile;
98
+ if (isVerbose) {
99
+ (0, util_2.verbose)(true);
100
+ }
101
+ if (apiKey) {
102
+ process.env.APPLAND_API_KEY = apiKey;
103
+ }
104
+ _c.label = 1;
105
+ case 1:
106
+ _c.trys.push([1, 10, , 11]);
107
+ if (appmapFile && appmapDir) {
108
+ throw new errors_1.ValidationError('Use --appmap-dir or --appmap-file, but not both');
109
+ }
110
+ if (!appmapFile && !appmapDir) {
111
+ throw new errors_1.ValidationError('Either --appmap-dir or --appmap-file is required');
112
+ }
113
+ files = [];
114
+ if (!appmapDir) return [3 /*break*/, 4];
115
+ return [4 /*yield*/, (0, validateFile_1.default)('directory', appmapDir)];
116
+ case 2:
117
+ _c.sent();
118
+ glob = (0, util_1.promisify)(glob_1.glob);
119
+ return [4 /*yield*/, glob(appmapDir + "/**/*.appmap.json")];
120
+ case 3:
121
+ files = _c.sent();
122
+ _c.label = 4;
123
+ case 4:
124
+ if (!appmapFile) return [3 /*break*/, 6];
125
+ return [4 /*yield*/, (0, validateFile_1.default)('file', appmapFile)];
126
+ case 5:
127
+ _c.sent();
128
+ files = [appmapFile];
129
+ _c.label = 6;
130
+ case 6: return [4 /*yield*/, (0, configurationProvider_1.parseConfigFile)(config)];
131
+ case 7:
132
+ configData = _c.sent();
133
+ scanner = (0, scanner_1.default)(reportAllFindings, configData, files);
134
+ return [4 /*yield*/, Promise.all([scanner.scan(), scanner.fetchFindingStatus(appIdArg, appmapDir)])];
135
+ case 8:
136
+ _b = __read.apply(void 0, [_c.sent(), 2]), rawScanResults = _b[0], findingStatuses = _b[1];
137
+ // Always report the raw data
138
+ return [4 /*yield*/, (0, promises_1.writeFile)(reportFile, JSON.stringify(rawScanResults, null, 2))];
139
+ case 9:
140
+ // Always report the raw data
141
+ _c.sent();
142
+ scanResults = void 0;
143
+ if (reportAllFindings) {
144
+ scanResults = rawScanResults;
145
+ }
146
+ else {
147
+ scanResults = rawScanResults.withFindings((0, findings_1.newFindings)(rawScanResults.findings, findingStatuses));
148
+ }
149
+ (0, findingsReport_1.default)(scanResults.findings, scanResults.appMapMetadata, ide);
150
+ console.log();
151
+ (0, summaryReport_1.default)(scanResults, true);
152
+ console.log('\n');
153
+ return [3 /*break*/, 11];
154
+ case 10:
155
+ err_1 = _c.sent();
156
+ if (err_1 instanceof errors_1.ValidationError) {
157
+ console.warn(err_1.message);
158
+ return [2 /*return*/, process.exit(exitCode_1.ExitCode.ValidationError)];
159
+ }
160
+ if (err_1 instanceof errors_1.AbortError) {
161
+ return [2 /*return*/, process.exit(exitCode_1.ExitCode.AbortError)];
162
+ }
163
+ if (!util_2.verbose && err_1 instanceof Error) {
164
+ console.error(err_1.message);
165
+ return [2 /*return*/, process.exit(exitCode_1.ExitCode.RuntimeError)];
166
+ }
167
+ throw err_1;
168
+ case 11: return [2 /*return*/];
169
+ }
170
+ });
171
+ });
172
+ },
173
+ };
174
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/cli/scan/command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4C;AAC5C,wCAAwC;AACxC,6BAAiC;AAKjC,mFAA4E;AAC5E,uCAA2D;AAE3D,yCAA2C;AAC3C,2CAA6C;AAC7C,+EAAyD;AACzD,6EAAuD;AAEvD,wCAAuC;AACvC,iEAA2C;AAG3C,sDAAoD;AACpD,yDAAmC;AAEnC,kBAAe;IACb,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,yCAAyC;IACnD,OAAO,EAAP,UAAQ,IAAU;QAChB,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,aAAa,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AAC,IAAI,CAAC,CAAC;;;;wBAElB,IAAI,KAAG,YAAY,wBAAe,EAAE;4BAClC,OAAO,CAAC,IAAI,CAAC,KAAG,CAAC,OAAO,CAAC,CAAC;4BAC1B,sBAAO,OAAO,CAAC,IAAI,CAAC,mBAAQ,CAAC,eAAe,CAAC,EAAC;yBAC/C;wBACD,IAAI,KAAG,YAAY,mBAAU,EAAE;4BAC7B,sBAAO,OAAO,CAAC,IAAI,CAAC,mBAAQ,CAAC,UAAU,CAAC,EAAC;yBAC1C;wBACD,IAAI,CAAC,cAAO,IAAI,KAAG,YAAY,KAAK,EAAE;4BACpC,OAAO,CAAC,KAAK,CAAC,KAAG,CAAC,OAAO,CAAC,CAAC;4BAC3B,sBAAO,OAAO,CAAC,IAAI,CAAC,mBAAQ,CAAC,YAAY,CAAC,EAAC;yBAC5C;wBAED,MAAM,KAAG,CAAC;;;;;KAEb;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/cli/scan/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,154 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __importDefault = (this && this.__importDefault) || function (mod) {
54
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ var src_1 = require("@appland/client/dist/src");
58
+ var configurationProvider_1 = require("../../configuration/configurationProvider");
59
+ var fetchStatus_1 = __importDefault(require("../../integration/appland/fetchStatus"));
60
+ var resolveAppId_1 = __importDefault(require("../resolveAppId"));
61
+ var scan_1 = __importDefault(require("../scan"));
62
+ var scanResults_1 = require("../../report/scanResults");
63
+ function scanner(reportAllFindings, configuration, files) {
64
+ return reportAllFindings
65
+ ? new StandaloneScanner(configuration, files)
66
+ : new ServerIntegratedScanner(configuration, files);
67
+ }
68
+ exports.default = scanner;
69
+ var ScannerBase = /** @class */ (function () {
70
+ function ScannerBase(configuration, files) {
71
+ this.configuration = configuration;
72
+ this.files = files;
73
+ }
74
+ ScannerBase.prototype.scan = function () {
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ var checks, _a, appMapMetadata, findings;
77
+ return __generator(this, function (_b) {
78
+ switch (_b.label) {
79
+ case 0: return [4 /*yield*/, this.verifyServerConfiguration()];
80
+ case 1:
81
+ _b.sent();
82
+ return [4 /*yield*/, (0, configurationProvider_1.loadConfig)(this.configuration)];
83
+ case 2:
84
+ checks = _b.sent();
85
+ return [4 /*yield*/, (0, scan_1.default)(this.files, checks)];
86
+ case 3:
87
+ _a = _b.sent(), appMapMetadata = _a.appMapMetadata, findings = _a.findings;
88
+ return [2 /*return*/, new scanResults_1.ScanResults(this.configuration, appMapMetadata, findings, checks)];
89
+ }
90
+ });
91
+ });
92
+ };
93
+ return ScannerBase;
94
+ }());
95
+ var ServerIntegratedScanner = /** @class */ (function (_super) {
96
+ __extends(ServerIntegratedScanner, _super);
97
+ function ServerIntegratedScanner() {
98
+ return _super !== null && _super.apply(this, arguments) || this;
99
+ }
100
+ ServerIntegratedScanner.prototype.verifyServerConfiguration = function () {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ return __generator(this, function (_a) {
103
+ return [2 /*return*/, new Promise(function (resolve) {
104
+ (0, src_1.loadConfiguration)()
105
+ .then(function () { return resolve(true); })
106
+ .catch(function (err) {
107
+ console.warn("\u26A0\uFE0F Notice \u26A0\uFE0F");
108
+ console.warn("\u26A0\uFE0F AppMap Server configuration is not available.");
109
+ console.warn("\u26A0\uFE0F Detailed message: " + err.toString());
110
+ console.warn("\u26A0\uFE0F Scanning will continue without fetching existing findings from the server.");
111
+ resolve(false);
112
+ });
113
+ })];
114
+ });
115
+ });
116
+ };
117
+ ServerIntegratedScanner.prototype.fetchFindingStatus = function (appIdArg, appMapDir) {
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ var appId;
120
+ return __generator(this, function (_a) {
121
+ switch (_a.label) {
122
+ case 0: return [4 /*yield*/, (0, resolveAppId_1.default)(appIdArg, appMapDir)];
123
+ case 1:
124
+ appId = _a.sent();
125
+ return [4 /*yield*/, (0, fetchStatus_1.default)(appId)];
126
+ case 2: return [2 /*return*/, _a.sent()];
127
+ }
128
+ });
129
+ });
130
+ };
131
+ return ServerIntegratedScanner;
132
+ }(ScannerBase));
133
+ var StandaloneScanner = /** @class */ (function (_super) {
134
+ __extends(StandaloneScanner, _super);
135
+ function StandaloneScanner() {
136
+ return _super !== null && _super.apply(this, arguments) || this;
137
+ }
138
+ StandaloneScanner.prototype.verifyServerConfiguration = function () {
139
+ return __awaiter(this, void 0, void 0, function () {
140
+ return __generator(this, function (_a) {
141
+ return [2 /*return*/, true];
142
+ });
143
+ });
144
+ };
145
+ StandaloneScanner.prototype.fetchFindingStatus = function () {
146
+ return __awaiter(this, void 0, void 0, function () {
147
+ return __generator(this, function (_a) {
148
+ return [2 /*return*/, []];
149
+ });
150
+ });
151
+ };
152
+ return StandaloneScanner;
153
+ }(ScannerBase));
154
+ //# sourceMappingUR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AAI,CAAC,cAAM,OAAA,OAAO,CAAC,IAAI,CAAC,EAAb,CAAa,CAAC;6BACzB,KAAK,CAAC,UAAC,GAAG;4BACT,OAAO,CAAC,IAAI,CAAC,kCAAc,CAAC,CAAC;4BAC7B,OAAO,CAAC,IAAI,CAAC,4DAAkD,CAAC,CAAC;4BACjE,OAAO,CAAC,IAAI,CAAC,oCAAwB,GAAG,CAAC,QAAQ,EAAI,CAAC,CAAC;4BACvD,OAAO,CAAC,IAAI,CACV,yFAA+E,CAChF,CAAC;4BACF,OAAO,CAAC,KAAK,CAAC,CAAC;wBACjB,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,EAAC;;;KACJ;IAEK,oDAAkB,GAAxB,UACE,QAAiB,EACjB,SAAkB;;;;;4BAEJ,qBAAM,IAAA,sBAAY,EAAC,QAAQ,EAAE,SAAS,CAAC,EAAA;;wBAA/C,KAAK,GAAG,SAAuC;wBAC9C,qBAAM,IAAA,qBAAW,EAAC,KAAK,CAAC,EAAA;4BAA/B,sBAAO,SAAwB,EAAC;;;;KACjC;IACH,8BAAC;AAAD,CAAC,AAxBD,CAAsC,WAAW,GAwBhD;AAED;IAAgC,qCAAW;IAA3C;;IAQA,CAAC;IAPO,qDAAyB,GAA/B;;;gBACE,sBAAO,IAAI,EAAC;;;KACb;IAEK,8CAAkB,GAAxB;;;gBACE,sBAAO,EAAE,EAAC;;;KACX;IACH,wBAAC;AAAD,CAAC,AARD,CAAgC,WAAW,GAQ1C"}
@@ -0,0 +1,103 @@
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
+ };
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var promises_1 = require("fs/promises");
43
+ var models_1 = require("@appland/models");
44
+ var ruleChecker_1 = __importDefault(require("../ruleChecker"));
45
+ var progressReporter_1 = __importDefault(require("./progressReporter"));
46
+ function scan(files, checks) {
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ var checker, appMapMetadata, findings;
49
+ var _this = this;
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0:
53
+ checker = new ruleChecker_1.default();
54
+ appMapMetadata = {};
55
+ findings = [];
56
+ return [4 /*yield*/, Promise.all(files.map(function (file) { return __awaiter(_this, void 0, void 0, function () {
57
+ var appMapData, appMap;
58
+ var _this = this;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0:
62
+ // TODO: Improve this by respecting .gitignore, or similar.
63
+ // For now, this addresses the main problem of encountering appmap-js and its appmap.json files
64
+ // in a bundled node_modules.
65
+ if (file.split('/').includes('node_modules')) {
66
+ return [2 /*return*/, null];
67
+ }
68
+ return [4 /*yield*/, (0, promises_1.readFile)(file, 'utf8')];
69
+ case 1:
70
+ appMapData = _a.sent();
71
+ appMap = (0, models_1.buildAppMap)(appMapData).normalize().build();
72
+ appMapMetadata[file] = appMap.metadata;
73
+ return [4 /*yield*/, Promise.all(checks.map(function (check) { return __awaiter(_this, void 0, void 0, function () {
74
+ var matchCount, newMatches;
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0:
78
+ matchCount = findings.length;
79
+ return [4 /*yield*/, checker.check(file, appMap, check, findings)];
80
+ case 1:
81
+ _a.sent();
82
+ newMatches = findings.slice(matchCount, findings.length);
83
+ newMatches.forEach(function (match) { return (match.appMapFile = file); });
84
+ process.stderr.write((0, progressReporter_1.default)(newMatches));
85
+ return [2 /*return*/];
86
+ }
87
+ });
88
+ }); }))];
89
+ case 2:
90
+ _a.sent();
91
+ return [2 /*return*/];
92
+ }
93
+ });
94
+ }); }))];
95
+ case 1:
96
+ _a.sent();
97
+ return [2 /*return*/, { appMapMetadata: appMapMetadata, findings: findings }];
98
+ }
99
+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AAM,CAAC,CAAC;4DAC/D,UAAU,CAAC,OAAO,CAAC,UAAC,KAAK,IAAK,OAAA,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,EAAzB,CAAyB,CAAC,CAAC;4DACzD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,0BAAgB,EAAC,UAAU,CAAC,CAAC,CAAC;;;;iDACpD,CAAC,CACH,EAAA;;wCARD,SAQC,CAAC;;;;6BACH,CAAC,CACH,EAAA;;oBAtBD,SAsBC,CAAC;oBAEF,sBAAO,EAAE,cAAc,gBAAA,EAAE,QAAQ,UAAA,EAAE,EAAC;;;;CACrC;AA9BD,uBA8BC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var path_1 = require("path");
4
+ function default_1(args) {
5
+ args.option('appmap-dir', {
6
+ describe: 'directory to recursively inspect for AppMaps',
7
+ alias: 'd',
8
+ });
9
+ args.option('config', {
10
+ describe: 'path to assertions config file (TypeScript or YAML, check docs for configuration format)',
11
+ default: (0, path_1.join)(__dirname, '../sampleConfig/default.yml'),
12
+ alias: 'c',
13
+ });
14
+ args.option('report-file', {
15
+ describe: 'file name for findings report',
16
+ default: 'appland-findings.json',
17
+ });
18
+ args.option('api-key', {
19
+ describe: 'AppMap server API key. Use of this option is discouraged; set APPLAND_API_KEY instead',
20
+ });
21
+ args.option('app', {
22
+ describe: 'name of the app to publish the findings for. By default, this is determined by looking in appmap.yml',
23
+ });
24
+ }
25
+ exports.default = default_1;
26
+ //# sourceMappingURL=scanArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanArgs.js","sourceRoot":"","sources":["../../src/cli/scanArgs.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAG5B,mBAAyB,IAAU;IACjC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;QACxB,QAAQ,EAAE,8CAA8C;QACxD,KAAK,EAAE,GAAG;KACX,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACpB,QAAQ,EACN,0FAA0F;QAC5F,OAAO,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,6BAA6B,CAAC;QACvD,KAAK,EAAE,GAAG;KACX,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE;QACzB,QAAQ,EAAE,+BAA+B;QACzC,OAAO,EAAE,uBAAuB;KACjC,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACrB,QAAQ,EACN,uFAAuF;KAC1F,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,QAAQ,EACN,sGAAsG;KACzG,CAAC,CAAC;AACL,CAAC;AAvBD,4BAuBC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=scanOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanOptions.js","sourceRoot":"","sources":["../../src/cli/scanOptions.ts"],"names":[],"mappings":""}