@appland/scanner 1.56.0 → 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.
- package/CHANGELOG.md +15 -0
- package/built/algorithms/dataStructures/graph/Graph.js +53 -62
- package/built/algorithms/dataStructures/graph/GraphEdge.js +13 -16
- package/built/algorithms/dataStructures/graph/GraphVertex.js +37 -42
- package/built/algorithms/dataStructures/linked-list/LinkedList.js +33 -38
- package/built/algorithms/dataStructures/linked-list/LinkedListNode.js +6 -10
- package/built/algorithms/graph/depth-first-search/index.js +7 -8
- package/built/algorithms/graph/detect-cycle/index.js +15 -16
- package/built/algorithms/utils/Comparator.js +19 -21
- package/built/analyzer/recordSecrets.js +7 -30
- package/built/analyzer/secretsRegexes.js +8 -9
- package/built/appMapIndex.js +18 -20
- package/built/check.js +16 -18
- package/built/checkInstance.js +26 -48
- package/built/cli/ci/command.js +61 -156
- package/built/cli/ci/options.js +0 -1
- package/built/cli/codeVersionArgs.js +0 -1
- package/built/cli/exitCode.js +0 -1
- package/built/cli/fail.js +2 -3
- package/built/cli/merge/command.js +21 -63
- package/built/cli/merge/options.js +0 -1
- package/built/cli/reportUploadURL.js +2 -3
- package/built/cli/resolveAppId.js +34 -85
- package/built/cli/scan/command.js +52 -94
- package/built/cli/scan/formatReport.js +16 -89
- package/built/cli/scan/options.js +0 -1
- package/built/cli/scan/scanner.js +38 -117
- package/built/cli/scan/singleScan.js +61 -109
- package/built/cli/scan/watchScan.js +32 -82
- package/built/cli/scan.js +39 -132
- package/built/cli/scanArgs.js +0 -1
- package/built/cli/scanOptions.js +0 -1
- package/built/cli/updateCommitStatus.js +10 -47
- package/built/cli/upload/command.js +20 -64
- package/built/cli/upload/options.js +0 -1
- package/built/cli/upload/pruneAppMap.js +16 -0
- package/built/cli/upload.js +91 -172
- package/built/cli/validateFile.js +13 -52
- package/built/cli.js +34 -21
- package/built/configuration/configurationProvider.js +148 -233
- package/built/configuration/schema/options.json +76 -76
- package/built/configuration/types/checkConfig.js +0 -1
- package/built/configuration/types/configuration.js +0 -1
- package/built/configuration/types/matchEventConfig.js +0 -1
- package/built/configuration/types/matchPatternConfig.js +0 -1
- package/built/database/index.js +33 -127
- package/built/database/visit.js +16 -66
- package/built/errors.js +4 -30
- package/built/eventUtil.js +10 -35
- package/built/findings.js +3 -4
- package/built/integration/appland/app/exists.js +33 -76
- package/built/integration/appland/app/listFindingStatus.js +3 -36
- package/built/integration/appland/appMap/create.js +38 -89
- package/built/integration/appland/location.js +0 -1
- package/built/integration/appland/mapset/create.js +34 -85
- package/built/integration/appland/retry.js +10 -11
- package/built/integration/appland/retryOptions.js +0 -1
- package/built/integration/appland/scannerJob/create.js +34 -84
- package/built/integration/appland/scannerJob/merge.js +28 -74
- package/built/integration/appland/scannerJob.js +0 -1
- package/built/integration/github/commitStatus.js +3 -4
- package/built/integration/vars.js +1 -2
- package/built/openapi/index.js +39 -83
- package/built/report/appMapMetadata.js +0 -1
- package/built/report/findingSummary.js +0 -1
- package/built/report/findingsReport.js +14 -16
- package/built/report/scanResults.js +18 -45
- package/built/report/scanSummary.js +0 -1
- package/built/report/summaryReport.js +12 -13
- package/built/ruleChecker.js +146 -297
- package/built/rules/authzBeforeAuthn.js +25 -59
- package/built/rules/circularDependency.js +69 -101
- package/built/rules/deserializationOfUntrustedData.js +29 -63
- package/built/rules/execOfUntrustedCommand.js +28 -62
- package/built/rules/http-500/metadata.js +0 -1
- package/built/rules/http-500/rule.js +2 -3
- package/built/rules/illegalPackageDependency.js +16 -18
- package/built/rules/incompatibleHttpClientRequest.js +30 -69
- package/built/rules/insecureCompare.js +12 -13
- package/built/rules/jobNotCancelled.js +13 -45
- package/built/rules/lib/hasParameterOrReceiver.js +4 -7
- package/built/rules/lib/matchEvent.js +12 -13
- package/built/rules/lib/matchPattern.js +6 -7
- package/built/rules/lib/metadata.js +0 -1
- package/built/rules/lib/parseRuleDescription.js +5 -6
- package/built/rules/lib/precedingEvents.js +7 -75
- package/built/rules/lib/rpcWithoutProtection.js +5 -28
- package/built/rules/lib/sanitizesData.js +0 -1
- package/built/rules/lib/util.js +33 -73
- package/built/rules/logoutWithoutSessionReset.js +24 -58
- package/built/rules/missingAuthentication.js +28 -28
- package/built/rules/missingContentType.js +8 -9
- package/built/rules/nPlusOneQuery.js +35 -87
- package/built/rules/queryFromInvalidPackage.js +17 -19
- package/built/rules/queryFromView.js +13 -16
- package/built/rules/rpcWithoutCircuitBreaker.js +14 -84
- package/built/rules/saveWithoutValidation.js +8 -9
- package/built/rules/secretInLog.js +29 -92
- package/built/rules/slowFunctionCall.js +16 -20
- package/built/rules/slowHttpServerRequest.js +9 -11
- package/built/rules/slowQuery.js +9 -12
- package/built/rules/tooManyJoins.js +26 -51
- package/built/rules/tooManyUpdates.js +25 -105
- package/built/rules/unbatchedMaterializedQuery.js +26 -30
- package/built/rules/updateInGetRequest.js +30 -45
- package/built/scope/commandScope.js +24 -144
- package/built/scope/httpClientRequestScope.js +11 -98
- package/built/scope/httpServerRequestScope.js +11 -98
- package/built/scope/rootScope.js +11 -98
- package/built/scope/scopeImpl.js +10 -82
- package/built/scope/scopeIterator.js +6 -10
- package/built/scope/sqlTransactionScope.js +24 -122
- package/built/sqlWarning.js +9 -35
- package/built/telemetry.js +215 -0
- package/built/wellKnownLabels.js +0 -1
- package/package.json +7 -3
- package/built/algorithms/dataStructures/graph/Graph.js.map +0 -1
- package/built/algorithms/dataStructures/graph/GraphEdge.js.map +0 -1
- package/built/algorithms/dataStructures/graph/GraphVertex.js.map +0 -1
- package/built/algorithms/dataStructures/linked-list/LinkedList.js.map +0 -1
- package/built/algorithms/dataStructures/linked-list/LinkedListNode.js.map +0 -1
- package/built/algorithms/graph/depth-first-search/index.js.map +0 -1
- package/built/algorithms/graph/detect-cycle/index.js.map +0 -1
- package/built/algorithms/utils/Comparator.js.map +0 -1
- package/built/analyzer/recordSecrets.js.map +0 -1
- package/built/analyzer/secretsRegexes.js.map +0 -1
- package/built/appMapIndex.js.map +0 -1
- package/built/check.js.map +0 -1
- package/built/checkInstance.js.map +0 -1
- package/built/cli/ci/command.js.map +0 -1
- package/built/cli/ci/options.js.map +0 -1
- package/built/cli/codeVersionArgs.js.map +0 -1
- package/built/cli/exitCode.js.map +0 -1
- package/built/cli/fail.js.map +0 -1
- package/built/cli/merge/command.js.map +0 -1
- package/built/cli/merge/options.js.map +0 -1
- package/built/cli/reportUploadURL.js.map +0 -1
- package/built/cli/resolveAppId.js.map +0 -1
- package/built/cli/scan/command.js.map +0 -1
- package/built/cli/scan/formatReport.js.map +0 -1
- package/built/cli/scan/options.js.map +0 -1
- package/built/cli/scan/scanner.js.map +0 -1
- package/built/cli/scan/singleScan.js.map +0 -1
- package/built/cli/scan/watchScan.js.map +0 -1
- package/built/cli/scan.js.map +0 -1
- package/built/cli/scanArgs.js.map +0 -1
- package/built/cli/scanOptions.js.map +0 -1
- package/built/cli/updateCommitStatus.js.map +0 -1
- package/built/cli/upload/command.js.map +0 -1
- package/built/cli/upload/options.js.map +0 -1
- package/built/cli/upload.js.map +0 -1
- package/built/cli/validateFile.js.map +0 -1
- package/built/cli.js.map +0 -1
- package/built/configuration/configurationProvider.js.map +0 -1
- package/built/configuration/types/checkConfig.js.map +0 -1
- package/built/configuration/types/configuration.js.map +0 -1
- package/built/configuration/types/matchEventConfig.js.map +0 -1
- package/built/configuration/types/matchPatternConfig.js.map +0 -1
- package/built/database/index.js.map +0 -1
- package/built/database/visit.js.map +0 -1
- package/built/errors.js.map +0 -1
- package/built/eventUtil.js.map +0 -1
- package/built/findings.js.map +0 -1
- package/built/integration/appland/app/exists.js.map +0 -1
- package/built/integration/appland/app/listFindingStatus.js.map +0 -1
- package/built/integration/appland/appMap/create.js.map +0 -1
- package/built/integration/appland/location.js.map +0 -1
- package/built/integration/appland/mapset/create.js.map +0 -1
- package/built/integration/appland/retry.js.map +0 -1
- package/built/integration/appland/retryOptions.js.map +0 -1
- package/built/integration/appland/scannerJob/create.js.map +0 -1
- package/built/integration/appland/scannerJob/merge.js.map +0 -1
- package/built/integration/appland/scannerJob.js.map +0 -1
- package/built/integration/github/commitStatus.js.map +0 -1
- package/built/integration/vars.js.map +0 -1
- package/built/openapi/index.js.map +0 -1
- package/built/openapi/method.js +0 -120
- package/built/openapi/method.js.map +0 -1
- package/built/openapi/model.js +0 -49
- package/built/openapi/model.js.map +0 -1
- package/built/openapi/path.js +0 -36
- package/built/openapi/path.js.map +0 -1
- package/built/openapi/provider.js +0 -133
- package/built/openapi/provider.js.map +0 -1
- package/built/openapi/response.js +0 -59
- package/built/openapi/response.js.map +0 -1
- package/built/openapi/rpcRequest.js +0 -130
- package/built/openapi/rpcRequest.js.map +0 -1
- package/built/openapi/schema.js +0 -42
- package/built/openapi/schema.js.map +0 -1
- package/built/openapi/securitySchemes.js +0 -32
- package/built/openapi/securitySchemes.js.map +0 -1
- package/built/openapi/statusCodes.js +0 -68
- package/built/openapi/statusCodes.js.map +0 -1
- package/built/openapi/util.js +0 -91
- package/built/openapi/util.js.map +0 -1
- package/built/report/appMapMetadata.js.map +0 -1
- package/built/report/findingSummary.js.map +0 -1
- package/built/report/findingsReport.js.map +0 -1
- package/built/report/scanResults.js.map +0 -1
- package/built/report/scanSummary.js.map +0 -1
- package/built/report/summaryReport.js.map +0 -1
- package/built/ruleChecker.js.map +0 -1
- package/built/rules/authzBeforeAuthn.js.map +0 -1
- package/built/rules/circularDependency.js.map +0 -1
- package/built/rules/deserializationOfUntrustedData.js.map +0 -1
- package/built/rules/execOfUntrustedCommand.js.map +0 -1
- package/built/rules/http-500/metadata.js.map +0 -1
- package/built/rules/http-500/rule.js.map +0 -1
- package/built/rules/illegalPackageDependency.js.map +0 -1
- package/built/rules/incompatibleHttpClientRequest.js.map +0 -1
- package/built/rules/insecureCompare.js.map +0 -1
- package/built/rules/jobNotCancelled.js.map +0 -1
- package/built/rules/lib/hasParameterOrReceiver.js.map +0 -1
- package/built/rules/lib/matchEvent.js.map +0 -1
- package/built/rules/lib/matchPattern.js.map +0 -1
- package/built/rules/lib/metadata.js.map +0 -1
- package/built/rules/lib/parseRuleDescription.js.map +0 -1
- package/built/rules/lib/precedingEvents.js.map +0 -1
- package/built/rules/lib/rpcWithoutProtection.js.map +0 -1
- package/built/rules/lib/sanitizesData.js.map +0 -1
- package/built/rules/lib/util.js.map +0 -1
- package/built/rules/logoutWithoutSessionReset.js.map +0 -1
- package/built/rules/missingAuthentication.js.map +0 -1
- package/built/rules/missingContentType.js.map +0 -1
- package/built/rules/nPlusOneQuery.js.map +0 -1
- package/built/rules/queryFromInvalidPackage.js.map +0 -1
- package/built/rules/queryFromView.js.map +0 -1
- package/built/rules/rpcWithoutCircuitBreaker.js.map +0 -1
- package/built/rules/saveWithoutValidation.js.map +0 -1
- package/built/rules/secretInLog.js.map +0 -1
- package/built/rules/slowFunctionCall.js.map +0 -1
- package/built/rules/slowHttpServerRequest.js.map +0 -1
- package/built/rules/slowQuery.js.map +0 -1
- package/built/rules/tooManyJoins.js.map +0 -1
- package/built/rules/tooManyUpdates.js.map +0 -1
- package/built/rules/unbatchedMaterializedQuery.js.map +0 -1
- package/built/rules/updateInGetRequest.js.map +0 -1
- package/built/scope/commandScope.js.map +0 -1
- package/built/scope/httpClientRequestScope.js.map +0 -1
- package/built/scope/httpServerRequestScope.js.map +0 -1
- package/built/scope/rootScope.js.map +0 -1
- package/built/scope/scopeImpl.js.map +0 -1
- package/built/scope/scopeIterator.js.map +0 -1
- package/built/scope/sqlTransactionScope.js.map +0 -1
- package/built/sqlWarning.js.map +0 -1
- package/built/wellKnownLabels.js.map +0 -1
|
@@ -1,19 +1,4 @@
|
|
|
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
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -23,122 +8,58 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
9
|
});
|
|
25
10
|
};
|
|
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
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
13
|
};
|
|
56
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
15
|
+
const src_1 = require("@appland/client/dist/src");
|
|
16
|
+
const configurationProvider_1 = require("../../configuration/configurationProvider");
|
|
17
|
+
const listFindingStatus_1 = __importDefault(require("../../integration/appland/app/listFindingStatus"));
|
|
18
|
+
const resolveAppId_1 = __importDefault(require("../resolveAppId"));
|
|
19
|
+
const scan_1 = __importDefault(require("../scan"));
|
|
20
|
+
const scanResults_1 = require("../../report/scanResults");
|
|
63
21
|
function scanner(reportAllFindings, configuration, files) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
_a.sent();
|
|
73
|
-
return [2 /*return*/, new ServerIntegratedScanner(configuration, files)];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (reportAllFindings) {
|
|
24
|
+
return new StandaloneScanner(configuration, files);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
yield (0, src_1.loadConfiguration)();
|
|
28
|
+
return new ServerIntegratedScanner(configuration, files);
|
|
29
|
+
}
|
|
76
30
|
});
|
|
77
31
|
}
|
|
78
32
|
exports.default = scanner;
|
|
79
|
-
|
|
80
|
-
|
|
33
|
+
class ScannerBase {
|
|
34
|
+
constructor(configuration, files) {
|
|
81
35
|
this.configuration = configuration;
|
|
82
36
|
this.files = files;
|
|
83
37
|
}
|
|
84
|
-
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
case 0: return [4 /*yield*/, (0, configurationProvider_1.loadConfig)(this.configuration)];
|
|
90
|
-
case 1:
|
|
91
|
-
checks = _b.sent();
|
|
92
|
-
return [4 /*yield*/, (0, scan_1.default)(this.files, checks)];
|
|
93
|
-
case 2:
|
|
94
|
-
_a = _b.sent(), appMapMetadata = _a.appMapMetadata, findings = _a.findings;
|
|
95
|
-
return [2 /*return*/, new scanResults_1.ScanResults(this.configuration, appMapMetadata, findings, checks)];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
38
|
+
scan() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const checks = yield (0, configurationProvider_1.loadConfig)(this.configuration);
|
|
41
|
+
const { appMapMetadata, findings } = yield (0, scan_1.default)(this.files, checks);
|
|
42
|
+
return new scanResults_1.ScanResults(this.configuration, appMapMetadata, findings, checks);
|
|
98
43
|
});
|
|
99
|
-
};
|
|
100
|
-
return ScannerBase;
|
|
101
|
-
}());
|
|
102
|
-
var ServerIntegratedScanner = /** @class */ (function (_super) {
|
|
103
|
-
__extends(ServerIntegratedScanner, _super);
|
|
104
|
-
function ServerIntegratedScanner() {
|
|
105
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
106
44
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
case 1:
|
|
114
|
-
appId = _a.sent();
|
|
115
|
-
return [4 /*yield*/, (0, listFindingStatus_1.default)(appId)];
|
|
116
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
45
|
+
}
|
|
46
|
+
class ServerIntegratedScanner extends ScannerBase {
|
|
47
|
+
fetchFindingStatus(appIdArg, appMapDir) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const appId = yield (0, resolveAppId_1.default)(appIdArg, appMapDir);
|
|
50
|
+
return yield (0, listFindingStatus_1.default)(appId);
|
|
119
51
|
});
|
|
120
|
-
};
|
|
121
|
-
return ServerIntegratedScanner;
|
|
122
|
-
}(ScannerBase));
|
|
123
|
-
var StandaloneScanner = /** @class */ (function (_super) {
|
|
124
|
-
__extends(StandaloneScanner, _super);
|
|
125
|
-
function StandaloneScanner() {
|
|
126
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
127
52
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
53
|
+
}
|
|
54
|
+
class StandaloneScanner extends ScannerBase {
|
|
55
|
+
verifyServerConfiguration() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return true;
|
|
133
58
|
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
return
|
|
138
|
-
return [2 /*return*/, []];
|
|
139
|
-
});
|
|
59
|
+
}
|
|
60
|
+
fetchFindingStatus() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return [];
|
|
140
63
|
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}(ScannerBase));
|
|
144
|
-
//# sourceMappingURL=scanner.js.map
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -8,121 +8,73 @@ 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
|
-
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
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
55
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
56
13
|
};
|
|
57
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
15
|
+
const util_1 = require("util");
|
|
16
|
+
const promises_1 = require("fs/promises");
|
|
17
|
+
const glob_1 = require("glob");
|
|
18
|
+
const validateFile_1 = __importDefault(require("../validateFile"));
|
|
19
|
+
const scanner_1 = __importDefault(require("./scanner"));
|
|
20
|
+
const errors_1 = require("../../errors");
|
|
21
|
+
const findings_1 = require("../../findings");
|
|
22
|
+
const findingsReport_1 = __importDefault(require("../../report/findingsReport"));
|
|
23
|
+
const summaryReport_1 = __importDefault(require("../../report/summaryReport"));
|
|
24
|
+
const formatReport_1 = require("./formatReport");
|
|
25
|
+
const telemetry_1 = __importDefault(require("../../telemetry"));
|
|
68
26
|
function singleScan(options) {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
_b.label = 2;
|
|
83
|
-
case 2:
|
|
84
|
-
if (!appmapFile) return [3 /*break*/, 4];
|
|
85
|
-
files = typeof appmapFile === 'string' ? [appmapFile] : appmapFile;
|
|
86
|
-
return [4 /*yield*/, Promise.all(files.map(function (file) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
87
|
-
return [2 /*return*/, (0, validateFile_1.default)('file', file)];
|
|
88
|
-
}); }); }))];
|
|
89
|
-
case 3:
|
|
90
|
-
_b.sent();
|
|
91
|
-
_b.label = 4;
|
|
92
|
-
case 4: return [4 /*yield*/, (0, scanner_1.default)(reportAllFindings, configData, files).catch(function (error) {
|
|
93
|
-
throw new errors_1.ValidationError(error.message + '\nUse --all to perform an offline scan.');
|
|
94
|
-
})];
|
|
95
|
-
case 5:
|
|
96
|
-
scanner = _b.sent();
|
|
97
|
-
startTime = Date.now();
|
|
98
|
-
return [4 /*yield*/, Promise.all([
|
|
99
|
-
scanner.scan(),
|
|
100
|
-
scanner.fetchFindingStatus(appId, appmapDir),
|
|
101
|
-
])];
|
|
102
|
-
case 6:
|
|
103
|
-
_a = __read.apply(void 0, [_b.sent(), 2]), rawScanResults = _a[0], findingStatuses = _a[1];
|
|
104
|
-
// Always report the raw data
|
|
105
|
-
return [4 /*yield*/, (0, promises_1.writeFile)(reportFile, (0, formatReport_1.formatReport)(rawScanResults))];
|
|
106
|
-
case 7:
|
|
107
|
-
// Always report the raw data
|
|
108
|
-
_b.sent();
|
|
109
|
-
if (reportAllFindings) {
|
|
110
|
-
scanResults = rawScanResults;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
scanResults = rawScanResults.withFindings((0, findings_1.newFindings)(rawScanResults.findings, findingStatuses));
|
|
114
|
-
}
|
|
115
|
-
(0, findingsReport_1.default)(scanResults.findings, scanResults.appMapMetadata, ide);
|
|
116
|
-
console.log();
|
|
117
|
-
(0, summaryReport_1.default)(scanResults, true);
|
|
118
|
-
console.log('\n');
|
|
119
|
-
elapsed = Date.now() - startTime;
|
|
120
|
-
numChecks = scanResults.checks.length * scanResults.summary.numAppMaps;
|
|
121
|
-
console.log("Performed ".concat(numChecks, " checks in ").concat(elapsed, "ms (").concat(Math.floor(numChecks / (elapsed / 1000.0)), " checks/sec)"));
|
|
122
|
-
return [2 /*return*/];
|
|
123
|
-
}
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const { appmapFile, appmapDir, configData, reportAllFindings, appId, ide, reportFile } = options;
|
|
29
|
+
let files = [];
|
|
30
|
+
if (appmapDir) {
|
|
31
|
+
const glob = (0, util_1.promisify)(glob_1.glob);
|
|
32
|
+
files = yield glob(`${appmapDir}/**/*.appmap.json`);
|
|
33
|
+
}
|
|
34
|
+
if (appmapFile) {
|
|
35
|
+
files = typeof appmapFile === 'string' ? [appmapFile] : appmapFile;
|
|
36
|
+
yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () { return (0, validateFile_1.default)('file', file); })));
|
|
37
|
+
}
|
|
38
|
+
const scanner = yield (0, scanner_1.default)(reportAllFindings, configData, files).catch((error) => {
|
|
39
|
+
throw new errors_1.ValidationError(error.message + '\nUse --all to perform an offline scan.');
|
|
124
40
|
});
|
|
41
|
+
const startTime = Date.now();
|
|
42
|
+
const [rawScanResults, findingStatuses] = yield Promise.all([
|
|
43
|
+
scanner.scan(),
|
|
44
|
+
scanner.fetchFindingStatus(appId, appmapDir),
|
|
45
|
+
]);
|
|
46
|
+
// Always report the raw data
|
|
47
|
+
yield (0, promises_1.writeFile)(reportFile, (0, formatReport_1.formatReport)(rawScanResults));
|
|
48
|
+
let scanResults;
|
|
49
|
+
if (reportAllFindings) {
|
|
50
|
+
scanResults = rawScanResults;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
scanResults = rawScanResults.withFindings((0, findings_1.newFindings)(rawScanResults.findings, findingStatuses));
|
|
54
|
+
}
|
|
55
|
+
(0, findingsReport_1.default)(scanResults.findings, scanResults.appMapMetadata, ide);
|
|
56
|
+
console.log();
|
|
57
|
+
(0, summaryReport_1.default)(scanResults, true);
|
|
58
|
+
console.log('\n');
|
|
59
|
+
const elapsed = Date.now() - startTime;
|
|
60
|
+
const numChecks = scanResults.checks.length * scanResults.summary.numAppMaps;
|
|
61
|
+
console.log(`Performed ${numChecks} checks in ${elapsed}ms (${Math.floor(numChecks / (elapsed / 1000.0))} checks/sec)`);
|
|
62
|
+
sendTelemetry(scanResults, elapsed);
|
|
125
63
|
});
|
|
126
64
|
}
|
|
127
65
|
exports.default = singleScan;
|
|
128
|
-
|
|
66
|
+
function sendTelemetry(scanResults, msElapsed) {
|
|
67
|
+
const rules = [...new Set(scanResults.checks.map(({ id }) => id))];
|
|
68
|
+
telemetry_1.default.sendEvent({
|
|
69
|
+
name: 'scan:completed',
|
|
70
|
+
properties: {
|
|
71
|
+
rules: rules.join(', '),
|
|
72
|
+
},
|
|
73
|
+
metrics: {
|
|
74
|
+
duration: msElapsed / 1000,
|
|
75
|
+
numRules: rules.length,
|
|
76
|
+
numAppMaps: scanResults.summary.numAppMaps,
|
|
77
|
+
numFindings: scanResults.findings.length,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -31,104 +31,54 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (_) try {
|
|
41
|
-
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;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
36
|
};
|
|
64
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
38
|
exports.Watcher = void 0;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
const promises_1 = require("fs/promises");
|
|
40
|
+
const chokidar = __importStar(require("chokidar"));
|
|
41
|
+
const formatReport_1 = require("./formatReport");
|
|
42
|
+
const scanner_1 = __importDefault(require("./scanner"));
|
|
43
|
+
const fs_1 = require("fs");
|
|
44
|
+
const util_1 = require("util");
|
|
45
|
+
class Watcher {
|
|
46
|
+
constructor(options) {
|
|
74
47
|
this.options = options;
|
|
75
48
|
}
|
|
76
|
-
|
|
77
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
ignoreInitial: true,
|
|
81
|
-
});
|
|
82
|
-
this.watcher.on('add', this.scan.bind(this)).on('change', this.scan.bind(this));
|
|
83
|
-
return [2 /*return*/];
|
|
49
|
+
watch() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
this.watcher = chokidar.watch(`${this.options.appmapDir}/**/mtime`, {
|
|
52
|
+
ignoreInitial: true,
|
|
84
53
|
});
|
|
54
|
+
this.watcher.on('add', this.scan.bind(this)).on('change', this.scan.bind(this));
|
|
85
55
|
});
|
|
86
|
-
}
|
|
87
|
-
|
|
56
|
+
}
|
|
57
|
+
abort() {
|
|
88
58
|
if (!this.watcher)
|
|
89
59
|
return;
|
|
90
60
|
this.watcher.close();
|
|
91
61
|
this.watcher = undefined;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (!(_a.sent()))
|
|
106
|
-
return [2 /*return*/];
|
|
107
|
-
return [4 /*yield*/, (0, scanner_1.default)(true, this.options.configData, [appmapFile])];
|
|
108
|
-
case 2:
|
|
109
|
-
scanner = _a.sent();
|
|
110
|
-
return [4 /*yield*/, scanner.scan()];
|
|
111
|
-
case 3:
|
|
112
|
-
rawScanResults = _a.sent();
|
|
113
|
-
// Always report the raw data
|
|
114
|
-
return [4 /*yield*/, (0, promises_1.writeFile)(reportFile, (0, formatReport_1.formatReport)(rawScanResults))];
|
|
115
|
-
case 4:
|
|
116
|
-
// Always report the raw data
|
|
117
|
-
_a.sent();
|
|
118
|
-
return [2 /*return*/];
|
|
119
|
-
}
|
|
120
|
-
});
|
|
62
|
+
}
|
|
63
|
+
scan(fileName) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const pathTokens = fileName.split('/');
|
|
66
|
+
const appmapDir = pathTokens.slice(0, pathTokens.length - 1).join('/');
|
|
67
|
+
const appmapFile = [appmapDir, 'appmap.json'].join('.');
|
|
68
|
+
const reportFile = [appmapDir, 'appmap-findings.json'].join('/');
|
|
69
|
+
if (!(yield (0, util_1.promisify)(fs_1.exists)(appmapFile)))
|
|
70
|
+
return;
|
|
71
|
+
const scanner = yield (0, scanner_1.default)(true, this.options.configData, [appmapFile]);
|
|
72
|
+
const rawScanResults = yield scanner.scan();
|
|
73
|
+
// Always report the raw data
|
|
74
|
+
yield (0, promises_1.writeFile)(reportFile, (0, formatReport_1.formatReport)(rawScanResults));
|
|
121
75
|
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
}());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
125
78
|
exports.Watcher = Watcher;
|
|
126
79
|
function watchScan(options) {
|
|
127
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
-
return
|
|
129
|
-
return [2 /*return*/, new Watcher(options).watch()];
|
|
130
|
-
});
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return new Watcher(options).watch();
|
|
131
82
|
});
|
|
132
83
|
}
|
|
133
84
|
exports.default = watchScan;
|
|
134
|
-
//# sourceMappingURL=watchScan.js.map
|