@appland/scanner 1.56.0 → 1.59.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 +29 -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 +19 -21
- package/built/check.js +17 -21
- 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 +53 -85
- 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 +20 -0
- package/built/cli/upload.js +93 -172
- package/built/cli/validateFile.js +13 -52
- package/built/cli.js +34 -21
- package/built/configuration/configurationProvider.js +151 -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 +35 -128
- package/built/database/visit.js +20 -68
- 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 +50 -72
- 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 +34 -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
|
@@ -3,44 +3,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const matchPattern_1 = require("./lib/matchPattern");
|
|
7
|
+
const url_1 = require("url");
|
|
8
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
9
9
|
// TODO: Use the Query AST for this.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const WHITELIST = [/\bBEGIN\b/i, /\bCOMMIT\b/i, /\bROLLBACK\b/i, /\bRELEASE\b/i, /\bSAVEPOINT\b/i];
|
|
11
|
+
class Options {
|
|
12
|
+
constructor() {
|
|
13
13
|
this.allowedPackages = [];
|
|
14
|
-
this.allowedQueries = WHITELIST.map(
|
|
14
|
+
this.allowedQueries = WHITELIST.map((regexp) => ({ match: regexp }));
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
}());
|
|
16
|
+
}
|
|
18
17
|
function build(options) {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const allowedPackages = (0, matchPattern_1.buildFilters)(options.allowedPackages);
|
|
19
|
+
const allowedQueries = (0, matchPattern_1.buildFilters)(options.allowedQueries);
|
|
21
20
|
function matcher(e) {
|
|
22
|
-
if (!allowedPackages.some(
|
|
21
|
+
if (!allowedPackages.some((filter) => filter(e.parent.codeObject.packageOf))) {
|
|
23
22
|
return [
|
|
24
23
|
{
|
|
25
24
|
event: e,
|
|
26
|
-
message:
|
|
25
|
+
message: `${e.codeObject.id} is invoked from illegal package ${e.parent.codeObject.packageOf}`,
|
|
27
26
|
relatedEvents: [e.parent],
|
|
28
27
|
},
|
|
29
28
|
];
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
function where(e) {
|
|
33
|
-
return !!e.sqlQuery && !!e.parent && !allowedQueries.some(
|
|
32
|
+
return !!e.sqlQuery && !!e.parent && !allowedQueries.some((pattern) => pattern(e.sqlQuery));
|
|
34
33
|
}
|
|
35
34
|
return {
|
|
36
|
-
matcher
|
|
37
|
-
where
|
|
35
|
+
matcher,
|
|
36
|
+
where,
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
exports.default = {
|
|
41
40
|
id: 'query-from-invalid-package',
|
|
42
41
|
title: 'Queries from invalid packages',
|
|
43
|
-
Options
|
|
42
|
+
Options,
|
|
44
43
|
impactDomain: 'Maintainability',
|
|
45
44
|
enumerateScope: true,
|
|
46
45
|
references: {
|
|
@@ -48,6 +47,5 @@ exports.default = {
|
|
|
48
47
|
},
|
|
49
48
|
description: (0, parseRuleDescription_1.default)('queryFromInvalidPackage'),
|
|
50
49
|
url: 'https://appland.com/docs/analysis/rules-reference.html#query-from-invalid-package',
|
|
51
|
-
build
|
|
50
|
+
build,
|
|
52
51
|
};
|
|
53
|
-
//# sourceMappingURL=queryFromInvalidPackage.js.map
|
|
@@ -3,25 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const url_1 = require("url");
|
|
7
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
8
|
+
class Options {
|
|
9
|
+
constructor() {
|
|
10
10
|
this.forbiddenLabel = 'mvc.template';
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function build(options) {
|
|
15
|
-
if (options === void 0) { options = new Options(); }
|
|
12
|
+
}
|
|
13
|
+
function build(options = new Options()) {
|
|
16
14
|
function matcher(e) {
|
|
17
|
-
|
|
15
|
+
const forbiddenAncestor = e
|
|
18
16
|
.ancestors()
|
|
19
|
-
.find(
|
|
17
|
+
.find((e) => e.codeObject.labels.has(options.forbiddenLabel));
|
|
20
18
|
if (forbiddenAncestor) {
|
|
21
19
|
return [
|
|
22
20
|
{
|
|
23
21
|
event: e,
|
|
24
|
-
message:
|
|
22
|
+
message: `SQL query is invoked from invalid event ${forbiddenAncestor}, labeled ${options.forbiddenLabel}`,
|
|
25
23
|
relatedEvents: [forbiddenAncestor],
|
|
26
24
|
},
|
|
27
25
|
];
|
|
@@ -31,14 +29,14 @@ function build(options) {
|
|
|
31
29
|
return !!e.sqlQuery;
|
|
32
30
|
}
|
|
33
31
|
return {
|
|
34
|
-
matcher
|
|
35
|
-
where
|
|
32
|
+
matcher,
|
|
33
|
+
where,
|
|
36
34
|
};
|
|
37
35
|
}
|
|
38
36
|
exports.default = {
|
|
39
37
|
id: 'query-from-view',
|
|
40
38
|
title: 'Queries from view',
|
|
41
|
-
Options
|
|
39
|
+
Options,
|
|
42
40
|
impactDomain: 'Maintainability',
|
|
43
41
|
enumerateScope: true,
|
|
44
42
|
references: {
|
|
@@ -46,6 +44,5 @@ exports.default = {
|
|
|
46
44
|
},
|
|
47
45
|
description: (0, parseRuleDescription_1.default)('queryFromView'),
|
|
48
46
|
url: 'https://appland.com/docs/analysis/rules-reference.html#query-from-view',
|
|
49
|
-
build
|
|
47
|
+
build,
|
|
50
48
|
};
|
|
51
|
-
//# sourceMappingURL=queryFromView.js.map
|
|
@@ -1,104 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
3
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
5
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
|
-
function step(op) {
|
|
7
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
-
while (_) try {
|
|
9
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
|
-
switch (op[0]) {
|
|
12
|
-
case 0: case 1: t = op; break;
|
|
13
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
14
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
16
|
-
default:
|
|
17
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
20
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
21
|
-
if (t[2]) _.ops.pop();
|
|
22
|
-
_.trys.pop(); continue;
|
|
23
|
-
}
|
|
24
|
-
op = body.call(thisArg, _);
|
|
25
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
26
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var __values = (this && this.__values) || function(o) {
|
|
30
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
31
|
-
if (m) return m.call(o);
|
|
32
|
-
if (o && typeof o.length === "number") return {
|
|
33
|
-
next: function () {
|
|
34
|
-
if (o && i >= o.length) o = void 0;
|
|
35
|
-
return { value: o && o[i++], done: !o };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
39
|
-
};
|
|
40
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
4
|
};
|
|
43
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
6
|
+
const models_1 = require("@appland/models");
|
|
7
|
+
const rpcWithoutProtection_1 = require("./lib/rpcWithoutProtection");
|
|
8
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
9
|
+
class Options {
|
|
10
|
+
constructor() {
|
|
49
11
|
this.expectedLabel = RPCCircuitBreaker;
|
|
50
12
|
}
|
|
51
|
-
|
|
52
|
-
}());
|
|
13
|
+
}
|
|
53
14
|
// The circuit breaker will be found in a descendant of the httpClientRequest.
|
|
54
|
-
function descendants(httpClientRequest) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
switch (_d.label) {
|
|
59
|
-
case 0:
|
|
60
|
-
_d.trys.push([0, 5, 6, 7]);
|
|
61
|
-
_a = __values(new models_1.EventNavigator(httpClientRequest).descendants()), _b = _a.next();
|
|
62
|
-
_d.label = 1;
|
|
63
|
-
case 1:
|
|
64
|
-
if (!!_b.done) return [3 /*break*/, 4];
|
|
65
|
-
candidate = _b.value;
|
|
66
|
-
return [4 /*yield*/, candidate.event];
|
|
67
|
-
case 2:
|
|
68
|
-
_d.sent();
|
|
69
|
-
_d.label = 3;
|
|
70
|
-
case 3:
|
|
71
|
-
_b = _a.next();
|
|
72
|
-
return [3 /*break*/, 1];
|
|
73
|
-
case 4: return [3 /*break*/, 7];
|
|
74
|
-
case 5:
|
|
75
|
-
e_1_1 = _d.sent();
|
|
76
|
-
e_1 = { error: e_1_1 };
|
|
77
|
-
return [3 /*break*/, 7];
|
|
78
|
-
case 6:
|
|
79
|
-
try {
|
|
80
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
81
|
-
}
|
|
82
|
-
finally { if (e_1) throw e_1.error; }
|
|
83
|
-
return [7 /*endfinally*/];
|
|
84
|
-
case 7: return [2 /*return*/];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
15
|
+
function* descendants(httpClientRequest) {
|
|
16
|
+
for (const candidate of new models_1.EventNavigator(httpClientRequest).descendants()) {
|
|
17
|
+
yield candidate.event;
|
|
18
|
+
}
|
|
87
19
|
}
|
|
88
|
-
function build(options) {
|
|
89
|
-
if (options === void 0) { options = new Options(); }
|
|
20
|
+
function build(options = new Options()) {
|
|
90
21
|
return (0, rpcWithoutProtection_1.rpcWithoutProtection)(descendants, options);
|
|
91
22
|
}
|
|
92
|
-
|
|
23
|
+
const RPCCircuitBreaker = 'rpc.circuit_breaker';
|
|
93
24
|
exports.default = {
|
|
94
25
|
id: 'rpc-without-circuit-breaker',
|
|
95
26
|
title: 'RPC without circuit breaker',
|
|
96
|
-
Options
|
|
27
|
+
Options,
|
|
97
28
|
labels: [RPCCircuitBreaker],
|
|
98
29
|
impactDomain: 'Stability',
|
|
99
30
|
enumerateScope: true,
|
|
100
31
|
description: (0, parseRuleDescription_1.default)('rpcWithoutCircuitBreaker'),
|
|
101
32
|
url: 'https://appland.com/docs/analysis/rules-reference.html#rpc-without-circuit-breaker',
|
|
102
|
-
build
|
|
33
|
+
build,
|
|
103
34
|
};
|
|
104
|
-
//# sourceMappingURL=rpcWithoutCircuitBreaker.js.map
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const models_1 = require("@appland/models");
|
|
7
|
+
const url_1 = require("url");
|
|
8
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
9
|
+
const validatedBy = (iterator) => {
|
|
10
|
+
let i = iterator.next();
|
|
11
11
|
while (!i.done) {
|
|
12
12
|
if (i.value.event.methodId !== undefined &&
|
|
13
13
|
['valid?', 'validate'].includes(i.value.event.methodId) // TODO: change this to use labels
|
|
@@ -20,8 +20,8 @@ var validatedBy = function (iterator) {
|
|
|
20
20
|
};
|
|
21
21
|
function build() {
|
|
22
22
|
return {
|
|
23
|
-
matcher:
|
|
24
|
-
where:
|
|
23
|
+
matcher: (event) => !validatedBy(new models_1.EventNavigator(event).descendants()),
|
|
24
|
+
where: (e) => e.isFunction && ['save', 'save!'].includes(e.methodId),
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
exports.default = {
|
|
@@ -34,6 +34,5 @@ exports.default = {
|
|
|
34
34
|
},
|
|
35
35
|
description: (0, parseRuleDescription_1.default)('saveWithoutValidation'),
|
|
36
36
|
url: 'https://appland.com/docs/analysis/rules-reference.html#save-without-validation',
|
|
37
|
-
build
|
|
37
|
+
build,
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=saveWithoutValidation.js.map
|
|
@@ -22,114 +22,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
26
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
|
-
if (!m) return o;
|
|
28
|
-
var i = m.call(o), r, ar = [], e;
|
|
29
|
-
try {
|
|
30
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31
|
-
}
|
|
32
|
-
catch (error) { e = { error: error }; }
|
|
33
|
-
finally {
|
|
34
|
-
try {
|
|
35
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
-
}
|
|
37
|
-
finally { if (e) throw e.error; }
|
|
38
|
-
}
|
|
39
|
-
return ar;
|
|
40
|
-
};
|
|
41
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
42
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
43
|
-
if (ar || !(i in from)) {
|
|
44
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
45
|
-
ar[i] = from[i];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
49
|
-
};
|
|
50
|
-
var __values = (this && this.__values) || function(o) {
|
|
51
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
52
|
-
if (m) return m.call(o);
|
|
53
|
-
if (o && typeof o.length === "number") return {
|
|
54
|
-
next: function () {
|
|
55
|
-
if (o && i >= o.length) o = void 0;
|
|
56
|
-
return { value: o && o[i++], done: !o };
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
60
|
-
};
|
|
61
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
27
|
};
|
|
64
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
29
|
+
const secretsRegexes_1 = __importStar(require("../analyzer/secretsRegexes"));
|
|
30
|
+
const util_1 = require("./lib/util");
|
|
31
|
+
const recordSecrets_1 = __importDefault(require("../analyzer/recordSecrets"));
|
|
32
|
+
const url_1 = require("url");
|
|
33
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
34
|
+
class Match {
|
|
35
|
+
constructor(pattern, value) {
|
|
72
36
|
this.pattern = pattern;
|
|
73
37
|
this.value = value;
|
|
74
38
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var findInLog = function (event) {
|
|
79
|
-
var e_1, _a;
|
|
39
|
+
}
|
|
40
|
+
const secrets = new Set();
|
|
41
|
+
const findInLog = (event) => {
|
|
80
42
|
if (!event.parameters)
|
|
81
43
|
return;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var e_2, _d;
|
|
44
|
+
const matches = [];
|
|
45
|
+
for (const { value } of event.parameters) {
|
|
85
46
|
if ((0, util_1.emptyValue)(value))
|
|
86
|
-
|
|
87
|
-
|
|
47
|
+
continue;
|
|
48
|
+
const patterns = [];
|
|
88
49
|
if ((0, secretsRegexes_1.looksSecret)(value)) {
|
|
89
50
|
// Only look for the exact matching regexes if it matches the catchall regex
|
|
90
|
-
patterns.push
|
|
51
|
+
patterns.push(...Object.values(secretsRegexes_1.default)
|
|
91
52
|
.flat()
|
|
92
|
-
.filter(
|
|
53
|
+
.filter((re) => re.test(value)));
|
|
93
54
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (value.includes(secret))
|
|
98
|
-
patterns.push(secret);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
102
|
-
finally {
|
|
103
|
-
try {
|
|
104
|
-
if (secrets_1_1 && !secrets_1_1.done && (_d = secrets_1.return)) _d.call(secrets_1);
|
|
105
|
-
}
|
|
106
|
-
finally { if (e_2) throw e_2.error; }
|
|
107
|
-
}
|
|
108
|
-
matches.push.apply(matches, __spreadArray([], __read(patterns.map(function (pattern) { return new Match(pattern, value); })), false));
|
|
109
|
-
};
|
|
110
|
-
try {
|
|
111
|
-
for (var _b = __values(event.parameters), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
112
|
-
var value = _c.value.value;
|
|
113
|
-
_loop_1(value);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
117
|
-
finally {
|
|
118
|
-
try {
|
|
119
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
55
|
+
for (const secret of secrets) {
|
|
56
|
+
if (value.includes(secret))
|
|
57
|
+
patterns.push(secret);
|
|
120
58
|
}
|
|
121
|
-
|
|
59
|
+
matches.push(...patterns.map((pattern) => new Match(pattern, value)));
|
|
122
60
|
}
|
|
123
61
|
if (matches.length > 0) {
|
|
124
|
-
return matches.map(
|
|
125
|
-
event
|
|
126
|
-
message:
|
|
127
|
-
})
|
|
62
|
+
return matches.map((match) => ({
|
|
63
|
+
event,
|
|
64
|
+
message: `Log event contains secret data: ${match.value}`,
|
|
65
|
+
}));
|
|
128
66
|
}
|
|
129
67
|
};
|
|
130
68
|
function build() {
|
|
131
69
|
return {
|
|
132
|
-
matcher:
|
|
70
|
+
matcher: (e) => {
|
|
133
71
|
if (e.codeObject.labels.has(Secret)) {
|
|
134
72
|
(0, recordSecrets_1.default)(secrets, e);
|
|
135
73
|
}
|
|
@@ -137,13 +75,13 @@ function build() {
|
|
|
137
75
|
return findInLog(e);
|
|
138
76
|
}
|
|
139
77
|
},
|
|
140
|
-
where:
|
|
78
|
+
where: (e) => {
|
|
141
79
|
return e.codeObject.labels.has(Log) || e.codeObject.labels.has(Secret);
|
|
142
80
|
},
|
|
143
81
|
};
|
|
144
82
|
}
|
|
145
|
-
|
|
146
|
-
|
|
83
|
+
const Secret = 'secret';
|
|
84
|
+
const Log = 'log';
|
|
147
85
|
exports.default = {
|
|
148
86
|
id: 'secret-in-log',
|
|
149
87
|
title: 'Secret in log',
|
|
@@ -155,6 +93,5 @@ exports.default = {
|
|
|
155
93
|
},
|
|
156
94
|
description: (0, parseRuleDescription_1.default)('secretInLog'),
|
|
157
95
|
url: 'https://appland.com/docs/analysis/rules-reference.html#secret-in-log',
|
|
158
|
-
build
|
|
96
|
+
build,
|
|
159
97
|
};
|
|
160
|
-
//# sourceMappingURL=secretInLog.js.map
|
|
@@ -3,31 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const matchPattern_1 = require("./lib/matchPattern");
|
|
7
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
8
|
+
class Options {
|
|
9
|
+
constructor() {
|
|
10
10
|
this.functions = [];
|
|
11
11
|
this.timeAllowed = 0.1;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
}());
|
|
13
|
+
}
|
|
15
14
|
function build(options) {
|
|
16
|
-
|
|
15
|
+
const functionPatterns = (0, matchPattern_1.buildFilters)(options.functions || []);
|
|
17
16
|
return {
|
|
18
|
-
matcher:
|
|
17
|
+
matcher: (e) => {
|
|
19
18
|
if (e.returnEvent.elapsedTime > options.timeAllowed) {
|
|
20
|
-
return
|
|
19
|
+
return `Slow ${e.codeObject.id} call (${e.returnEvent.elapsedTime}ms)`;
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
|
-
where:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
functionPatterns.some(function (pattern) { return pattern(e.codeObject.id); }));
|
|
30
|
-
},
|
|
22
|
+
where: (e) => e.isFunction &&
|
|
23
|
+
!!e.returnEvent &&
|
|
24
|
+
!!e.returnEvent.elapsedTime &&
|
|
25
|
+
!!e.codeObject.id &&
|
|
26
|
+
(functionPatterns.length === 0 ||
|
|
27
|
+
functionPatterns.some((pattern) => pattern(e.codeObject.id))),
|
|
31
28
|
};
|
|
32
29
|
}
|
|
33
30
|
exports.default = {
|
|
@@ -38,7 +35,6 @@ exports.default = {
|
|
|
38
35
|
enumerateScope: true,
|
|
39
36
|
description: (0, parseRuleDescription_1.default)('slowFunctionCall'),
|
|
40
37
|
url: 'https://appland.com/docs/analysis/rules-reference.html#slow-function-call',
|
|
41
|
-
Options
|
|
42
|
-
build
|
|
38
|
+
Options,
|
|
39
|
+
build,
|
|
43
40
|
};
|
|
44
|
-
//# sourceMappingURL=slowFunctionCall.js.map
|
|
@@ -3,18 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
7
|
+
class Options {
|
|
8
|
+
constructor() {
|
|
9
9
|
this.timeAllowed = 1;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
}());
|
|
11
|
+
}
|
|
13
12
|
function build(options) {
|
|
14
13
|
return {
|
|
15
|
-
matcher:
|
|
16
|
-
message:
|
|
17
|
-
where:
|
|
14
|
+
matcher: (e) => e.elapsedTime > options.timeAllowed,
|
|
15
|
+
message: () => `Slow HTTP server request (> ${options.timeAllowed * 1000}ms)`,
|
|
16
|
+
where: (e) => !!e.httpServerRequest && e.elapsedTime !== undefined,
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
19
|
exports.default = {
|
|
@@ -25,7 +24,6 @@ exports.default = {
|
|
|
25
24
|
impactDomain: 'Performance',
|
|
26
25
|
description: (0, parseRuleDescription_1.default)('slowHttpServerRequest'),
|
|
27
26
|
url: 'https://appland.com/docs/analysis/rules-reference.html#slow-http-server-request',
|
|
28
|
-
Options
|
|
29
|
-
build
|
|
27
|
+
Options,
|
|
28
|
+
build,
|
|
30
29
|
};
|
|
31
|
-
//# sourceMappingURL=slowHttpServerRequest.js.map
|
package/built/rules/slowQuery.js
CHANGED
|
@@ -3,28 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
7
|
+
class Options {
|
|
8
|
+
constructor() {
|
|
9
9
|
this.timeAllowed = 1;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function build(options) {
|
|
14
|
-
if (options === void 0) { options = new Options(); }
|
|
11
|
+
}
|
|
12
|
+
function build(options = new Options()) {
|
|
15
13
|
return {
|
|
16
|
-
matcher:
|
|
17
|
-
where:
|
|
14
|
+
matcher: (e) => e.elapsedTime > options.timeAllowed,
|
|
15
|
+
where: (e) => !!e.sqlQuery && !!e.elapsedTime,
|
|
18
16
|
};
|
|
19
17
|
}
|
|
20
18
|
exports.default = {
|
|
21
19
|
id: 'slow-query',
|
|
22
20
|
title: 'Slow SQL query',
|
|
23
|
-
Options
|
|
21
|
+
Options,
|
|
24
22
|
impactDomain: 'Performance',
|
|
25
23
|
enumerateScope: true,
|
|
26
24
|
description: (0, parseRuleDescription_1.default)('slowQuery'),
|
|
27
25
|
url: 'https://appland.com/docs/analysis/rules-reference.html#slow-query',
|
|
28
|
-
build
|
|
26
|
+
build,
|
|
29
27
|
};
|
|
30
|
-
//# sourceMappingURL=slowQuery.js.map
|