@appland/scanner 1.54.1 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -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 -147
- 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 +58 -233
- package/built/cli/scan/formatReport.js +44 -0
- package/built/cli/scan/options.js +0 -1
- package/built/cli/scan/scanner.js +38 -117
- package/built/cli/scan/singleScan.js +80 -0
- package/built/cli/scan/watchScan.js +84 -0
- package/built/cli/scan.js +39 -132
- package/built/cli/scanArgs.js +2 -4
- package/built/cli/scanOptions.js +0 -1
- package/built/cli/updateCommitStatus.js +10 -47
- package/built/cli/upload/command.js +21 -65
- 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 -48
- package/built/cli.js +34 -21
- package/built/configuration/configurationProvider.js +148 -227
- 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 +5 -38
- 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 +48 -25
- 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 +30 -93
- 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 +10 -4
- 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/options.js.map +0 -1
- package/built/cli/scan/scanner.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
|
@@ -8,48 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
15
|
+
const promises_1 = require("fs/promises");
|
|
16
|
+
const util_1 = require("../../rules/lib/util");
|
|
17
|
+
const validateFile_1 = __importDefault(require("../validateFile"));
|
|
18
|
+
const resolveAppId_1 = __importDefault(require("../resolveAppId"));
|
|
19
|
+
const reportUploadURL_1 = __importDefault(require("../reportUploadURL"));
|
|
20
|
+
const upload_1 = __importDefault(require("../upload"));
|
|
21
|
+
const codeVersionArgs_1 = __importDefault(require("../codeVersionArgs"));
|
|
49
22
|
exports.default = {
|
|
50
23
|
command: 'upload',
|
|
51
24
|
describe: 'Upload Findings to the AppMap Server',
|
|
52
|
-
builder
|
|
25
|
+
builder(args) {
|
|
53
26
|
(0, codeVersionArgs_1.default)(args);
|
|
54
27
|
args.option('appmap-dir', {
|
|
55
28
|
describe: 'base directory of AppMaps',
|
|
@@ -57,7 +30,7 @@ exports.default = {
|
|
|
57
30
|
});
|
|
58
31
|
args.option('report-file', {
|
|
59
32
|
describe: 'file containing the findings report',
|
|
60
|
-
default: '
|
|
33
|
+
default: 'appmap-findings.json',
|
|
61
34
|
});
|
|
62
35
|
args.option('app', {
|
|
63
36
|
describe: 'name of the app to publish the findings for. By default, this is determined by looking in appmap.yml',
|
|
@@ -67,36 +40,19 @@ exports.default = {
|
|
|
67
40
|
});
|
|
68
41
|
return args.strict();
|
|
69
42
|
},
|
|
70
|
-
handler
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
case 1:
|
|
82
|
-
_d.sent();
|
|
83
|
-
return [4 /*yield*/, (0, resolveAppId_1.default)(appIdArg, appmapDir)];
|
|
84
|
-
case 2:
|
|
85
|
-
appId = _d.sent();
|
|
86
|
-
_c = (_b = JSON).parse;
|
|
87
|
-
return [4 /*yield*/, (0, promises_1.readFile)(reportFile)];
|
|
88
|
-
case 3:
|
|
89
|
-
scanResults = _c.apply(_b, [(_d.sent()).toString()]);
|
|
90
|
-
return [4 /*yield*/, (0, upload_1.default)(scanResults, appId, appmapDir, mergeKey, { branch: branch, commit: commit, environment: environment }, {
|
|
91
|
-
maxRetries: 3,
|
|
92
|
-
})];
|
|
93
|
-
case 4:
|
|
94
|
-
uploadResponse = _d.sent();
|
|
95
|
-
(0, reportUploadURL_1.default)(uploadResponse.summary.numFindings, uploadResponse.url);
|
|
96
|
-
return [2 /*return*/];
|
|
97
|
-
}
|
|
43
|
+
handler(options) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const { verbose: isVerbose, reportFile, appmapDir, app: appIdArg, mergeKey, branch, commit, environment, } = options;
|
|
46
|
+
if (isVerbose) {
|
|
47
|
+
(0, util_1.verbose)(true);
|
|
48
|
+
}
|
|
49
|
+
yield (0, validateFile_1.default)('directory', appmapDir);
|
|
50
|
+
const appId = yield (0, resolveAppId_1.default)(appIdArg, appmapDir);
|
|
51
|
+
const scanResults = JSON.parse((yield (0, promises_1.readFile)(reportFile)).toString());
|
|
52
|
+
const uploadResponse = yield (0, upload_1.default)(scanResults, appId, appmapDir, mergeKey, { branch, commit, environment }, {
|
|
53
|
+
maxRetries: 3,
|
|
98
54
|
});
|
|
55
|
+
(0, reportUploadURL_1.default)(uploadResponse.summary.numFindings, uploadResponse.url);
|
|
99
56
|
});
|
|
100
57
|
},
|
|
101
58
|
};
|
|
102
|
-
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pruneAppMap = exports.maxAppMapSize = void 0;
|
|
4
|
+
const models_1 = require("@appland/models");
|
|
5
|
+
const APPMAP_UPLOAD_MAX_SIZE = parseInt(process.env.APPMAP_UPLOAD_MAX_SIZE || '40960') * 1024;
|
|
6
|
+
if (!APPMAP_UPLOAD_MAX_SIZE) {
|
|
7
|
+
throw Error(`Failed parsing APPMAP_UPLOAD_MAX_SIZE: "${process.env.APPMAP_UPLOAD_MAX_SIZE}"`);
|
|
8
|
+
}
|
|
9
|
+
function maxAppMapSize() {
|
|
10
|
+
return APPMAP_UPLOAD_MAX_SIZE;
|
|
11
|
+
}
|
|
12
|
+
exports.maxAppMapSize = maxAppMapSize;
|
|
13
|
+
function pruneAppMap(appMapJson, maxSize) {
|
|
14
|
+
return (0, models_1.buildAppMap)().source(appMapJson).prune(maxSize).normalize().build();
|
|
15
|
+
}
|
|
16
|
+
exports.pruneAppMap = pruneAppMap;
|
package/built/cli/upload.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,173 +8,103 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const async_1 = require("async");
|
|
13
|
+
const promises_1 = require("fs/promises");
|
|
14
|
+
const util_1 = require("../rules/lib/util");
|
|
15
|
+
const create_1 = require("../integration/appland/appMap/create");
|
|
16
|
+
const create_2 = require("../integration/appland/mapset/create");
|
|
17
|
+
const create_3 = require("../integration/appland/scannerJob/create");
|
|
18
|
+
const vars_1 = require("../integration/vars");
|
|
19
|
+
const promises_2 = require("fs/promises");
|
|
20
|
+
const path_1 = require("path");
|
|
21
|
+
const pruneAppMap_1 = require("./upload/pruneAppMap");
|
|
22
|
+
function fileExists(file) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
24
|
try {
|
|
59
|
-
|
|
25
|
+
yield (0, promises_2.stat)(file);
|
|
26
|
+
return true;
|
|
60
27
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
-
if (ar || !(i in from)) {
|
|
68
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
-
ar[i] = from[i];
|
|
28
|
+
catch (e) {
|
|
29
|
+
return false;
|
|
70
30
|
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
-
};
|
|
74
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
-
var async_1 = require("async");
|
|
76
|
-
var promises_1 = require("fs/promises");
|
|
77
|
-
var util_1 = require("../rules/lib/util");
|
|
78
|
-
var create_1 = require("../integration/appland/appMap/create");
|
|
79
|
-
var create_2 = require("../integration/appland/mapset/create");
|
|
80
|
-
var create_3 = require("../integration/appland/scannerJob/create");
|
|
81
|
-
var vars_1 = require("../integration/vars");
|
|
82
|
-
var promises_2 = require("fs/promises");
|
|
83
|
-
var path_1 = require("path");
|
|
84
|
-
function fileExists(file) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var e_1;
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
_a.trys.push([0, 2, , 3]);
|
|
91
|
-
return [4 /*yield*/, (0, promises_2.stat)(file)];
|
|
92
|
-
case 1:
|
|
93
|
-
_a.sent();
|
|
94
|
-
return [2 /*return*/, true];
|
|
95
|
-
case 2:
|
|
96
|
-
e_1 = _a.sent();
|
|
97
|
-
return [2 /*return*/, false];
|
|
98
|
-
case 3: return [2 /*return*/];
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
31
|
});
|
|
102
32
|
}
|
|
103
|
-
function create(scanResults, appId, appMapDir, mergeKey, mapsetOptions, retryOptions) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
}); }, 3);
|
|
164
|
-
q.error(function (err, filePath) {
|
|
165
|
-
console.error("An error occurred uploading ".concat(filePath, ": ").concat(err));
|
|
166
|
-
});
|
|
167
|
-
if ((0, util_1.verbose)())
|
|
168
|
-
console.log("Uploading ".concat(relevantFilePaths.length, " AppMaps"));
|
|
169
|
-
q.push(relevantFilePaths);
|
|
170
|
-
return [4 /*yield*/, q.drain()];
|
|
171
|
-
case 1:
|
|
172
|
-
_a.sent();
|
|
173
|
-
mostFrequent = function (counts) {
|
|
174
|
-
if (Object.keys(counts).length === 0)
|
|
175
|
-
return;
|
|
176
|
-
var maxCount = Object.values(counts).reduce(function (max, count) { return Math.max(max, count); }, 0);
|
|
177
|
-
return Object.entries(counts).find(function (e) { return e[1] === maxCount; })[0];
|
|
178
|
-
};
|
|
179
|
-
mapsetOptions.branch || (mapsetOptions.branch = (0, vars_1.branch)() || mostFrequent(branchCount));
|
|
180
|
-
mapsetOptions.commit || (mapsetOptions.commit = (0, vars_1.sha)() || mostFrequent(commitCount));
|
|
181
|
-
return [4 /*yield*/, (0, create_2.create)(appId, Object.values(appMapUUIDByFileName), mapsetOptions, retryOptions)];
|
|
182
|
-
case 2:
|
|
183
|
-
mapset = _a.sent();
|
|
184
|
-
console.warn('Uploading findings');
|
|
185
|
-
return [2 /*return*/, (0, create_3.create)(scanResults, mapset.id, appMapUUIDByFileName, { mergeKey: mergeKey }, retryOptions)];
|
|
186
|
-
}
|
|
33
|
+
function create(scanResults, appId, appMapDir, mergeKey, mapsetOptions = {}, retryOptions = {}) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if ((0, util_1.verbose)())
|
|
36
|
+
console.log(`Uploading AppMaps and findings to application '${appId}'`);
|
|
37
|
+
const { findings } = scanResults;
|
|
38
|
+
const relevantFilePaths = [
|
|
39
|
+
...new Set(findings.filter((f) => f.appMapFile).map((f) => f.appMapFile)),
|
|
40
|
+
];
|
|
41
|
+
const appMapUUIDByFileName = {};
|
|
42
|
+
const branchCount = {};
|
|
43
|
+
const commitCount = {};
|
|
44
|
+
const createAppMapOptions = {
|
|
45
|
+
app: appId,
|
|
46
|
+
};
|
|
47
|
+
const q = (0, async_1.queue)((filePath, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
if ((0, util_1.verbose)())
|
|
49
|
+
console.log(`Uploading AppMap ${filePath}`);
|
|
50
|
+
const filePaths = [filePath, (0, path_1.join)(appMapDir, filePath)];
|
|
51
|
+
const filePathsExist = yield Promise.all(filePaths.map(fileExists));
|
|
52
|
+
const fullPath = filePaths.find((_, fileIndex) => filePathsExist[fileIndex]);
|
|
53
|
+
if (!fullPath)
|
|
54
|
+
throw new Error(`File ${filePath} not found`);
|
|
55
|
+
(0, promises_1.readFile)(fullPath)
|
|
56
|
+
.then((buffer) => {
|
|
57
|
+
const maxSize = (0, pruneAppMap_1.maxAppMapSize)();
|
|
58
|
+
const appMapJson = JSON.parse(buffer.toString());
|
|
59
|
+
let metadata = appMapJson.metadata;
|
|
60
|
+
if (buffer.byteLength > maxSize) {
|
|
61
|
+
console.warn(`${fullPath} is larger than ${maxSize / 1024}K, pruning it`);
|
|
62
|
+
const prunedAppMap = (0, pruneAppMap_1.pruneAppMap)(appMapJson, maxSize);
|
|
63
|
+
metadata = prunedAppMap.metadata;
|
|
64
|
+
buffer = Buffer.from(JSON.stringify(prunedAppMap));
|
|
65
|
+
}
|
|
66
|
+
return { metadata, buffer };
|
|
67
|
+
})
|
|
68
|
+
.then(({ metadata, buffer }) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const branch = (_a = metadata.git) === null || _a === void 0 ? void 0 : _a.branch;
|
|
71
|
+
const commit = (_b = metadata.git) === null || _b === void 0 ? void 0 : _b.commit;
|
|
72
|
+
if (branch) {
|
|
73
|
+
branchCount[branch] || (branchCount[branch] = 1);
|
|
74
|
+
branchCount[branch] += 1;
|
|
75
|
+
}
|
|
76
|
+
if (commit) {
|
|
77
|
+
commitCount[commit] || (commitCount[commit] = 1);
|
|
78
|
+
commitCount[commit] += 1;
|
|
79
|
+
}
|
|
80
|
+
return (0, create_1.create)(buffer, Object.assign(retryOptions, Object.assign(Object.assign({}, createAppMapOptions), { metadata })));
|
|
81
|
+
})
|
|
82
|
+
.then((appMap) => {
|
|
83
|
+
if (appMap) {
|
|
84
|
+
appMapUUIDByFileName[filePath] = appMap.uuid;
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
.then(() => callback(null))
|
|
88
|
+
.catch(callback);
|
|
89
|
+
}), 3);
|
|
90
|
+
q.error((err, filePath) => {
|
|
91
|
+
console.error(`An error occurred uploading ${filePath}: ${err}`);
|
|
187
92
|
});
|
|
93
|
+
if ((0, util_1.verbose)())
|
|
94
|
+
console.log(`Uploading ${relevantFilePaths.length} AppMaps`);
|
|
95
|
+
q.push(relevantFilePaths);
|
|
96
|
+
yield q.drain();
|
|
97
|
+
const mostFrequent = (counts) => {
|
|
98
|
+
if (Object.keys(counts).length === 0)
|
|
99
|
+
return;
|
|
100
|
+
const maxCount = Object.values(counts).reduce((max, count) => Math.max(max, count), 0);
|
|
101
|
+
return Object.entries(counts).find((e) => e[1] === maxCount)[0];
|
|
102
|
+
};
|
|
103
|
+
mapsetOptions.branch || (mapsetOptions.branch = (0, vars_1.branch)() || mostFrequent(branchCount));
|
|
104
|
+
mapsetOptions.commit || (mapsetOptions.commit = (0, vars_1.sha)() || mostFrequent(commitCount));
|
|
105
|
+
const mapset = yield (0, create_2.create)(appId, Object.values(appMapUUIDByFileName), mapsetOptions, retryOptions);
|
|
106
|
+
console.warn('Uploading findings');
|
|
107
|
+
return (0, create_3.create)(scanResults, mapset.id, appMapUUIDByFileName, { mergeKey }, retryOptions);
|
|
188
108
|
});
|
|
189
109
|
}
|
|
190
110
|
exports.default = create;
|
|
191
|
-
//# sourceMappingURL=upload.js.map
|
|
@@ -8,59 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
15
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
const fs_1 = require("fs");
|
|
17
|
+
const promises_1 = require("fs/promises");
|
|
18
|
+
const errors_1 = require("../errors");
|
|
46
19
|
function default_1(kind, path) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return [3 /*break*/, 3];
|
|
57
|
-
case 2:
|
|
58
|
-
_a = _b.sent();
|
|
59
|
-
throw new errors_1.ValidationError("AppMap ".concat(kind, " ").concat(chalk_1.default.red(path), " does not exist, or is not readable."));
|
|
60
|
-
case 3: return [2 /*return*/];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (path === '.')
|
|
22
|
+
return;
|
|
23
|
+
try {
|
|
24
|
+
yield (0, promises_1.access)(path, fs_1.constants.R_OK);
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
throw new errors_1.ValidationError(`AppMap ${kind} ${chalk_1.default.red(path)} does not exist, or is not readable.`);
|
|
28
|
+
}
|
|
63
29
|
});
|
|
64
30
|
}
|
|
65
31
|
exports.default = default_1;
|
|
66
|
-
//# sourceMappingURL=validateFile.js.map
|
package/built/cli.js
CHANGED
|
@@ -4,14 +4,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
+
const command_1 = __importDefault(require("./cli/scan/command"));
|
|
9
|
+
const command_2 = __importDefault(require("./cli/upload/command"));
|
|
10
|
+
const command_3 = __importDefault(require("./cli/ci/command"));
|
|
11
|
+
const command_4 = __importDefault(require("./cli/merge/command"));
|
|
12
|
+
const util_1 = require("./rules/lib/util");
|
|
13
|
+
const errors_1 = require("./errors");
|
|
14
|
+
const exitCode_1 = require("./cli/exitCode");
|
|
15
|
+
const telemetry_1 = __importDefault(require("./telemetry"));
|
|
16
|
+
function errorInfo(err) {
|
|
17
|
+
if (err instanceof errors_1.ValidationError)
|
|
18
|
+
return { label: 'validation-error', code: exitCode_1.ExitCode.ValidationError };
|
|
19
|
+
else if (err instanceof errors_1.AbortError)
|
|
20
|
+
return { label: 'abort', code: exitCode_1.ExitCode.AbortError };
|
|
21
|
+
else
|
|
22
|
+
return { label: 'error', code: exitCode_1.ExitCode.RuntimeError };
|
|
23
|
+
}
|
|
24
|
+
function handleError(err) {
|
|
25
|
+
const { label, code } = errorInfo(err);
|
|
26
|
+
process.exitCode = code;
|
|
27
|
+
const telemetry = {
|
|
28
|
+
name: [process.argv[2], label].join(':'),
|
|
29
|
+
properties: { error: err.message },
|
|
30
|
+
};
|
|
31
|
+
if (label === 'error')
|
|
32
|
+
telemetry.properties.errorStack = err.stack;
|
|
33
|
+
telemetry_1.default.sendEvent(telemetry);
|
|
34
|
+
}
|
|
15
35
|
(0, yargs_1.default)(process.argv.slice(2))
|
|
16
36
|
.option('verbose', {
|
|
17
37
|
describe: 'Show verbose output',
|
|
@@ -21,7 +41,7 @@ var exitCode_1 = require("./cli/exitCode");
|
|
|
21
41
|
.command(command_2.default)
|
|
22
42
|
.command(command_3.default)
|
|
23
43
|
.command(command_4.default)
|
|
24
|
-
.fail(
|
|
44
|
+
.fail((msg, err, yargs) => {
|
|
25
45
|
if (msg) {
|
|
26
46
|
console.warn(yargs.help());
|
|
27
47
|
console.warn(msg);
|
|
@@ -33,19 +53,12 @@ var exitCode_1 = require("./cli/exitCode");
|
|
|
33
53
|
else {
|
|
34
54
|
console.error(err.message);
|
|
35
55
|
}
|
|
36
|
-
if (err instanceof errors_1.ValidationError) {
|
|
37
|
-
process.exit(exitCode_1.ExitCode.ValidationError);
|
|
38
|
-
}
|
|
39
|
-
if (err instanceof errors_1.AbortError) {
|
|
40
|
-
process.exit(exitCode_1.ExitCode.AbortError);
|
|
41
|
-
}
|
|
42
|
-
if (err instanceof Error) {
|
|
43
|
-
process.exit(exitCode_1.ExitCode.RuntimeError);
|
|
44
|
-
}
|
|
45
56
|
}
|
|
46
|
-
process.
|
|
57
|
+
process.exitCode = exitCode_1.ExitCode.ValidationError;
|
|
47
58
|
})
|
|
59
|
+
.exitProcess(false)
|
|
48
60
|
.strict()
|
|
49
61
|
.demandCommand()
|
|
50
|
-
.help()
|
|
51
|
-
|
|
62
|
+
.help()
|
|
63
|
+
.parseAsync()
|
|
64
|
+
.catch(handleError);
|