eslint-plugin-sonarjs 4.0.1 → 4.0.2
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/README.md +1 -1
- package/cjs/S100/rule.js +7 -5
- package/cjs/S101/rule.js +2 -2
- package/cjs/S104/rule.js +2 -2
- package/cjs/S105/rule.js +2 -2
- package/cjs/S1066/rule.js +5 -4
- package/cjs/S1067/rule.js +8 -6
- package/cjs/S1110/rule.js +7 -5
- package/cjs/S1119/rule.js +2 -2
- package/cjs/S1121/rule.js +4 -3
- package/cjs/S1125/rule.js +9 -8
- package/cjs/S1126/rule.js +2 -2
- package/cjs/S1128/rule.js +8 -5
- package/cjs/S1134/rule.js +2 -2
- package/cjs/S1135/rule.js +2 -2
- package/cjs/S1154/rule.js +6 -4
- package/cjs/S117/rule.js +6 -5
- package/cjs/S1172/rule.js +2 -2
- package/cjs/S1192/rule.js +5 -4
- package/cjs/S1219/rule.js +4 -3
- package/cjs/S1226/rule.js +6 -4
- package/cjs/S124/rule.js +2 -2
- package/cjs/S125/rule.js +9 -7
- package/cjs/S126/rule.js +2 -2
- package/cjs/S1264/rule.js +2 -2
- package/cjs/S128/rule.js +4 -3
- package/cjs/S1291/rule.js +2 -2
- package/cjs/S1301/rule.js +2 -2
- package/cjs/S1313/rule.js +2 -2
- package/cjs/S134/rule.js +7 -5
- package/cjs/S135/rule.js +5 -4
- package/cjs/S138/rule.js +9 -6
- package/cjs/S1439/rule.js +2 -2
- package/cjs/S1444/rule.js +2 -2
- package/cjs/S1451/rule.js +2 -2
- package/cjs/S1472/rule.js +2 -2
- package/cjs/S1479/rule.js +2 -2
- package/cjs/S1481/rule.js +2 -2
- package/cjs/S1488/rule.js +11 -7
- package/cjs/S1515/rule.js +10 -8
- package/cjs/S1523/rule.js +5 -5
- package/cjs/S1526/rule.js +5 -4
- package/cjs/S1527/rule.js +2 -2
- package/cjs/S1528/rule.js +2 -2
- package/cjs/S1529/rule.js +4 -3
- package/cjs/S1530/rule.js +5 -3
- package/cjs/S1533/rule.js +2 -2
- package/cjs/S1535/rule.js +2 -2
- package/cjs/S1541/rule.js +10 -7
- package/cjs/S1607/rule.js +22 -20
- package/cjs/S1764/rule.js +10 -7
- package/cjs/S1821/rule.js +2 -2
- package/cjs/S1848/rule.js +10 -7
- package/cjs/S1854/rule.js +18 -14
- package/cjs/S1862/rule.js +10 -8
- package/cjs/S1871/rule.js +21 -16
- package/cjs/S1874/rule.js +4 -3
- package/cjs/S1940/rule.js +2 -2
- package/cjs/S1994/rule.js +10 -7
- package/cjs/S2004/rule.js +9 -7
- package/cjs/S2068/rule.js +75 -12
- package/cjs/S2077/rule.js +10 -6
- package/cjs/S2092/rule.js +2 -2
- package/cjs/S2123/rule.js +2 -2
- package/cjs/S2137/rule.js +2 -2
- package/cjs/S2138/rule.js +4 -3
- package/cjs/S2187/rule.js +2 -2
- package/cjs/S2201/rule.js +8 -5
- package/cjs/S2208/rule.js +2 -2
- package/cjs/S2234/rule.js +15 -11
- package/cjs/S2245/rule.js +4 -3
- package/cjs/S2251/rule.js +5 -4
- package/cjs/S2255/rule.js +6 -5
- package/cjs/S2259/rule.js +14 -9
- package/cjs/S2301/rule.js +14 -9
- package/cjs/S2310/rule.js +14 -11
- package/cjs/S2392/rule.js +7 -5
- package/cjs/S2424/rule.js +2 -2
- package/cjs/S2428/rule.js +8 -6
- package/cjs/S2486/rule.js +4 -3
- package/cjs/S2589/rule.js +12 -10
- package/cjs/S2598/rule.js +17 -14
- package/cjs/S2612/generated-meta.js +1 -1
- package/cjs/S2612/rule.js +8 -6
- package/cjs/S2639/rule.js +2 -2
- package/cjs/S2681/rule.js +2 -2
- package/cjs/S2692/rule.js +6 -4
- package/cjs/S2699/rule.js +40 -31
- package/cjs/S2703/rule.js +2 -2
- package/cjs/S2737/rule.js +6 -4
- package/cjs/S2755/rule.js +9 -6
- package/cjs/S2757/rule.js +2 -2
- package/cjs/S2817/rule.js +10 -7
- package/cjs/S2819/rule.js +16 -12
- package/cjs/S2870/rule.js +8 -5
- package/cjs/S2871/rule.js +12 -9
- package/cjs/S2970/rule.js +9 -8
- package/cjs/S2990/rule.js +2 -2
- package/cjs/S2999/rule.js +10 -7
- package/cjs/S3001/rule.js +2 -2
- package/cjs/S3003/rule.js +10 -7
- package/cjs/S3317/rule.js +4 -3
- package/cjs/S3330/rule.js +2 -2
- package/cjs/S3358/rule.js +2 -2
- package/cjs/S3402/rule.js +14 -10
- package/cjs/S3403/rule.js +10 -7
- package/cjs/S3415/rule.js +16 -13
- package/cjs/S3499/rule.js +5 -4
- package/cjs/S3500/rule.js +5 -4
- package/cjs/S3513/rule.js +5 -4
- package/cjs/S3514/rule.js +10 -7
- package/cjs/S3516/rule.js +10 -7
- package/cjs/S3524/rule.js +2 -2
- package/cjs/S3525/rule.js +6 -4
- package/cjs/S3531/rule.js +5 -3
- package/cjs/S3533/rule.js +8 -7
- package/cjs/S3579/rule.js +6 -4
- package/cjs/S3616/rule.js +6 -4
- package/cjs/S3626/rule.js +4 -3
- package/cjs/S3686/rule.js +7 -5
- package/cjs/S3699/rule.js +4 -3
- package/cjs/S3735/rule.js +8 -5
- package/cjs/S3757/rule.js +8 -6
- package/cjs/S3758/rule.js +9 -7
- package/cjs/S3760/rule.js +24 -21
- package/cjs/S3776/rule.js +26 -22
- package/cjs/S3782/rule.js +6 -4
- package/cjs/S3785/rule.js +9 -6
- package/cjs/S3796/rule.js +12 -8
- package/cjs/S3798/rule.js +4 -3
- package/cjs/S3800/rule.js +16 -11
- package/cjs/S3801/rule.js +15 -11
- package/cjs/S3827/rule.js +9 -6
- package/cjs/S3923/rule.js +9 -6
- package/cjs/S3972/rule.js +5 -4
- package/cjs/S3973/rule.js +7 -5
- package/cjs/S3981/rule.js +4 -3
- package/cjs/S3984/rule.js +4 -3
- package/cjs/S4030/rule.js +10 -7
- package/cjs/S4036/rule.js +7 -5
- package/cjs/S4043/rule.js +12 -8
- package/cjs/S4139/rule.js +7 -5
- package/cjs/S4143/rule.js +12 -9
- package/cjs/S4144/rule.js +12 -9
- package/cjs/S4158/rule.js +11 -8
- package/cjs/S4165/rule.js +14 -12
- package/cjs/S4322/rule.js +8 -5
- package/cjs/S4323/rule.js +4 -3
- package/cjs/S4324/rule.js +7 -5
- package/cjs/S4328/rule.js +2 -2
- package/cjs/S4335/rule.js +6 -4
- package/cjs/S4423/rule.js +4 -3
- package/cjs/S4423/rule.lib.js +8 -7
- package/cjs/S4426/rule.js +11 -10
- package/cjs/S4502/rule.js +16 -13
- package/cjs/S4507/rule.js +8 -6
- package/cjs/S4524/rule.js +2 -2
- package/cjs/S4619/rule.js +6 -4
- package/cjs/S4621/rule.js +5 -4
- package/cjs/S4622/rule.js +5 -3
- package/cjs/S4623/rule.js +8 -5
- package/cjs/S4624/rule.js +6 -4
- package/cjs/S4634/rule.js +4 -3
- package/cjs/S4721/rule.js +7 -5
- package/cjs/S4782/rule.js +7 -5
- package/cjs/S4784/rule.js +5 -4
- package/cjs/S4787/rule.js +9 -7
- package/cjs/S4790/rule.js +7 -5
- package/cjs/S4798/rule.js +2 -2
- package/cjs/S4817/rule.js +10 -8
- package/cjs/S4818/rule.js +4 -3
- package/cjs/S4822/rule.js +13 -9
- package/cjs/S4823/rule.js +4 -3
- package/cjs/S4829/rule.js +4 -3
- package/cjs/S4830/rule.js +11 -8
- package/cjs/S5042/rule.js +9 -7
- package/cjs/S5122/rule.js +40 -36
- package/cjs/S5148/rule.js +9 -8
- package/cjs/S5247/rule.js +22 -18
- package/cjs/S5256/rule.js +5 -4
- package/cjs/S5257/rule.js +4 -3
- package/cjs/S5260/rule.js +4 -3
- package/cjs/S5264/rule.js +4 -3
- package/cjs/S5332/rule.js +4 -3
- package/cjs/S5332/rule.lib.js +19 -17
- package/cjs/S5443/rule.js +2 -2
- package/cjs/S5527/rule.js +18 -14
- package/cjs/S5542/rule.js +6 -4
- package/cjs/S5547/rule.js +6 -4
- package/cjs/S5604/rule.js +15 -14
- package/cjs/S5659/rule.js +15 -12
- package/cjs/S5689/rule.js +11 -8
- package/cjs/S5691/rule.js +7 -5
- package/cjs/S5693/rule.js +14 -12
- package/cjs/S5725/rule.js +9 -6
- package/cjs/S5728/rule.js +7 -4
- package/cjs/S5730/rule.js +9 -6
- package/cjs/S5732/rule.js +8 -5
- package/cjs/S5734/rule.js +7 -4
- package/cjs/S5736/rule.js +8 -5
- package/cjs/S5739/rule.js +11 -8
- package/cjs/S5742/rule.js +7 -4
- package/cjs/S5743/rule.js +8 -6
- package/cjs/S5757/rule.js +13 -10
- package/cjs/S5759/rule.js +10 -7
- package/cjs/S5842/rule.js +2 -2
- package/cjs/S5843/rule.js +22 -19
- package/cjs/S5850/rule.js +4 -3
- package/cjs/S5852/rule.js +2 -2
- package/cjs/S5856/rule.js +10 -7
- package/cjs/S5860/rule.js +30 -26
- package/cjs/S5863/rule.js +15 -11
- package/cjs/S5867/rule.js +8 -7
- package/cjs/S5868/rule.js +7 -5
- package/cjs/S5869/rule.js +6 -5
- package/cjs/S5876/rule.js +12 -8
- package/cjs/S5958/rule.js +12 -9
- package/cjs/S5973/rule.js +10 -7
- package/cjs/S6019/rule.js +4 -3
- package/cjs/S6035/rule.js +2 -2
- package/cjs/S6079/rule.js +9 -6
- package/cjs/S6080/rule.js +13 -10
- package/cjs/S6092/rule.js +9 -7
- package/cjs/S6245/rule.js +14 -9
- package/cjs/S6249/rule.js +7 -5
- package/cjs/S6252/rule.js +12 -8
- package/cjs/S6265/rule.js +27 -20
- package/cjs/S6268/rule.js +5 -4
- package/cjs/S6270/rule.js +12 -9
- package/cjs/S6275/rule.js +2 -2
- package/cjs/S6281/rule.js +22 -17
- package/cjs/S6299/rule.js +2 -2
- package/cjs/S6302/rule.js +6 -5
- package/cjs/S6303/rule.js +12 -10
- package/cjs/S6304/rule.js +6 -5
- package/cjs/S6308/rule.js +7 -5
- package/cjs/S6317/rule.js +5 -4
- package/cjs/S6319/rule.js +2 -2
- package/cjs/S6321/rule.js +25 -23
- package/cjs/S6323/rule.js +4 -3
- package/cjs/S6324/rule.js +2 -2
- package/cjs/S6326/rule.js +2 -2
- package/cjs/S6327/rule.js +2 -2
- package/cjs/S6328/rule.js +4 -3
- package/cjs/S6329/rule.js +7 -5
- package/cjs/S6330/rule.js +2 -2
- package/cjs/S6332/rule.js +2 -2
- package/cjs/S6333/rule.js +8 -6
- package/cjs/S6351/rule.js +22 -19
- package/cjs/S6353/rule.js +2 -2
- package/cjs/S6397/rule.js +2 -2
- package/cjs/S6418/rule.js +9 -24
- package/cjs/S6426/rule.js +5 -4
- package/cjs/S6437/rule.js +10 -7
- package/cjs/S6439/rule.js +9 -7
- package/cjs/S6442/rule.js +11 -8
- package/cjs/S6443/rule.js +9 -7
- package/cjs/S6486/rule.js +5 -4
- package/cjs/S6564/rule.js +4 -3
- package/cjs/S6594/rule.js +12 -8
- package/cjs/S6627/rule.js +6 -4
- package/cjs/S6759/rule.js +10 -6
- package/cjs/S6958/rule.js +2 -2
- package/cjs/S6959/rule.js +9 -6
- package/cjs/S7059/rule.js +8 -5
- package/cjs/S7639/rule.js +5 -4
- package/cjs/S7790/rule.js +7 -5
- package/cjs/S8441/rule.js +13 -9
- package/cjs/S881/rule.js +2 -2
- package/cjs/S888/rule.js +4 -3
- package/cjs/S930/rule.js +14 -12
- package/cjs/helpers/ast.js +11 -8
- package/cjs/helpers/aws/s3.js +9 -6
- package/cjs/helpers/chai.js +41 -43
- package/cjs/helpers/cookie-flag-check.js +19 -17
- package/cjs/helpers/{decorators/index.js → entropy.js} +16 -17
- package/cjs/helpers/express.js +127 -128
- package/cjs/helpers/mocha.js +50 -54
- package/cjs/helpers/regex/ast.js +7 -6
- package/cjs/helpers/regex/extract.js +11 -11
- package/cjs/helpers/regex/group.js +2 -2
- package/cjs/helpers/regex/location.js +2 -2
- package/cjs/helpers/regex/range.js +5 -4
- package/cjs/helpers/regex/rule-template.js +4 -3
- package/cjs/helpers/sinon.js +33 -36
- package/cjs/helpers/supertest.js +34 -37
- package/cjs/helpers/vitest.js +29 -32
- package/docs/file-permissions.md +1 -1
- package/package.json +39 -1
- package/types/helpers/ancestor.d.ts +1 -1
- package/types/helpers/aws/s3.d.ts +1 -1
- package/types/helpers/chai.d.ts +3 -5
- package/types/helpers/entropy.d.ts +1 -0
- package/types/helpers/express.d.ts +38 -43
- package/types/helpers/mocha.d.ts +19 -21
- package/types/helpers/regex/ast.d.ts +1 -1
- package/types/helpers/regex/rule-template.d.ts +1 -1
- package/types/helpers/sinon.d.ts +3 -5
- package/types/helpers/supertest.d.ts +3 -5
- package/types/helpers/type.d.ts +1 -1
- package/types/helpers/vitest.d.ts +3 -5
- package/cjs/helpers/aws/index.js +0 -35
- package/cjs/helpers/decorators/interceptor.js +0 -88
- package/cjs/helpers/index.js +0 -60
- package/cjs/helpers/recognizers/index.js +0 -37
- package/cjs/helpers/rule-detect-react.js +0 -29
- package/cjs/helpers/validate-version.js +0 -94
- package/types/helpers/aws/index.d.ts +0 -3
- package/types/helpers/decorators/index.d.ts +0 -2
- package/types/helpers/decorators/interceptor.d.ts +0 -16
- package/types/helpers/index.d.ts +0 -28
- package/types/helpers/recognizers/index.d.ts +0 -2
- package/types/helpers/rule-detect-react.d.ts +0 -2
- package/types/helpers/validate-version.d.ts +0 -13
package/cjs/S6270/rule.js
CHANGED
|
@@ -51,7 +51,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
|
+
const module_js_1 = require("../helpers/module.js");
|
|
57
|
+
const location_js_1 = require("../helpers/location.js");
|
|
55
58
|
const result_js_1 = require("../helpers/result.js");
|
|
56
59
|
const iam_js_1 = require("../helpers/aws/iam.js");
|
|
57
60
|
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
@@ -62,22 +65,22 @@ const MESSAGES = {
|
|
|
62
65
|
message: 'Make sure granting public access is safe here.',
|
|
63
66
|
secondary: 'Related effect',
|
|
64
67
|
};
|
|
65
|
-
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(publicAccessStatementChecker, (0,
|
|
68
|
+
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(publicAccessStatementChecker, (0, generate_meta_js_1.generateMeta)(meta));
|
|
66
69
|
function publicAccessStatementChecker(expr, ctx, options) {
|
|
67
70
|
const properties = (0, result_js_1.getResultOfExpression)(ctx, expr);
|
|
68
71
|
const effect = (0, iam_js_1.getSensitiveEffect)(properties, ctx, options);
|
|
69
72
|
const principal = getSensitivePrincipal(properties, ctx, options);
|
|
70
73
|
if (effect.isMissing && principal) {
|
|
71
|
-
(0,
|
|
74
|
+
(0, location_js_1.report)(ctx, {
|
|
72
75
|
message: MESSAGES.message,
|
|
73
76
|
node: principal,
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
else if (effect.isFound && principal) {
|
|
77
|
-
(0,
|
|
80
|
+
(0, location_js_1.report)(ctx, {
|
|
78
81
|
message: MESSAGES.message,
|
|
79
82
|
node: principal,
|
|
80
|
-
}, [(0,
|
|
83
|
+
}, [(0, location_js_1.toSecondaryLocation)(effect.node, MESSAGES.secondary)]);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
function getSensitivePrincipal(properties, ctx, options) {
|
|
@@ -97,7 +100,7 @@ function getSensitivePrincipalFromFullyQualifiedName(ctx, node, options) {
|
|
|
97
100
|
}
|
|
98
101
|
function getPrincipalNewExpressions(node) {
|
|
99
102
|
const newExpressions = [];
|
|
100
|
-
if ((0,
|
|
103
|
+
if ((0, ast_js_1.isArrayExpression)(node)) {
|
|
101
104
|
for (const element of node.elements) {
|
|
102
105
|
if (element?.type === 'NewExpression') {
|
|
103
106
|
newExpressions.push(element);
|
|
@@ -113,16 +116,16 @@ function isSensitivePrincipalNewExpression(ctx, newExpression, options) {
|
|
|
113
116
|
return (options.principals.anyValues ?? []).some(anyValue => {
|
|
114
117
|
if (anyValue === ARN_PRINCIPAL) {
|
|
115
118
|
const argument = newExpression.arguments[0];
|
|
116
|
-
return (0,
|
|
119
|
+
return (0, ast_js_1.isStringLiteral)(argument) && (0, iam_js_1.isAnyLiteral)(argument);
|
|
117
120
|
}
|
|
118
121
|
else {
|
|
119
|
-
return anyValue === (0, cdk_js_1.normalizeFQN)((0,
|
|
122
|
+
return anyValue === (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(ctx, newExpression.callee));
|
|
120
123
|
}
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
126
|
function getPrincipalLiterals(node, ctx) {
|
|
124
127
|
const literals = [];
|
|
125
|
-
if ((0,
|
|
128
|
+
if ((0, ast_js_1.isStringLiteral)(node)) {
|
|
126
129
|
literals.push(node);
|
|
127
130
|
}
|
|
128
131
|
else {
|
package/cjs/S6275/rule.js
CHANGED
|
@@ -52,11 +52,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
54
|
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
55
|
-
const
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
56
|
const meta = __importStar(require("./generated-meta.js"));
|
|
57
57
|
exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
|
|
58
58
|
'aws-cdk-lib.aws-ec2.Volume': (0, cdk_js_1.AwsCdkCheckArguments)(['encryptionOmitted', 'encryptionDisabled'], true, 'encrypted', { primitives: { invalid: [false] } }),
|
|
59
|
-
}, (0,
|
|
59
|
+
}, (0, generate_meta_js_1.generateMeta)(meta, {
|
|
60
60
|
messages: {
|
|
61
61
|
encryptionDisabled: 'Make sure that using unencrypted volumes is safe here.',
|
|
62
62
|
encryptionOmitted: 'Omitting "encrypted" disables volumes encryption. Make sure it is safe here.',
|
package/cjs/S6281/rule.js
CHANGED
|
@@ -51,7 +51,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const s3_js_1 = require("../helpers/aws/s3.js");
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
|
+
const module_js_1 = require("../helpers/module.js");
|
|
57
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
58
|
+
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
59
|
+
const location_js_1 = require("../helpers/location.js");
|
|
55
60
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
61
|
const BLOCK_PUBLIC_ACCESS_KEY = 'blockPublicAccess';
|
|
57
62
|
const BLOCK_PUBLIC_ACCESS_PROPERTY_KEYS = [
|
|
@@ -65,10 +70,10 @@ const messages = {
|
|
|
65
70
|
'to be set on this S3 bucket. Make sure it is safe here.',
|
|
66
71
|
public: 'Make sure allowing public ACL/policies to be set is safe here.',
|
|
67
72
|
};
|
|
68
|
-
exports.rule = (0,
|
|
69
|
-
const blockPublicAccess = (0,
|
|
73
|
+
exports.rule = (0, s3_js_1.S3BucketTemplate)((bucket, context) => {
|
|
74
|
+
const blockPublicAccess = (0, s3_js_1.getBucketProperty)(context, bucket, BLOCK_PUBLIC_ACCESS_KEY);
|
|
70
75
|
if (blockPublicAccess == null) {
|
|
71
|
-
(0,
|
|
76
|
+
(0, location_js_1.report)(context, {
|
|
72
77
|
message: messages['omitted'],
|
|
73
78
|
node: bucket.callee,
|
|
74
79
|
});
|
|
@@ -79,12 +84,12 @@ exports.rule = (0, index_js_1.S3BucketTemplate)((bucket, context) => {
|
|
|
79
84
|
}
|
|
80
85
|
/** Checks `blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS` sensitive pattern */
|
|
81
86
|
function checkBlockPublicAccessValue(blockPublicAccess) {
|
|
82
|
-
const blockPublicAccessMember = (0,
|
|
87
|
+
const blockPublicAccessMember = (0, ast_js_1.getValueOfExpression)(context, blockPublicAccess.value, 'MemberExpression');
|
|
83
88
|
if (blockPublicAccessMember !== undefined &&
|
|
84
|
-
(0,
|
|
89
|
+
(0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(context, blockPublicAccessMember)) ===
|
|
85
90
|
'aws_cdk_lib.aws_s3.BlockPublicAccess.BLOCK_ACLS') {
|
|
86
|
-
const propagated = (0,
|
|
87
|
-
(0,
|
|
91
|
+
const propagated = (0, s3_js_1.findPropagatedSetting)(blockPublicAccess, blockPublicAccessMember);
|
|
92
|
+
(0, location_js_1.report)(context, {
|
|
88
93
|
message: messages['public'],
|
|
89
94
|
node: blockPublicAccess,
|
|
90
95
|
}, propagated ? [propagated] : []);
|
|
@@ -92,12 +97,12 @@ exports.rule = (0, index_js_1.S3BucketTemplate)((bucket, context) => {
|
|
|
92
97
|
}
|
|
93
98
|
/** Checks `blockPublicAccess: new s3.BlockPublicAccess({...})` sensitive pattern */
|
|
94
99
|
function checkBlockPublicAccessConstructor(blockPublicAccess) {
|
|
95
|
-
const blockPublicAccessNew = (0,
|
|
100
|
+
const blockPublicAccessNew = (0, ast_js_1.getValueOfExpression)(context, blockPublicAccess.value, 'NewExpression');
|
|
96
101
|
if (blockPublicAccessNew !== undefined &&
|
|
97
102
|
isS3BlockPublicAccessConstructor(blockPublicAccessNew)) {
|
|
98
|
-
const blockPublicAccessConfig = (0,
|
|
103
|
+
const blockPublicAccessConfig = (0, ast_js_1.getValueOfExpression)(context, blockPublicAccessNew.arguments[0], 'ObjectExpression');
|
|
99
104
|
if (blockPublicAccessConfig === undefined) {
|
|
100
|
-
(0,
|
|
105
|
+
(0, location_js_1.report)(context, {
|
|
101
106
|
message: messages['omitted'],
|
|
102
107
|
node: blockPublicAccessNew,
|
|
103
108
|
});
|
|
@@ -109,12 +114,12 @@ exports.rule = (0, index_js_1.S3BucketTemplate)((bucket, context) => {
|
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
function checkBlockPublicAccessConstructorProperty(blockPublicAccessConfig, key) {
|
|
112
|
-
const blockPublicAccessProperty = blockPublicAccessConfig.properties.find(property => (0,
|
|
117
|
+
const blockPublicAccessProperty = blockPublicAccessConfig.properties.find(property => (0, ast_js_1.isProperty)(property) && (0, ast_js_1.isIdentifier)(property.key, key));
|
|
113
118
|
if (blockPublicAccessProperty !== undefined) {
|
|
114
|
-
const blockPublicAccessValue = (0,
|
|
119
|
+
const blockPublicAccessValue = (0, ast_js_1.getValueOfExpression)(context, blockPublicAccessProperty.value, 'Literal');
|
|
115
120
|
if (blockPublicAccessValue?.value === false) {
|
|
116
|
-
const propagated = (0,
|
|
117
|
-
(0,
|
|
121
|
+
const propagated = (0, s3_js_1.findPropagatedSetting)(blockPublicAccessProperty, blockPublicAccessValue);
|
|
122
|
+
(0, location_js_1.report)(context, {
|
|
118
123
|
message: messages['public'],
|
|
119
124
|
node: blockPublicAccessProperty,
|
|
120
125
|
}, propagated ? [propagated] : []);
|
|
@@ -123,8 +128,8 @@ exports.rule = (0, index_js_1.S3BucketTemplate)((bucket, context) => {
|
|
|
123
128
|
}
|
|
124
129
|
function isS3BlockPublicAccessConstructor(expr) {
|
|
125
130
|
return (expr.callee.type === 'MemberExpression' &&
|
|
126
|
-
(0,
|
|
131
|
+
(0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(context, expr.callee)) ===
|
|
127
132
|
'aws_cdk_lib.aws_s3.BlockPublicAccess');
|
|
128
133
|
}
|
|
129
134
|
}
|
|
130
|
-
}, (0,
|
|
135
|
+
}, (0, generate_meta_js_1.generateMeta)(meta));
|
package/cjs/S6299/rule.js
CHANGED
|
@@ -51,10 +51,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
55
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
56
|
exports.rule = {
|
|
57
|
-
meta: (0,
|
|
57
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
58
58
|
messages: {
|
|
59
59
|
safeVueBypassing: 'Make sure bypassing Vue built-in sanitization is safe here.',
|
|
60
60
|
},
|
package/cjs/S6302/rule.js
CHANGED
|
@@ -53,28 +53,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
exports.rule = void 0;
|
|
54
54
|
const result_js_1 = require("../helpers/result.js");
|
|
55
55
|
const iam_js_1 = require("../helpers/aws/iam.js");
|
|
56
|
-
const
|
|
56
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
57
|
+
const location_js_1 = require("../helpers/location.js");
|
|
57
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
58
59
|
const MESSAGES = {
|
|
59
60
|
message: 'Make sure granting all privileges is safe here.',
|
|
60
61
|
secondary: 'Related effect',
|
|
61
62
|
};
|
|
62
|
-
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(allPrivilegesStatementChecker, (0,
|
|
63
|
+
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(allPrivilegesStatementChecker, (0, generate_meta_js_1.generateMeta)(meta));
|
|
63
64
|
function allPrivilegesStatementChecker(expr, ctx, options) {
|
|
64
65
|
const properties = (0, result_js_1.getResultOfExpression)(ctx, expr);
|
|
65
66
|
const effect = (0, iam_js_1.getSensitiveEffect)(properties, ctx, options);
|
|
66
67
|
const action = getSensitiveAction(properties, options);
|
|
67
68
|
if (effect.isMissing && action) {
|
|
68
|
-
(0,
|
|
69
|
+
(0, location_js_1.report)(ctx, {
|
|
69
70
|
message: MESSAGES.message,
|
|
70
71
|
node: action,
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
else if (effect.isFound && action) {
|
|
74
|
-
(0,
|
|
75
|
+
(0, location_js_1.report)(ctx, {
|
|
75
76
|
message: MESSAGES.message,
|
|
76
77
|
node: action,
|
|
77
|
-
}, [(0,
|
|
78
|
+
}, [(0, location_js_1.toSecondaryLocation)(effect.node, MESSAGES.secondary)]);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
function getSensitiveAction(properties, options) {
|
package/cjs/S6303/rule.js
CHANGED
|
@@ -51,7 +51,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
|
+
const module_js_1 = require("../helpers/module.js");
|
|
56
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
55
57
|
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
56
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
57
59
|
const CfnDBCluster = 'CfnDBCluster';
|
|
@@ -67,7 +69,7 @@ exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
|
|
|
67
69
|
'aws-cdk-lib.aws_rds.DatabaseClusterFromSnapshot': checkStorage(DatabaseClusterFromSnapshot),
|
|
68
70
|
'aws-cdk-lib.aws_rds.DatabaseInstance': checkStorage(DatabaseInstance),
|
|
69
71
|
'aws-cdk-lib.aws_rds.DatabaseInstanceReadReplica': checkStorage(DatabaseInstanceReadReplica),
|
|
70
|
-
}, (0,
|
|
72
|
+
}, (0, generate_meta_js_1.generateMeta)(meta, {
|
|
71
73
|
messages: {
|
|
72
74
|
unsafe: 'Make sure that using unencrypted storage is safe here.',
|
|
73
75
|
omitted: 'Omitting storageEncrypted disables RDS encryption. Make sure it is safe here.',
|
|
@@ -77,7 +79,7 @@ const PROPS_ARGUMENT_POSITION = 2;
|
|
|
77
79
|
function checkStorage(storage) {
|
|
78
80
|
return (expr, ctx) => {
|
|
79
81
|
const argument = expr.arguments[PROPS_ARGUMENT_POSITION];
|
|
80
|
-
const props = (0,
|
|
82
|
+
const props = (0, ast_js_1.getValueOfExpression)(ctx, argument, 'ObjectExpression');
|
|
81
83
|
if (isUnresolved(argument, props)) {
|
|
82
84
|
return;
|
|
83
85
|
}
|
|
@@ -88,20 +90,20 @@ function checkStorage(storage) {
|
|
|
88
90
|
if (isException(storage, props)) {
|
|
89
91
|
return;
|
|
90
92
|
}
|
|
91
|
-
const propertyKey = (0,
|
|
93
|
+
const propertyKey = (0, ast_js_1.getProperty)(props, 'storageEncrypted', ctx);
|
|
92
94
|
if (propertyKey === null) {
|
|
93
95
|
report(props, 'omitted');
|
|
94
96
|
}
|
|
95
97
|
if (!propertyKey) {
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
|
-
const propertyValue = (0,
|
|
99
|
-
if ((0,
|
|
100
|
+
const propertyValue = (0, ast_js_1.getUniqueWriteUsageOrNode)(ctx, propertyKey.value);
|
|
101
|
+
if ((0, ast_js_1.isFalseLiteral)(propertyValue)) {
|
|
100
102
|
report(propertyKey.value, 'unsafe');
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
103
105
|
function isUnresolved(node, value) {
|
|
104
|
-
return node?.type === 'Identifier' && !(0,
|
|
106
|
+
return node?.type === 'Identifier' && !(0, ast_js_1.isUndefined)(node) && value === undefined;
|
|
105
107
|
}
|
|
106
108
|
function isException(storage, props) {
|
|
107
109
|
if (![
|
|
@@ -112,15 +114,15 @@ function checkStorage(storage) {
|
|
|
112
114
|
].includes(storage)) {
|
|
113
115
|
return false;
|
|
114
116
|
}
|
|
115
|
-
const exceptionKey = (0,
|
|
117
|
+
const exceptionKey = (0, ast_js_1.getProperty)(props, 'storageEncryptionKey', ctx);
|
|
116
118
|
if (exceptionKey == null) {
|
|
117
119
|
return false;
|
|
118
120
|
}
|
|
119
|
-
const exceptionValue = (0,
|
|
121
|
+
const exceptionValue = (0, ast_js_1.getUniqueWriteUsageOrNode)(ctx, exceptionKey.value);
|
|
120
122
|
if (exceptionValue.type !== 'NewExpression') {
|
|
121
123
|
return false;
|
|
122
124
|
}
|
|
123
|
-
const fqn = (0, cdk_js_1.normalizeFQN)((0,
|
|
125
|
+
const fqn = (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(ctx, exceptionValue.callee));
|
|
124
126
|
return fqn === 'aws_cdk_lib.aws_kms.Key' || fqn === 'aws_cdk_lib.aws_kms.Alias';
|
|
125
127
|
}
|
|
126
128
|
function report(node, messageId) {
|
package/cjs/S6304/rule.js
CHANGED
|
@@ -51,7 +51,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
|
+
const location_js_1 = require("../helpers/location.js");
|
|
55
56
|
const result_js_1 = require("../helpers/result.js");
|
|
56
57
|
const iam_js_1 = require("../helpers/aws/iam.js");
|
|
57
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
@@ -60,7 +61,7 @@ const MESSAGES = {
|
|
|
60
61
|
secondary: 'Related effect',
|
|
61
62
|
};
|
|
62
63
|
const KMS_PREFIX = 'kms:';
|
|
63
|
-
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(allResourcesAccessibleStatementCheck, (0,
|
|
64
|
+
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(allResourcesAccessibleStatementCheck, (0, generate_meta_js_1.generateMeta)(meta));
|
|
64
65
|
function allResourcesAccessibleStatementCheck(expr, ctx, options) {
|
|
65
66
|
const properties = (0, result_js_1.getResultOfExpression)(ctx, expr);
|
|
66
67
|
const effect = (0, iam_js_1.getSensitiveEffect)(properties, ctx, options);
|
|
@@ -69,16 +70,16 @@ function allResourcesAccessibleStatementCheck(expr, ctx, options) {
|
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
if (effect.isMissing && resource) {
|
|
72
|
-
(0,
|
|
73
|
+
(0, location_js_1.report)(ctx, {
|
|
73
74
|
message: MESSAGES.message,
|
|
74
75
|
node: resource,
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
else if (effect.isFound && resource) {
|
|
78
|
-
(0,
|
|
79
|
+
(0, location_js_1.report)(ctx, {
|
|
79
80
|
message: MESSAGES.message,
|
|
80
81
|
node: resource,
|
|
81
|
-
}, [(0,
|
|
82
|
+
}, [(0, location_js_1.toSecondaryLocation)(effect.node, MESSAGES.secondary)]);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
function isException(properties, options) {
|
package/cjs/S6308/rule.js
CHANGED
|
@@ -52,7 +52,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
54
|
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
55
|
-
const
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
|
+
const module_js_1 = require("../helpers/module.js");
|
|
57
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
56
58
|
const result_js_1 = require("../helpers/result.js");
|
|
57
59
|
const meta = __importStar(require("./generated-meta.js"));
|
|
58
60
|
const DOMAIN_PROPS_POSITION = 2;
|
|
@@ -92,7 +94,7 @@ exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
|
|
|
92
94
|
defaultValue: ELASTIC_SEARCH,
|
|
93
95
|
},
|
|
94
96
|
}),
|
|
95
|
-
}, (0,
|
|
97
|
+
}, (0, generate_meta_js_1.generateMeta)(meta, {
|
|
96
98
|
messages: {
|
|
97
99
|
encryptionDisabled: 'Make sure that using unencrypted {{search}} domains is safe here.',
|
|
98
100
|
encryptionOmitted: 'Omitting {{encryptionPropertyName}} causes encryption of data at rest to be ' +
|
|
@@ -128,11 +130,11 @@ function domainChecker(options) {
|
|
|
128
130
|
}
|
|
129
131
|
function getSearchEngine(node) {
|
|
130
132
|
let version;
|
|
131
|
-
if (options.version.valueType === 'string' && (0,
|
|
133
|
+
if (options.version.valueType === 'string' && (0, ast_js_1.isStringLiteral)(node)) {
|
|
132
134
|
version = `${options.version.property}.${node.value}`;
|
|
133
135
|
}
|
|
134
136
|
else {
|
|
135
|
-
version = (0,
|
|
137
|
+
version = (0, module_js_1.getFullyQualifiedName)(ctx, node);
|
|
136
138
|
}
|
|
137
139
|
for (const name of version?.toLowerCase().split('.').reverse() ?? []) {
|
|
138
140
|
if (name.includes('opensearch')) {
|
|
@@ -147,5 +149,5 @@ function domainChecker(options) {
|
|
|
147
149
|
};
|
|
148
150
|
}
|
|
149
151
|
function isUnencrypted(node) {
|
|
150
|
-
return (0,
|
|
152
|
+
return (0, ast_js_1.isBooleanLiteral)(node) && !node.value;
|
|
151
153
|
}
|
package/cjs/S6317/rule.js
CHANGED
|
@@ -51,7 +51,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
|
+
const location_js_1 = require("../helpers/location.js");
|
|
55
56
|
const result_js_1 = require("../helpers/result.js");
|
|
56
57
|
const iam_js_1 = require("../helpers/aws/iam.js");
|
|
57
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
@@ -89,7 +90,7 @@ const MESSAGES = {
|
|
|
89
90
|
'Remove permissions or restrict the set of resources they apply to.',
|
|
90
91
|
secondary: 'Permissions are granted on all resources.',
|
|
91
92
|
};
|
|
92
|
-
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(privilegeEscalationStatementChecker, (0,
|
|
93
|
+
exports.rule = (0, iam_js_1.AwsIamPolicyTemplate)(privilegeEscalationStatementChecker, (0, generate_meta_js_1.generateMeta)(meta));
|
|
93
94
|
function privilegeEscalationStatementChecker(expr, ctx, options) {
|
|
94
95
|
const properties = (0, result_js_1.getResultOfExpression)(ctx, expr);
|
|
95
96
|
const effect = (0, iam_js_1.getSensitiveEffect)(properties, ctx, options);
|
|
@@ -99,10 +100,10 @@ function privilegeEscalationStatementChecker(expr, ctx, options) {
|
|
|
99
100
|
(effect.isFound || effect.isMissing) &&
|
|
100
101
|
resource &&
|
|
101
102
|
action) {
|
|
102
|
-
(0,
|
|
103
|
+
(0, location_js_1.report)(ctx, {
|
|
103
104
|
message: MESSAGES.message(action.value),
|
|
104
105
|
node: resource,
|
|
105
|
-
}, [(0,
|
|
106
|
+
}, [(0, location_js_1.toSecondaryLocation)(action, MESSAGES.secondary)]);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
function getSensitiveAction(properties, options) {
|
package/cjs/S6319/rule.js
CHANGED
|
@@ -52,11 +52,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
54
|
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
55
|
-
const
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
56
|
const meta = __importStar(require("./generated-meta.js"));
|
|
57
57
|
exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
|
|
58
58
|
'aws-cdk-lib.aws_sagemaker.CfnNotebookInstance': (0, cdk_js_1.AwsCdkCheckArguments)('CfnNotebookInstance', true, 'kmsKeyId'),
|
|
59
|
-
}, (0,
|
|
59
|
+
}, (0, generate_meta_js_1.generateMeta)(meta, {
|
|
60
60
|
messages: {
|
|
61
61
|
CfnNotebookInstance: 'Omitting "kmsKeyId" disables encryption of SageMaker notebook instances. Make sure it is safe here.',
|
|
62
62
|
},
|
package/cjs/S6321/rule.js
CHANGED
|
@@ -52,7 +52,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
54
|
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
55
|
-
const
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
|
+
const module_js_1 = require("../helpers/module.js");
|
|
57
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
56
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
57
59
|
const TYPES_WITH_CONNECTIONS = [
|
|
58
60
|
'aws_cdk_lib.aws_docdb.DatabaseCluster.connections',
|
|
@@ -134,15 +136,15 @@ templateCallback['aws_cdk_lib.aws_ec2.SecurityGroup.addIngressRule'] = {
|
|
|
134
136
|
};
|
|
135
137
|
templateCallback['aws_cdk_lib.aws_ec2.CfnSecurityGroup'] = (expr, ctx) => {
|
|
136
138
|
const params = expr.arguments[2];
|
|
137
|
-
const objExpr = (0,
|
|
139
|
+
const objExpr = (0, ast_js_1.getValueOfExpression)(ctx, params, 'ObjectExpression', true);
|
|
138
140
|
if (!objExpr) {
|
|
139
141
|
return;
|
|
140
142
|
}
|
|
141
|
-
const ingressProp = (0,
|
|
143
|
+
const ingressProp = (0, ast_js_1.getProperty)(objExpr, 'securityGroupIngress', ctx);
|
|
142
144
|
if (!ingressProp) {
|
|
143
145
|
return;
|
|
144
146
|
}
|
|
145
|
-
const arrExpr = (0,
|
|
147
|
+
const arrExpr = (0, ast_js_1.getValueOfExpression)(ctx, ingressProp.value, 'ArrayExpression', true);
|
|
146
148
|
if (arrExpr) {
|
|
147
149
|
for (const ingressGroup of arrExpr.elements) {
|
|
148
150
|
if (ingressGroup) {
|
|
@@ -154,7 +156,7 @@ templateCallback['aws_cdk_lib.aws_ec2.CfnSecurityGroup'] = (expr, ctx) => {
|
|
|
154
156
|
templateCallback['aws_cdk_lib.aws_ec2.CfnSecurityGroupIngress'] = (expr, ctx) => {
|
|
155
157
|
checkIngressObject(ctx, expr.arguments[2]);
|
|
156
158
|
};
|
|
157
|
-
exports.rule = (0, cdk_js_1.AwsCdkTemplate)(templateCallback, (0,
|
|
159
|
+
exports.rule = (0, cdk_js_1.AwsCdkTemplate)(templateCallback, (0, generate_meta_js_1.generateMeta)(meta, {
|
|
158
160
|
messages: {
|
|
159
161
|
allowFromAnyIpv4: 'Change this method for "allowFrom" and set "other" to a subset of trusted IP addresses.',
|
|
160
162
|
allowFrom: 'Change this IP range to a subset of trusted IP addresses.',
|
|
@@ -162,7 +164,7 @@ exports.rule = (0, cdk_js_1.AwsCdkTemplate)(templateCallback, (0, index_js_1.gen
|
|
|
162
164
|
}));
|
|
163
165
|
const invalidDefaultPortChecker = (0, cdk_js_1.AwsCdkCheckArguments)('allowFrom', false, 'defaultPort', { customChecker: isBadEc2Port }, true, 0);
|
|
164
166
|
function checkConstructorDefaultPort(ctx, node) {
|
|
165
|
-
const newExpr = (0,
|
|
167
|
+
const newExpr = (0, ast_js_1.getValueOfExpression)(ctx, (0, module_js_1.reduceToIdentifier)(node.callee), 'NewExpression', true);
|
|
166
168
|
if (newExpr && invalidDefaultPortChecker(newExpr, ctx)) {
|
|
167
169
|
ctx.report({ messageId: 'allowFromAnyIpv4', node: node.callee });
|
|
168
170
|
}
|
|
@@ -181,7 +183,7 @@ function checkAllowFromAnyIpv4(expr, ctx) {
|
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
function checkIngressObject(ctx, node) {
|
|
184
|
-
const objExpr = (0,
|
|
186
|
+
const objExpr = (0, ast_js_1.getValueOfExpression)(ctx, node, 'ObjectExpression', true);
|
|
185
187
|
if (!objExpr) {
|
|
186
188
|
return;
|
|
187
189
|
}
|
|
@@ -202,19 +204,19 @@ function checkIngressObject(ctx, node) {
|
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
function disallowedPortObject(ctx, node) {
|
|
205
|
-
const objExpr = (0,
|
|
207
|
+
const objExpr = (0, ast_js_1.getValueOfExpression)(ctx, node, 'ObjectExpression', true);
|
|
206
208
|
if (!objExpr) {
|
|
207
209
|
return false;
|
|
208
210
|
}
|
|
209
|
-
const protocol = (0,
|
|
211
|
+
const protocol = (0, ast_js_1.getProperty)(objExpr, 'protocol', ctx);
|
|
210
212
|
if (!protocol) {
|
|
211
213
|
return false;
|
|
212
214
|
}
|
|
213
|
-
const protocolValue = (0,
|
|
214
|
-
if ((0,
|
|
215
|
+
const protocolValue = (0, ast_js_1.getUniqueWriteUsageOrNode)(ctx, protocol.value, true);
|
|
216
|
+
if ((0, ast_js_1.isUnresolved)(protocolValue, ctx) || (0, ast_js_1.isUndefined)(protocolValue)) {
|
|
215
217
|
return false;
|
|
216
218
|
}
|
|
217
|
-
const protocolFQN = (0, cdk_js_1.normalizeFQN)((0,
|
|
219
|
+
const protocolFQN = (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(ctx, protocolValue));
|
|
218
220
|
if (protocolFQN && badFQNProtocols.has(protocolFQN)) {
|
|
219
221
|
const fromPort = Number.parseInt(getPropertyValue(ctx, objExpr, 'fromPort')?.value);
|
|
220
222
|
const toPort = Number.parseInt(getPropertyValue(ctx, objExpr, 'toPort')?.value);
|
|
@@ -223,7 +225,7 @@ function disallowedPortObject(ctx, node) {
|
|
|
223
225
|
return false;
|
|
224
226
|
}
|
|
225
227
|
function isBadEc2Peer(ctx, node) {
|
|
226
|
-
const fqn = (0, cdk_js_1.normalizeFQN)((0,
|
|
228
|
+
const fqn = (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(ctx, node));
|
|
227
229
|
if (fqn === 'aws_cdk_lib.aws_ec2.Peer.anyIpv4' || fqn === 'aws_cdk_lib.aws_ec2.Peer.anyIpv6') {
|
|
228
230
|
return true;
|
|
229
231
|
}
|
|
@@ -236,7 +238,7 @@ function isBadEc2Peer(ctx, node) {
|
|
|
236
238
|
return false;
|
|
237
239
|
}
|
|
238
240
|
function isBadEc2Port(ctx, node) {
|
|
239
|
-
const fqn = (0, cdk_js_1.normalizeFQN)((0,
|
|
241
|
+
const fqn = (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(ctx, node));
|
|
240
242
|
if (fqn === 'aws_cdk_lib.aws_ec2.Port.allTcp' || fqn === 'aws_cdk_lib.aws_ec2.Port.allTraffic') {
|
|
241
243
|
return true;
|
|
242
244
|
}
|
|
@@ -257,18 +259,18 @@ function isBadEc2Port(ctx, node) {
|
|
|
257
259
|
return false;
|
|
258
260
|
}
|
|
259
261
|
function getArgument(ctx, node, position = 0) {
|
|
260
|
-
if (!node || (0,
|
|
262
|
+
if (!node || (0, ast_js_1.isUndefined)(node) || (0, ast_js_1.isUnresolved)(node, ctx)) {
|
|
261
263
|
return undefined;
|
|
262
264
|
}
|
|
263
|
-
const callExpr = (0,
|
|
264
|
-
if ((0,
|
|
265
|
-
(0,
|
|
265
|
+
const callExpr = (0, ast_js_1.getUniqueWriteUsageOrNode)(ctx, node, true);
|
|
266
|
+
if ((0, ast_js_1.isUnresolved)(callExpr, ctx) ||
|
|
267
|
+
(0, ast_js_1.isUndefined)(callExpr) ||
|
|
266
268
|
(callExpr.type !== 'CallExpression' && callExpr.type !== 'NewExpression')) {
|
|
267
269
|
return undefined;
|
|
268
270
|
}
|
|
269
271
|
const argument = callExpr.arguments[position];
|
|
270
|
-
const argumentValue = (0,
|
|
271
|
-
if ((0,
|
|
272
|
+
const argumentValue = (0, ast_js_1.getUniqueWriteUsageOrNode)(ctx, argument, true);
|
|
273
|
+
if ((0, ast_js_1.isUnresolved)(argumentValue, ctx) || (0, ast_js_1.isUndefined)(argumentValue)) {
|
|
272
274
|
return undefined;
|
|
273
275
|
}
|
|
274
276
|
return argumentValue;
|
|
@@ -278,12 +280,12 @@ function getArgumentValue(ctx, node, position = 0) {
|
|
|
278
280
|
return argument ? (0, cdk_js_1.getLiteralValue)(ctx, argument) : undefined;
|
|
279
281
|
}
|
|
280
282
|
function getPropertyValue(ctx, node, propertyName) {
|
|
281
|
-
const property = (0,
|
|
283
|
+
const property = (0, ast_js_1.getProperty)(node, propertyName, ctx);
|
|
282
284
|
if (!property) {
|
|
283
285
|
return undefined;
|
|
284
286
|
}
|
|
285
|
-
const propertyValue = (0,
|
|
286
|
-
if ((0,
|
|
287
|
+
const propertyValue = (0, ast_js_1.getUniqueWriteUsageOrNode)(ctx, property.value, true);
|
|
288
|
+
if ((0, ast_js_1.isUnresolved)(propertyValue, ctx) || (0, ast_js_1.isUndefined)(propertyValue)) {
|
|
287
289
|
return undefined;
|
|
288
290
|
}
|
|
289
291
|
return (0, cdk_js_1.getLiteralValue)(ctx, propertyValue);
|
package/cjs/S6323/rule.js
CHANGED
|
@@ -51,7 +51,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
|
+
const collection_js_1 = require("../helpers/collection.js");
|
|
55
56
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
57
|
const rule_template_js_1 = require("../helpers/regex/rule-template.js");
|
|
57
58
|
exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
|
|
@@ -77,10 +78,10 @@ exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
|
|
|
77
78
|
onGroupEnter: checkAlternation,
|
|
78
79
|
onCapturingGroupEnter: checkAlternation,
|
|
79
80
|
};
|
|
80
|
-
}, (0,
|
|
81
|
+
}, (0, generate_meta_js_1.generateMeta)(meta));
|
|
81
82
|
function isLastEmptyInGroup(alt) {
|
|
82
83
|
const group = alt.parent;
|
|
83
84
|
return ((group.type === 'Group' || group.type === 'CapturingGroup') &&
|
|
84
|
-
(0,
|
|
85
|
+
(0, collection_js_1.last)(group.alternatives) === alt &&
|
|
85
86
|
group.parent.type !== 'Quantifier');
|
|
86
87
|
}
|
package/cjs/S6324/rule.js
CHANGED
|
@@ -51,7 +51,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
55
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
56
|
const rule_template_js_1 = require("../helpers/regex/rule-template.js");
|
|
57
57
|
const EXCEPTIONS = new Set(['\t', '\n']);
|
|
@@ -150,7 +150,7 @@ exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
|
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
};
|
|
153
|
-
}, (0,
|
|
153
|
+
}, (0, generate_meta_js_1.generateMeta)(meta));
|
|
154
154
|
/**
|
|
155
155
|
* When the character has been interpreted, we need to compare its
|
|
156
156
|
* code point value.
|
package/cjs/S6326/rule.js
CHANGED
|
@@ -51,7 +51,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
55
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
56
|
const rule_template_js_1 = require("../helpers/regex/rule-template.js");
|
|
57
57
|
const range_js_1 = require("../helpers/regex/range.js");
|
|
@@ -89,7 +89,7 @@ exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
|
-
}, (0,
|
|
92
|
+
}, (0, generate_meta_js_1.generateMeta)(meta, { hasSuggestions: true }));
|
|
93
93
|
function countSpacesBefore(pattern, index) {
|
|
94
94
|
let counter = 0;
|
|
95
95
|
for (let i = index - 1; i > 0; i--) {
|
package/cjs/S6327/rule.js
CHANGED
|
@@ -52,12 +52,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
54
|
const cdk_js_1 = require("../helpers/aws/cdk.js");
|
|
55
|
-
const
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
56
|
const meta = __importStar(require("./generated-meta.js"));
|
|
57
57
|
exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
|
|
58
58
|
'aws-cdk-lib.aws_sns.Topic': (0, cdk_js_1.AwsCdkCheckArguments)('SNSTopic', true, 'masterKey'),
|
|
59
59
|
'aws-cdk-lib.aws_sns.CfnTopic': (0, cdk_js_1.AwsCdkCheckArguments)('SNSCfnTopic', true, 'kmsMasterKeyId'),
|
|
60
|
-
}, (0,
|
|
60
|
+
}, (0, generate_meta_js_1.generateMeta)(meta, {
|
|
61
61
|
messages: {
|
|
62
62
|
SNSTopic: 'Omitting "masterKey" disables SNS topics encryption. Make sure it is safe here.',
|
|
63
63
|
SNSCfnTopic: 'Omitting "kmsMasterKeyId" disables SNS topics encryption. Make sure it is safe here.',
|