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.
Files changed (314) hide show
  1. package/README.md +1 -1
  2. package/cjs/S100/rule.js +7 -5
  3. package/cjs/S101/rule.js +2 -2
  4. package/cjs/S104/rule.js +2 -2
  5. package/cjs/S105/rule.js +2 -2
  6. package/cjs/S1066/rule.js +5 -4
  7. package/cjs/S1067/rule.js +8 -6
  8. package/cjs/S1110/rule.js +7 -5
  9. package/cjs/S1119/rule.js +2 -2
  10. package/cjs/S1121/rule.js +4 -3
  11. package/cjs/S1125/rule.js +9 -8
  12. package/cjs/S1126/rule.js +2 -2
  13. package/cjs/S1128/rule.js +8 -5
  14. package/cjs/S1134/rule.js +2 -2
  15. package/cjs/S1135/rule.js +2 -2
  16. package/cjs/S1154/rule.js +6 -4
  17. package/cjs/S117/rule.js +6 -5
  18. package/cjs/S1172/rule.js +2 -2
  19. package/cjs/S1192/rule.js +5 -4
  20. package/cjs/S1219/rule.js +4 -3
  21. package/cjs/S1226/rule.js +6 -4
  22. package/cjs/S124/rule.js +2 -2
  23. package/cjs/S125/rule.js +9 -7
  24. package/cjs/S126/rule.js +2 -2
  25. package/cjs/S1264/rule.js +2 -2
  26. package/cjs/S128/rule.js +4 -3
  27. package/cjs/S1291/rule.js +2 -2
  28. package/cjs/S1301/rule.js +2 -2
  29. package/cjs/S1313/rule.js +2 -2
  30. package/cjs/S134/rule.js +7 -5
  31. package/cjs/S135/rule.js +5 -4
  32. package/cjs/S138/rule.js +9 -6
  33. package/cjs/S1439/rule.js +2 -2
  34. package/cjs/S1444/rule.js +2 -2
  35. package/cjs/S1451/rule.js +2 -2
  36. package/cjs/S1472/rule.js +2 -2
  37. package/cjs/S1479/rule.js +2 -2
  38. package/cjs/S1481/rule.js +2 -2
  39. package/cjs/S1488/rule.js +11 -7
  40. package/cjs/S1515/rule.js +10 -8
  41. package/cjs/S1523/rule.js +5 -5
  42. package/cjs/S1526/rule.js +5 -4
  43. package/cjs/S1527/rule.js +2 -2
  44. package/cjs/S1528/rule.js +2 -2
  45. package/cjs/S1529/rule.js +4 -3
  46. package/cjs/S1530/rule.js +5 -3
  47. package/cjs/S1533/rule.js +2 -2
  48. package/cjs/S1535/rule.js +2 -2
  49. package/cjs/S1541/rule.js +10 -7
  50. package/cjs/S1607/rule.js +22 -20
  51. package/cjs/S1764/rule.js +10 -7
  52. package/cjs/S1821/rule.js +2 -2
  53. package/cjs/S1848/rule.js +10 -7
  54. package/cjs/S1854/rule.js +18 -14
  55. package/cjs/S1862/rule.js +10 -8
  56. package/cjs/S1871/rule.js +21 -16
  57. package/cjs/S1874/rule.js +4 -3
  58. package/cjs/S1940/rule.js +2 -2
  59. package/cjs/S1994/rule.js +10 -7
  60. package/cjs/S2004/rule.js +9 -7
  61. package/cjs/S2068/rule.js +75 -12
  62. package/cjs/S2077/rule.js +10 -6
  63. package/cjs/S2092/rule.js +2 -2
  64. package/cjs/S2123/rule.js +2 -2
  65. package/cjs/S2137/rule.js +2 -2
  66. package/cjs/S2138/rule.js +4 -3
  67. package/cjs/S2187/rule.js +2 -2
  68. package/cjs/S2201/rule.js +8 -5
  69. package/cjs/S2208/rule.js +2 -2
  70. package/cjs/S2234/rule.js +15 -11
  71. package/cjs/S2245/rule.js +4 -3
  72. package/cjs/S2251/rule.js +5 -4
  73. package/cjs/S2255/rule.js +6 -5
  74. package/cjs/S2259/rule.js +14 -9
  75. package/cjs/S2301/rule.js +14 -9
  76. package/cjs/S2310/rule.js +14 -11
  77. package/cjs/S2392/rule.js +7 -5
  78. package/cjs/S2424/rule.js +2 -2
  79. package/cjs/S2428/rule.js +8 -6
  80. package/cjs/S2486/rule.js +4 -3
  81. package/cjs/S2589/rule.js +12 -10
  82. package/cjs/S2598/rule.js +17 -14
  83. package/cjs/S2612/generated-meta.js +1 -1
  84. package/cjs/S2612/rule.js +8 -6
  85. package/cjs/S2639/rule.js +2 -2
  86. package/cjs/S2681/rule.js +2 -2
  87. package/cjs/S2692/rule.js +6 -4
  88. package/cjs/S2699/rule.js +40 -31
  89. package/cjs/S2703/rule.js +2 -2
  90. package/cjs/S2737/rule.js +6 -4
  91. package/cjs/S2755/rule.js +9 -6
  92. package/cjs/S2757/rule.js +2 -2
  93. package/cjs/S2817/rule.js +10 -7
  94. package/cjs/S2819/rule.js +16 -12
  95. package/cjs/S2870/rule.js +8 -5
  96. package/cjs/S2871/rule.js +12 -9
  97. package/cjs/S2970/rule.js +9 -8
  98. package/cjs/S2990/rule.js +2 -2
  99. package/cjs/S2999/rule.js +10 -7
  100. package/cjs/S3001/rule.js +2 -2
  101. package/cjs/S3003/rule.js +10 -7
  102. package/cjs/S3317/rule.js +4 -3
  103. package/cjs/S3330/rule.js +2 -2
  104. package/cjs/S3358/rule.js +2 -2
  105. package/cjs/S3402/rule.js +14 -10
  106. package/cjs/S3403/rule.js +10 -7
  107. package/cjs/S3415/rule.js +16 -13
  108. package/cjs/S3499/rule.js +5 -4
  109. package/cjs/S3500/rule.js +5 -4
  110. package/cjs/S3513/rule.js +5 -4
  111. package/cjs/S3514/rule.js +10 -7
  112. package/cjs/S3516/rule.js +10 -7
  113. package/cjs/S3524/rule.js +2 -2
  114. package/cjs/S3525/rule.js +6 -4
  115. package/cjs/S3531/rule.js +5 -3
  116. package/cjs/S3533/rule.js +8 -7
  117. package/cjs/S3579/rule.js +6 -4
  118. package/cjs/S3616/rule.js +6 -4
  119. package/cjs/S3626/rule.js +4 -3
  120. package/cjs/S3686/rule.js +7 -5
  121. package/cjs/S3699/rule.js +4 -3
  122. package/cjs/S3735/rule.js +8 -5
  123. package/cjs/S3757/rule.js +8 -6
  124. package/cjs/S3758/rule.js +9 -7
  125. package/cjs/S3760/rule.js +24 -21
  126. package/cjs/S3776/rule.js +26 -22
  127. package/cjs/S3782/rule.js +6 -4
  128. package/cjs/S3785/rule.js +9 -6
  129. package/cjs/S3796/rule.js +12 -8
  130. package/cjs/S3798/rule.js +4 -3
  131. package/cjs/S3800/rule.js +16 -11
  132. package/cjs/S3801/rule.js +15 -11
  133. package/cjs/S3827/rule.js +9 -6
  134. package/cjs/S3923/rule.js +9 -6
  135. package/cjs/S3972/rule.js +5 -4
  136. package/cjs/S3973/rule.js +7 -5
  137. package/cjs/S3981/rule.js +4 -3
  138. package/cjs/S3984/rule.js +4 -3
  139. package/cjs/S4030/rule.js +10 -7
  140. package/cjs/S4036/rule.js +7 -5
  141. package/cjs/S4043/rule.js +12 -8
  142. package/cjs/S4139/rule.js +7 -5
  143. package/cjs/S4143/rule.js +12 -9
  144. package/cjs/S4144/rule.js +12 -9
  145. package/cjs/S4158/rule.js +11 -8
  146. package/cjs/S4165/rule.js +14 -12
  147. package/cjs/S4322/rule.js +8 -5
  148. package/cjs/S4323/rule.js +4 -3
  149. package/cjs/S4324/rule.js +7 -5
  150. package/cjs/S4328/rule.js +2 -2
  151. package/cjs/S4335/rule.js +6 -4
  152. package/cjs/S4423/rule.js +4 -3
  153. package/cjs/S4423/rule.lib.js +8 -7
  154. package/cjs/S4426/rule.js +11 -10
  155. package/cjs/S4502/rule.js +16 -13
  156. package/cjs/S4507/rule.js +8 -6
  157. package/cjs/S4524/rule.js +2 -2
  158. package/cjs/S4619/rule.js +6 -4
  159. package/cjs/S4621/rule.js +5 -4
  160. package/cjs/S4622/rule.js +5 -3
  161. package/cjs/S4623/rule.js +8 -5
  162. package/cjs/S4624/rule.js +6 -4
  163. package/cjs/S4634/rule.js +4 -3
  164. package/cjs/S4721/rule.js +7 -5
  165. package/cjs/S4782/rule.js +7 -5
  166. package/cjs/S4784/rule.js +5 -4
  167. package/cjs/S4787/rule.js +9 -7
  168. package/cjs/S4790/rule.js +7 -5
  169. package/cjs/S4798/rule.js +2 -2
  170. package/cjs/S4817/rule.js +10 -8
  171. package/cjs/S4818/rule.js +4 -3
  172. package/cjs/S4822/rule.js +13 -9
  173. package/cjs/S4823/rule.js +4 -3
  174. package/cjs/S4829/rule.js +4 -3
  175. package/cjs/S4830/rule.js +11 -8
  176. package/cjs/S5042/rule.js +9 -7
  177. package/cjs/S5122/rule.js +40 -36
  178. package/cjs/S5148/rule.js +9 -8
  179. package/cjs/S5247/rule.js +22 -18
  180. package/cjs/S5256/rule.js +5 -4
  181. package/cjs/S5257/rule.js +4 -3
  182. package/cjs/S5260/rule.js +4 -3
  183. package/cjs/S5264/rule.js +4 -3
  184. package/cjs/S5332/rule.js +4 -3
  185. package/cjs/S5332/rule.lib.js +19 -17
  186. package/cjs/S5443/rule.js +2 -2
  187. package/cjs/S5527/rule.js +18 -14
  188. package/cjs/S5542/rule.js +6 -4
  189. package/cjs/S5547/rule.js +6 -4
  190. package/cjs/S5604/rule.js +15 -14
  191. package/cjs/S5659/rule.js +15 -12
  192. package/cjs/S5689/rule.js +11 -8
  193. package/cjs/S5691/rule.js +7 -5
  194. package/cjs/S5693/rule.js +14 -12
  195. package/cjs/S5725/rule.js +9 -6
  196. package/cjs/S5728/rule.js +7 -4
  197. package/cjs/S5730/rule.js +9 -6
  198. package/cjs/S5732/rule.js +8 -5
  199. package/cjs/S5734/rule.js +7 -4
  200. package/cjs/S5736/rule.js +8 -5
  201. package/cjs/S5739/rule.js +11 -8
  202. package/cjs/S5742/rule.js +7 -4
  203. package/cjs/S5743/rule.js +8 -6
  204. package/cjs/S5757/rule.js +13 -10
  205. package/cjs/S5759/rule.js +10 -7
  206. package/cjs/S5842/rule.js +2 -2
  207. package/cjs/S5843/rule.js +22 -19
  208. package/cjs/S5850/rule.js +4 -3
  209. package/cjs/S5852/rule.js +2 -2
  210. package/cjs/S5856/rule.js +10 -7
  211. package/cjs/S5860/rule.js +30 -26
  212. package/cjs/S5863/rule.js +15 -11
  213. package/cjs/S5867/rule.js +8 -7
  214. package/cjs/S5868/rule.js +7 -5
  215. package/cjs/S5869/rule.js +6 -5
  216. package/cjs/S5876/rule.js +12 -8
  217. package/cjs/S5958/rule.js +12 -9
  218. package/cjs/S5973/rule.js +10 -7
  219. package/cjs/S6019/rule.js +4 -3
  220. package/cjs/S6035/rule.js +2 -2
  221. package/cjs/S6079/rule.js +9 -6
  222. package/cjs/S6080/rule.js +13 -10
  223. package/cjs/S6092/rule.js +9 -7
  224. package/cjs/S6245/rule.js +14 -9
  225. package/cjs/S6249/rule.js +7 -5
  226. package/cjs/S6252/rule.js +12 -8
  227. package/cjs/S6265/rule.js +27 -20
  228. package/cjs/S6268/rule.js +5 -4
  229. package/cjs/S6270/rule.js +12 -9
  230. package/cjs/S6275/rule.js +2 -2
  231. package/cjs/S6281/rule.js +22 -17
  232. package/cjs/S6299/rule.js +2 -2
  233. package/cjs/S6302/rule.js +6 -5
  234. package/cjs/S6303/rule.js +12 -10
  235. package/cjs/S6304/rule.js +6 -5
  236. package/cjs/S6308/rule.js +7 -5
  237. package/cjs/S6317/rule.js +5 -4
  238. package/cjs/S6319/rule.js +2 -2
  239. package/cjs/S6321/rule.js +25 -23
  240. package/cjs/S6323/rule.js +4 -3
  241. package/cjs/S6324/rule.js +2 -2
  242. package/cjs/S6326/rule.js +2 -2
  243. package/cjs/S6327/rule.js +2 -2
  244. package/cjs/S6328/rule.js +4 -3
  245. package/cjs/S6329/rule.js +7 -5
  246. package/cjs/S6330/rule.js +2 -2
  247. package/cjs/S6332/rule.js +2 -2
  248. package/cjs/S6333/rule.js +8 -6
  249. package/cjs/S6351/rule.js +22 -19
  250. package/cjs/S6353/rule.js +2 -2
  251. package/cjs/S6397/rule.js +2 -2
  252. package/cjs/S6418/rule.js +9 -24
  253. package/cjs/S6426/rule.js +5 -4
  254. package/cjs/S6437/rule.js +10 -7
  255. package/cjs/S6439/rule.js +9 -7
  256. package/cjs/S6442/rule.js +11 -8
  257. package/cjs/S6443/rule.js +9 -7
  258. package/cjs/S6486/rule.js +5 -4
  259. package/cjs/S6564/rule.js +4 -3
  260. package/cjs/S6594/rule.js +12 -8
  261. package/cjs/S6627/rule.js +6 -4
  262. package/cjs/S6759/rule.js +10 -6
  263. package/cjs/S6958/rule.js +2 -2
  264. package/cjs/S6959/rule.js +9 -6
  265. package/cjs/S7059/rule.js +8 -5
  266. package/cjs/S7639/rule.js +5 -4
  267. package/cjs/S7790/rule.js +7 -5
  268. package/cjs/S8441/rule.js +13 -9
  269. package/cjs/S881/rule.js +2 -2
  270. package/cjs/S888/rule.js +4 -3
  271. package/cjs/S930/rule.js +14 -12
  272. package/cjs/helpers/ast.js +11 -8
  273. package/cjs/helpers/aws/s3.js +9 -6
  274. package/cjs/helpers/chai.js +41 -43
  275. package/cjs/helpers/cookie-flag-check.js +19 -17
  276. package/cjs/helpers/{decorators/index.js → entropy.js} +16 -17
  277. package/cjs/helpers/express.js +127 -128
  278. package/cjs/helpers/mocha.js +50 -54
  279. package/cjs/helpers/regex/ast.js +7 -6
  280. package/cjs/helpers/regex/extract.js +11 -11
  281. package/cjs/helpers/regex/group.js +2 -2
  282. package/cjs/helpers/regex/location.js +2 -2
  283. package/cjs/helpers/regex/range.js +5 -4
  284. package/cjs/helpers/regex/rule-template.js +4 -3
  285. package/cjs/helpers/sinon.js +33 -36
  286. package/cjs/helpers/supertest.js +34 -37
  287. package/cjs/helpers/vitest.js +29 -32
  288. package/docs/file-permissions.md +1 -1
  289. package/package.json +39 -1
  290. package/types/helpers/ancestor.d.ts +1 -1
  291. package/types/helpers/aws/s3.d.ts +1 -1
  292. package/types/helpers/chai.d.ts +3 -5
  293. package/types/helpers/entropy.d.ts +1 -0
  294. package/types/helpers/express.d.ts +38 -43
  295. package/types/helpers/mocha.d.ts +19 -21
  296. package/types/helpers/regex/ast.d.ts +1 -1
  297. package/types/helpers/regex/rule-template.d.ts +1 -1
  298. package/types/helpers/sinon.d.ts +3 -5
  299. package/types/helpers/supertest.d.ts +3 -5
  300. package/types/helpers/type.d.ts +1 -1
  301. package/types/helpers/vitest.d.ts +3 -5
  302. package/cjs/helpers/aws/index.js +0 -35
  303. package/cjs/helpers/decorators/interceptor.js +0 -88
  304. package/cjs/helpers/index.js +0 -60
  305. package/cjs/helpers/recognizers/index.js +0 -37
  306. package/cjs/helpers/rule-detect-react.js +0 -29
  307. package/cjs/helpers/validate-version.js +0 -94
  308. package/types/helpers/aws/index.d.ts +0 -3
  309. package/types/helpers/decorators/index.d.ts +0 -2
  310. package/types/helpers/decorators/interceptor.d.ts +0 -16
  311. package/types/helpers/index.d.ts +0 -28
  312. package/types/helpers/recognizers/index.d.ts +0 -2
  313. package/types/helpers/rule-detect-react.d.ts +0 -2
  314. package/types/helpers/validate-version.d.ts +0 -13
package/cjs/S5257/rule.js CHANGED
@@ -51,10 +51,11 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const accessibility_js_1 = require("../helpers/accessibility.js");
55
56
  const meta = __importStar(require("./generated-meta.js"));
56
57
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta, {
58
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
58
59
  messages: {
59
60
  noLayoutTable: 'Replace this layout table with a CSS layout.',
60
61
  },
@@ -63,7 +64,7 @@ exports.rule = {
63
64
  return {
64
65
  JSXOpeningElement(node) {
65
66
  const jsxNode = node;
66
- if ((0, index_js_1.isPresentationTable)(context, jsxNode)) {
67
+ if ((0, accessibility_js_1.isPresentationTable)(context, jsxNode)) {
67
68
  context.report({
68
69
  node,
69
70
  messageId: 'noLayoutTable',
package/cjs/S5260/rule.js CHANGED
@@ -52,10 +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 table_js_1 = require("../helpers/table.js");
55
- const index_js_1 = require("../helpers/index.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
+ const accessibility_js_1 = require("../helpers/accessibility.js");
56
57
  const meta = __importStar(require("./generated-meta.js"));
57
58
  exports.rule = {
58
- meta: (0, index_js_1.generateMeta)(meta),
59
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
59
60
  create(context) {
60
61
  const verifyHeaderReferences = (tree) => {
61
62
  const grid = (0, table_js_1.computeGrid)(context, tree);
@@ -111,7 +112,7 @@ exports.rule = {
111
112
  return {
112
113
  JSXElement(node) {
113
114
  const tree = node;
114
- const elementType = (0, index_js_1.getElementType)(context)(tree.openingElement);
115
+ const elementType = (0, accessibility_js_1.getElementType)(context)(tree.openingElement);
115
116
  if (elementType === 'table') {
116
117
  verifyHeaderReferences(tree);
117
118
  }
package/cjs/S5264/rule.js CHANGED
@@ -54,18 +54,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
54
54
  };
55
55
  Object.defineProperty(exports, "__esModule", { value: true });
56
56
  exports.rule = void 0;
57
- const index_js_1 = require("../helpers/index.js");
57
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
58
+ const accessibility_js_1 = require("../helpers/accessibility.js");
58
59
  const meta = __importStar(require("./generated-meta.js"));
59
60
  const jsx_ast_utils_x_1 = __importDefault(require("jsx-ast-utils-x"));
60
61
  const { getLiteralPropValue, getProp, getPropValue } = jsx_ast_utils_x_1.default;
61
62
  exports.rule = {
62
- meta: (0, index_js_1.generateMeta)(meta, {
63
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
63
64
  messages: {
64
65
  addContent: 'Add an accessible content to this "<object>" tag.',
65
66
  },
66
67
  }),
67
68
  create(context) {
68
- const elementType = (0, index_js_1.getElementType)(context);
69
+ const elementType = (0, accessibility_js_1.getElementType)(context);
69
70
  function hasVisibleChildren(children) {
70
71
  return children.some((child) => {
71
72
  switch (child.type) {
package/cjs/S5332/rule.js CHANGED
@@ -51,15 +51,16 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const merger_js_1 = require("../helpers/decorators/merger.js");
55
56
  const rule_lib_js_1 = require("./rule.lib.js");
56
57
  const rule_aws_js_1 = require("./rule.aws.js");
57
58
  const meta = __importStar(require("./generated-meta.js"));
58
59
  exports.rule = {
59
- meta: (0, index_js_1.generateMeta)(meta, {
60
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
60
61
  messages: { ...rule_lib_js_1.rule.meta.messages, ...rule_aws_js_1.rule.meta.messages },
61
62
  }),
62
63
  create(context) {
63
- return (0, index_js_1.mergeRules)(rule_lib_js_1.rule.create(context), rule_aws_js_1.rule.create(context));
64
+ return (0, merger_js_1.mergeRules)(rule_lib_js_1.rule.create(context), rule_aws_js_1.rule.create(context));
64
65
  },
65
66
  };
@@ -19,7 +19,9 @@
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.rule = void 0;
21
21
  const node_url_1 = require("node:url");
22
- const index_js_1 = require("../helpers/index.js");
22
+ const module_js_1 = require("../helpers/module.js");
23
+ const ancestor_js_1 = require("../helpers/ancestor.js");
24
+ const ast_js_1 = require("../helpers/ast.js");
23
25
  const cdk_js_1 = require("../helpers/aws/cdk.js");
24
26
  const INSECURE_PROTOCOLS = ['http://', 'ftp://', 'telnet://'];
25
27
  const LOOPBACK_PATTERN = /localhost|127(?:\.\d+){0,2}\.\d+$|\/\/(?:0*:)*?:?0*1$/;
@@ -59,37 +61,37 @@ exports.rule = {
59
61
  if (!firstArg) {
60
62
  return;
61
63
  }
62
- const firstArgValue = (0, index_js_1.getValueOfExpression)(context, firstArg, 'ObjectExpression');
63
- const ses = (0, index_js_1.getProperty)(firstArgValue, 'SES', context);
64
+ const firstArgValue = (0, ast_js_1.getValueOfExpression)(context, firstArg, 'ObjectExpression');
65
+ const ses = (0, ast_js_1.getProperty)(firstArgValue, 'SES', context);
64
66
  if (ses && usesSesCommunication(ses)) {
65
67
  return;
66
68
  }
67
- const secure = (0, index_js_1.getProperty)(firstArgValue, 'secure', context);
69
+ const secure = (0, ast_js_1.getProperty)(firstArgValue, 'secure', context);
68
70
  if (secure && (secure.value.type !== 'Literal' || secure.value.raw !== 'false')) {
69
71
  return;
70
72
  }
71
- const requireTls = (0, index_js_1.getProperty)(firstArgValue, 'requireTLS', context);
73
+ const requireTls = (0, ast_js_1.getProperty)(firstArgValue, 'requireTLS', context);
72
74
  if (requireTls && (requireTls.value.type !== 'Literal' || requireTls.value.raw !== 'false')) {
73
75
  return;
74
76
  }
75
- const port = (0, index_js_1.getProperty)(firstArgValue, 'port', context);
77
+ const port = (0, ast_js_1.getProperty)(firstArgValue, 'port', context);
76
78
  if (port && (port.value.type !== 'Literal' || port.value.raw === '465')) {
77
79
  return;
78
80
  }
79
81
  context.report({ node: callExpression.callee, ...getMessageAndData('http') });
80
82
  }
81
83
  function usesSesCommunication(sesProperty) {
82
- const configuration = (0, index_js_1.getValueOfExpression)(context, sesProperty.value, 'ObjectExpression');
84
+ const configuration = (0, ast_js_1.getValueOfExpression)(context, sesProperty.value, 'ObjectExpression');
83
85
  if (!configuration) {
84
86
  return false;
85
87
  }
86
- const ses = (0, index_js_1.getValueOfExpression)(context, (0, index_js_1.getProperty)(configuration, 'ses', context)?.value, 'NewExpression');
87
- if (!ses || (0, cdk_js_1.normalizeFQN)((0, index_js_1.getFullyQualifiedName)(context, ses)) !== '@aws_sdk.client_ses.SES') {
88
+ const ses = (0, ast_js_1.getValueOfExpression)(context, (0, ast_js_1.getProperty)(configuration, 'ses', context)?.value, 'NewExpression');
89
+ if (!ses || (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(context, ses)) !== '@aws_sdk.client_ses.SES') {
88
90
  return false;
89
91
  }
90
- const aws = (0, index_js_1.getProperty)(configuration, 'aws', context);
92
+ const aws = (0, ast_js_1.getProperty)(configuration, 'aws', context);
91
93
  if (!aws ||
92
- (0, cdk_js_1.normalizeFQN)((0, index_js_1.getFullyQualifiedName)(context, aws.value)) !== '@aws_sdk.client_ses') {
94
+ (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(context, aws.value)) !== '@aws_sdk.client_ses') {
93
95
  return false;
94
96
  }
95
97
  return true;
@@ -98,14 +100,14 @@ exports.rule = {
98
100
  if (callExpression.callee.type === 'MemberExpression' &&
99
101
  callExpression.callee.property.type === 'Identifier' &&
100
102
  callExpression.callee.property.name === 'connect') {
101
- const newExpression = (0, index_js_1.getValueOfExpression)(context, callExpression.callee.object, 'NewExpression');
102
- if (!!newExpression && (0, index_js_1.getFullyQualifiedName)(context, newExpression.callee) === 'ftp') {
103
+ const newExpression = (0, ast_js_1.getValueOfExpression)(context, callExpression.callee.object, 'NewExpression');
104
+ if (!!newExpression && (0, module_js_1.getFullyQualifiedName)(context, newExpression.callee) === 'ftp') {
103
105
  const firstArg = callExpression.arguments.length > 0 ? callExpression.arguments[0] : null;
104
106
  if (!firstArg) {
105
107
  return;
106
108
  }
107
- const firstArgValue = (0, index_js_1.getValueOfExpression)(context, firstArg, 'ObjectExpression');
108
- const secure = (0, index_js_1.getProperty)(firstArgValue, 'secure', context);
109
+ const firstArgValue = (0, ast_js_1.getValueOfExpression)(context, firstArg, 'ObjectExpression');
110
+ const secure = (0, ast_js_1.getProperty)(firstArgValue, 'secure', context);
109
111
  if (secure?.value.type === 'Literal' && secure.value.raw === 'false') {
110
112
  context.report({
111
113
  node: callExpression.callee,
@@ -130,7 +132,7 @@ exports.rule = {
130
132
  }
131
133
  function isExceptionUrl(value, node) {
132
134
  if (INSECURE_PROTOCOLS.includes(value)) {
133
- const parent = (0, index_js_1.getParent)(context, node);
135
+ const parent = (0, ancestor_js_1.getParent)(context, node);
134
136
  return !(parent?.type === 'BinaryExpression' && parent.operator === '+');
135
137
  }
136
138
  return hasExceptionHost(value);
@@ -152,7 +154,7 @@ exports.rule = {
152
154
  },
153
155
  CallExpression: (node) => {
154
156
  const callExpression = node;
155
- if ((0, index_js_1.getFullyQualifiedName)(context, callExpression) === 'nodemailer.createTransport') {
157
+ if ((0, module_js_1.getFullyQualifiedName)(context, callExpression) === 'nodemailer.createTransport') {
156
158
  checkNodemailer(callExpression);
157
159
  }
158
160
  checkCallToFtp(callExpression);
package/cjs/S5443/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 index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
55
  const meta = __importStar(require("./generated-meta.js"));
56
56
  const UNIX_DIRECTORIES = [
57
57
  '/tmp/',
@@ -69,7 +69,7 @@ const UNIX_DIRECTORIES = [
69
69
  const WINDOWS_DIRECTORIES_PATTERN = new RegExp(String.raw `^[^\\]*(\\){1,2}(Windows(\\){1,2}Temp|Temp|TMP)(\\.*|$)`, 'i');
70
70
  const SENSITIVE_ENV_VARIABLES = new Set(['TMPDIR', 'TMP', 'TEMPDIR', 'TEMP']);
71
71
  exports.rule = {
72
- meta: (0, index_js_1.generateMeta)(meta, {
72
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
73
73
  messages: {
74
74
  safeDirectory: 'Make sure publicly writable directories are used safely here.',
75
75
  },
package/cjs/S5527/rule.js CHANGED
@@ -51,10 +51,14 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const location_js_1 = require("../helpers/location.js");
55
+ const ancestor_js_1 = require("../helpers/ancestor.js");
56
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
57
+ const module_js_1 = require("../helpers/module.js");
58
+ const ast_js_1 = require("../helpers/ast.js");
55
59
  const meta = __importStar(require("./generated-meta.js"));
56
60
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta),
61
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
58
62
  create(context) {
59
63
  const MESSAGE = 'Enable server hostname verification on this SSL/TLS connection.';
60
64
  const SECONDARY_MESSAGE = 'Set "rejectUnauthorized" to "true".';
@@ -65,26 +69,26 @@ exports.rule = {
65
69
  const sensitiveArgument = callExpression.arguments[sensitiveArgumentIndex];
66
70
  const secondaryLocations = [];
67
71
  let shouldReport = false;
68
- const argumentValue = (0, index_js_1.getValueOfExpression)(context, sensitiveArgument, 'ObjectExpression');
72
+ const argumentValue = (0, ast_js_1.getValueOfExpression)(context, sensitiveArgument, 'ObjectExpression');
69
73
  if (!argumentValue) {
70
74
  return;
71
75
  }
72
76
  if (sensitiveArgument !== argumentValue) {
73
- secondaryLocations.push((0, index_js_1.toSecondaryLocation)(argumentValue));
77
+ secondaryLocations.push((0, location_js_1.toSecondaryLocation)(argumentValue));
74
78
  }
75
- const unsafeRejectUnauthorizedConfiguration = (0, index_js_1.getPropertyWithValue)(context, argumentValue, 'rejectUnauthorized', false);
79
+ const unsafeRejectUnauthorizedConfiguration = (0, ast_js_1.getPropertyWithValue)(context, argumentValue, 'rejectUnauthorized', false);
76
80
  if (unsafeRejectUnauthorizedConfiguration) {
77
- secondaryLocations.push((0, index_js_1.toSecondaryLocation)(unsafeRejectUnauthorizedConfiguration, SECONDARY_MESSAGE));
81
+ secondaryLocations.push((0, location_js_1.toSecondaryLocation)(unsafeRejectUnauthorizedConfiguration, SECONDARY_MESSAGE));
78
82
  shouldReport = true;
79
83
  }
80
- const checkServerIdentityProperty = (0, index_js_1.getProperty)(argumentValue, 'checkServerIdentity', context);
84
+ const checkServerIdentityProperty = (0, ast_js_1.getProperty)(argumentValue, 'checkServerIdentity', context);
81
85
  if (checkServerIdentityProperty &&
82
86
  shouldReportOnCheckServerIdentityCallBack(checkServerIdentityProperty)) {
83
- secondaryLocations.push((0, index_js_1.toSecondaryLocation)(checkServerIdentityProperty));
87
+ secondaryLocations.push((0, location_js_1.toSecondaryLocation)(checkServerIdentityProperty));
84
88
  shouldReport = true;
85
89
  }
86
90
  if (shouldReport) {
87
- (0, index_js_1.report)(context, {
91
+ (0, location_js_1.report)(context, {
88
92
  node: callExpression.callee,
89
93
  message: MESSAGE,
90
94
  }, secondaryLocations);
@@ -92,12 +96,12 @@ exports.rule = {
92
96
  }
93
97
  function shouldReportOnCheckServerIdentityCallBack(checkServerIdentityProperty) {
94
98
  let baseFunction;
95
- baseFunction = (0, index_js_1.getValueOfExpression)(context, checkServerIdentityProperty.value, 'FunctionExpression');
96
- baseFunction ??= (0, index_js_1.getValueOfExpression)(context, checkServerIdentityProperty.value, 'ArrowFunctionExpression');
99
+ baseFunction = (0, ast_js_1.getValueOfExpression)(context, checkServerIdentityProperty.value, 'FunctionExpression');
100
+ baseFunction ??= (0, ast_js_1.getValueOfExpression)(context, checkServerIdentityProperty.value, 'ArrowFunctionExpression');
97
101
  if (baseFunction?.body.type === 'BlockStatement') {
98
102
  const returnStatements = ReturnStatementsVisitor.getReturnStatements(baseFunction.body, context);
99
103
  if (returnStatements.every(r => {
100
- return (!r.argument || (0, index_js_1.getValueOfExpression)(context, r.argument, 'Literal')?.value === true);
104
+ return (!r.argument || (0, ast_js_1.getValueOfExpression)(context, r.argument, 'Literal')?.value === true);
101
105
  })) {
102
106
  return true;
103
107
  }
@@ -107,7 +111,7 @@ exports.rule = {
107
111
  return {
108
112
  CallExpression: (node) => {
109
113
  const callExpression = node;
110
- const fqn = (0, index_js_1.getFullyQualifiedName)(context, callExpression);
114
+ const fqn = (0, module_js_1.getFullyQualifiedName)(context, callExpression);
111
115
  if (fqn === 'https.request') {
112
116
  checkSensitiveArgument(callExpression, 0);
113
117
  }
@@ -141,7 +145,7 @@ class ReturnStatementsVisitor {
141
145
  case 'ArrowFunctionExpression':
142
146
  return;
143
147
  }
144
- for (const childNode of (0, index_js_1.childrenOf)(node, context.sourceCode.visitorKeys)) {
148
+ for (const childNode of (0, ancestor_js_1.childrenOf)(node, context.sourceCode.visitorKeys)) {
145
149
  visitNode(childNode);
146
150
  }
147
151
  };
package/cjs/S5542/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 index_js_1 = require("../helpers/index.js");
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 meta = __importStar(require("./generated-meta.js"));
56
58
  const aliases = [
57
59
  'AES128',
@@ -75,7 +77,7 @@ const aliases = [
75
77
  'SEED',
76
78
  ];
77
79
  exports.rule = {
78
- meta: (0, index_js_1.generateMeta)(meta, {
80
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
79
81
  messages: {
80
82
  useSecureMode: 'Use a secure mode and padding scheme.',
81
83
  },
@@ -88,11 +90,11 @@ exports.rule = {
88
90
  return {
89
91
  CallExpression: (node) => {
90
92
  const callExpression = node;
91
- if ((0, index_js_1.getFullyQualifiedName)(context, callExpression) !== 'crypto.createCipheriv') {
93
+ if ((0, module_js_1.getFullyQualifiedName)(context, callExpression) !== 'crypto.createCipheriv') {
92
94
  return;
93
95
  }
94
96
  const sensitiveArgument = callExpression.arguments[0];
95
- const sensitiveArgumentValue = (0, index_js_1.getValueOfExpression)(context, sensitiveArgument, 'Literal');
97
+ const sensitiveArgumentValue = (0, ast_js_1.getValueOfExpression)(context, sensitiveArgument, 'Literal');
96
98
  if (!sensitiveArgumentValue) {
97
99
  return;
98
100
  }
package/cjs/S5547/rule.js CHANGED
@@ -51,11 +51,13 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
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 meta = __importStar(require("./generated-meta.js"));
56
58
  const WEAK_CIPHERS = ['bf', 'blowfish', 'des', 'rc2', 'rc4'];
57
59
  exports.rule = {
58
- meta: (0, index_js_1.generateMeta)(meta, {
60
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
59
61
  messages: {
60
62
  strongerCipher: 'Use a strong cipher algorithm.',
61
63
  },
@@ -64,8 +66,8 @@ exports.rule = {
64
66
  return {
65
67
  CallExpression(node) {
66
68
  const callExpression = node;
67
- if ((0, index_js_1.getFullyQualifiedName)(context, callExpression) === 'crypto.createCipheriv') {
68
- const algorithm = (0, index_js_1.getValueOfExpression)(context, callExpression.arguments[0], 'Literal');
69
+ if ((0, module_js_1.getFullyQualifiedName)(context, callExpression) === 'crypto.createCipheriv') {
70
+ const algorithm = (0, ast_js_1.getValueOfExpression)(context, callExpression.arguments[0], 'Literal');
69
71
  const algorithmValue = algorithm?.value?.toString().toLowerCase();
70
72
  if (algorithm &&
71
73
  algorithmValue &&
package/cjs/S5604/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 index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const ast_js_1 = require("../helpers/ast.js");
55
56
  const meta = __importStar(require("./generated-meta.js"));
56
57
  const GEOLOCATION = 'geolocation';
57
58
  const CAMERA = 'camera';
@@ -70,7 +71,7 @@ const messages = {
70
71
  checkPermission: 'Make sure the use of the {{feature}} is necessary.',
71
72
  };
72
73
  exports.rule = {
73
- meta: (0, index_js_1.generateMeta)(meta, { messages }),
74
+ meta: (0, generate_meta_js_1.generateMeta)(meta, { messages }),
74
75
  create(context) {
75
76
  const permissions = context.options[0]?.permissions ?? DEFAULT_PERMISSIONS;
76
77
  return {
@@ -95,12 +96,12 @@ exports.rule = {
95
96
  }
96
97
  if (isNavigatorMemberExpression(callee, 'mediaDevices', 'getUserMedia') &&
97
98
  call.arguments.length > 0) {
98
- const firstArg = (0, index_js_1.getValueOfExpression)(context, call.arguments[0], 'ObjectExpression');
99
+ const firstArg = (0, ast_js_1.getValueOfExpression)(context, call.arguments[0], 'ObjectExpression');
99
100
  checkForCameraAndMicrophonePermissions(context, permissions, callee, firstArg);
100
101
  return;
101
102
  }
102
103
  if (permissions.includes(NOTIFICATIONS) &&
103
- (0, index_js_1.isMemberExpression)(callee, 'Notification', 'requestPermission')) {
104
+ (0, ast_js_1.isMemberExpression)(callee, 'Notification', 'requestPermission')) {
104
105
  context.report({
105
106
  messageId: 'checkPermission',
106
107
  data: {
@@ -111,7 +112,7 @@ exports.rule = {
111
112
  return;
112
113
  }
113
114
  if (permissions.includes(PERSISTENT_STORAGE) &&
114
- (0, index_js_1.isMemberExpression)(callee.object, 'navigator', 'storage')) {
115
+ (0, ast_js_1.isMemberExpression)(callee.object, 'navigator', 'storage')) {
115
116
  context.report({
116
117
  messageId: 'checkPermission',
117
118
  data: {
@@ -123,7 +124,7 @@ exports.rule = {
123
124
  },
124
125
  NewExpression(node) {
125
126
  const { callee } = node;
126
- if (permissions.includes(NOTIFICATIONS) && (0, index_js_1.isIdentifier)(callee, 'Notification')) {
127
+ if (permissions.includes(NOTIFICATIONS) && (0, ast_js_1.isIdentifier)(callee, 'Notification')) {
127
128
  context.report({
128
129
  messageId: 'checkPermission',
129
130
  data: {
@@ -149,10 +150,10 @@ function checkForCameraAndMicrophonePermissions(context, permissions, callee, fi
149
150
  for (const prop of firstArg.properties) {
150
151
  if (prop.type === 'Property') {
151
152
  const { value, key } = prop;
152
- if ((0, index_js_1.isIdentifier)(key, 'audio') && shouldCheckAudio && isOtherThanFalse(context, value)) {
153
+ if ((0, ast_js_1.isIdentifier)(key, 'audio') && shouldCheckAudio && isOtherThanFalse(context, value)) {
153
154
  perms.push('microphone');
154
155
  }
155
- else if ((0, index_js_1.isIdentifier)(key, 'video') &&
156
+ else if ((0, ast_js_1.isIdentifier)(key, 'video') &&
156
157
  shouldCheckVideo &&
157
158
  isOtherThanFalse(context, value)) {
158
159
  perms.push(CAMERA);
@@ -170,14 +171,14 @@ function checkForCameraAndMicrophonePermissions(context, permissions, callee, fi
170
171
  }
171
172
  }
172
173
  function isOtherThanFalse(context, value) {
173
- const exprValue = (0, index_js_1.getValueOfExpression)(context, value, 'Literal');
174
+ const exprValue = (0, ast_js_1.getValueOfExpression)(context, value, 'Literal');
174
175
  if (exprValue?.value === false) {
175
176
  return false;
176
177
  }
177
178
  return true;
178
179
  }
179
180
  function checkPermissions(context, call, permissions) {
180
- const firstArg = (0, index_js_1.getValueOfExpression)(context, call.arguments[0], 'ObjectExpression');
181
+ const firstArg = (0, ast_js_1.getValueOfExpression)(context, call.arguments[0], 'ObjectExpression');
181
182
  if (firstArg?.type === 'ObjectExpression') {
182
183
  const nameProp = firstArg.properties.find(prop => hasNamePropertyWithPermission(prop, context, permissions));
183
184
  if (nameProp) {
@@ -193,12 +194,12 @@ function checkPermissions(context, call, permissions) {
193
194
  }
194
195
  }
195
196
  function isNavigatorMemberExpression({ object, property }, firstProperty, ...secondProperty) {
196
- return ((0, index_js_1.isMemberExpression)(object, 'navigator', firstProperty) &&
197
- (0, index_js_1.isIdentifier)(property, ...secondProperty));
197
+ return ((0, ast_js_1.isMemberExpression)(object, 'navigator', firstProperty) &&
198
+ (0, ast_js_1.isIdentifier)(property, ...secondProperty));
198
199
  }
199
200
  function hasNamePropertyWithPermission(prop, context, permissions) {
200
- if (prop.type === 'Property' && (0, index_js_1.isIdentifier)(prop.key, 'name')) {
201
- const value = (0, index_js_1.getValueOfExpression)(context, prop.value, 'Literal');
201
+ if (prop.type === 'Property' && (0, ast_js_1.isIdentifier)(prop.key, 'name')) {
202
+ const value = (0, ast_js_1.getValueOfExpression)(context, prop.value, 'Literal');
202
203
  return (value &&
203
204
  typeof value.value === 'string' &&
204
205
  supportedPermissions.has(value.value) &&
package/cjs/S5659/rule.js CHANGED
@@ -51,18 +51,21 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
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");
57
+ const location_js_1 = require("../helpers/location.js");
55
58
  const meta = __importStar(require("./generated-meta.js"));
56
59
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta),
60
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
58
61
  create(context) {
59
62
  const SIGN_MESSAGE = 'Use only strong cipher algorithms when signing this JWT.';
60
63
  const VERIFY_MESSAGE = 'Use only strong cipher algorithms when verifying the signature of this JWT.';
61
64
  const SECONDARY_MESSAGE = `The "algorithms" option should be defined and should not contain 'none'.`;
62
65
  function checkCallToSign(callExpression, thirdArgumentValue, secondaryLocations) {
63
- const unsafeAlgorithmProperty = (0, index_js_1.getPropertyWithValue)(context, thirdArgumentValue, 'algorithm', 'none');
66
+ const unsafeAlgorithmProperty = (0, ast_js_1.getPropertyWithValue)(context, thirdArgumentValue, 'algorithm', 'none');
64
67
  if (unsafeAlgorithmProperty) {
65
- const unsafeAlgorithmValue = (0, index_js_1.getValueOfExpression)(context, unsafeAlgorithmProperty.value, 'Literal');
68
+ const unsafeAlgorithmValue = (0, ast_js_1.getValueOfExpression)(context, unsafeAlgorithmProperty.value, 'Literal');
66
69
  if (unsafeAlgorithmValue && unsafeAlgorithmValue !== unsafeAlgorithmProperty.value) {
67
70
  secondaryLocations.push(unsafeAlgorithmValue);
68
71
  }
@@ -70,19 +73,19 @@ exports.rule = {
70
73
  }
71
74
  }
72
75
  function checkCallToVerify(callExpression, publicKey, thirdArgumentValue, secondaryLocations) {
73
- const algorithmsProperty = (0, index_js_1.getProperty)(thirdArgumentValue, 'algorithms', context);
76
+ const algorithmsProperty = (0, ast_js_1.getProperty)(thirdArgumentValue, 'algorithms', context);
74
77
  if (!algorithmsProperty) {
75
- if ((0, index_js_1.isNullLiteral)(publicKey)) {
78
+ if ((0, ast_js_1.isNullLiteral)(publicKey)) {
76
79
  raiseIssueOn(callExpression.callee, VERIFY_MESSAGE, secondaryLocations);
77
80
  }
78
81
  return;
79
82
  }
80
- const algorithmsValue = (0, index_js_1.getValueOfExpression)(context, algorithmsProperty.value, 'ArrayExpression');
83
+ const algorithmsValue = (0, ast_js_1.getValueOfExpression)(context, algorithmsProperty.value, 'ArrayExpression');
81
84
  if (!algorithmsValue) {
82
85
  return;
83
86
  }
84
87
  const algorithmsContainNone = algorithmsValue.elements.some(e => {
85
- const value = (0, index_js_1.getValueOfExpression)(context, e, 'Literal');
88
+ const value = (0, ast_js_1.getValueOfExpression)(context, e, 'Literal');
86
89
  return value?.value === 'none';
87
90
  });
88
91
  if (algorithmsContainNone) {
@@ -93,15 +96,15 @@ exports.rule = {
93
96
  }
94
97
  }
95
98
  function raiseIssueOn(node, message, secondaryLocations) {
96
- (0, index_js_1.report)(context, {
99
+ (0, location_js_1.report)(context, {
97
100
  node,
98
101
  message,
99
- }, secondaryLocations.map(node => (0, index_js_1.toSecondaryLocation)(node, SECONDARY_MESSAGE)));
102
+ }, secondaryLocations.map(node => (0, location_js_1.toSecondaryLocation)(node, SECONDARY_MESSAGE)));
100
103
  }
101
104
  return {
102
105
  CallExpression: (node) => {
103
106
  const callExpression = node;
104
- const fqn = (0, index_js_1.getFullyQualifiedName)(context, callExpression);
107
+ const fqn = (0, module_js_1.getFullyQualifiedName)(context, callExpression);
105
108
  const isCallToSign = fqn === 'jsonwebtoken.sign';
106
109
  const isCallToVerify = fqn === 'jsonwebtoken.verify';
107
110
  if (!isCallToSign && !isCallToVerify) {
@@ -112,7 +115,7 @@ exports.rule = {
112
115
  return;
113
116
  }
114
117
  const thirdArgument = callExpression.arguments[2];
115
- const thirdArgumentValue = (0, index_js_1.getValueOfExpression)(context, thirdArgument, 'ObjectExpression');
118
+ const thirdArgumentValue = (0, ast_js_1.getValueOfExpression)(context, thirdArgument, 'ObjectExpression');
116
119
  if (!thirdArgumentValue) {
117
120
  return;
118
121
  }
package/cjs/S5689/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 index_js_1 = require("../helpers/index.js");
54
+ const express_js_1 = require("../helpers/express.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");
55
58
  const meta = __importStar(require("./generated-meta.js"));
56
59
  const HELMET = 'helmet';
57
60
  const HIDE_POWERED_BY = 'hide-powered-by';
@@ -60,7 +63,7 @@ const PROTECTING_MIDDLEWARES = [HELMET, HIDE_POWERED_BY];
60
63
  /** Expected number of arguments in `app.set`. */
61
64
  const APP_SET_NUM_ARGS = 2;
62
65
  exports.rule = {
63
- meta: (0, index_js_1.generateMeta)(meta, {
66
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
64
67
  messages: {
65
68
  headerSet: 'Make sure disclosing the fingerprinting of this web technology is safe here.',
66
69
  headerDefault: 'This framework implicitly discloses version information by default. Make sure it is safe here.',
@@ -80,7 +83,7 @@ exports.rule = {
80
83
  if (!isSafe && appInstantiation) {
81
84
  const callExpr = node;
82
85
  isSafe =
83
- index_js_1.Express.isUsingMiddleware(context, callExpr, appInstantiation, isProtecting(context)) ||
86
+ (0, express_js_1.isUsingMiddleware)(context, callExpr, appInstantiation, isProtecting(context)) ||
84
87
  isDisabledXPoweredBy(callExpr, appInstantiation) ||
85
88
  isSetFalseXPoweredBy(callExpr, appInstantiation) ||
86
89
  isAppEscaping(callExpr, appInstantiation);
@@ -90,7 +93,7 @@ exports.rule = {
90
93
  VariableDeclarator: (node) => {
91
94
  if (!isSafe && !appInstantiation) {
92
95
  const varDecl = node;
93
- const app = index_js_1.Express.attemptFindAppInstantiation(varDecl, context);
96
+ const app = (0, express_js_1.attemptFindAppInstantiation)(varDecl, context);
94
97
  if (app) {
95
98
  appInstantiation = app;
96
99
  }
@@ -122,16 +125,16 @@ exports.rule = {
122
125
  */
123
126
  function isHidePoweredByFromHelmet(context, n) {
124
127
  if (n.type === 'CallExpression') {
125
- return (0, index_js_1.getFullyQualifiedName)(context, n) === `${HELMET}.hidePoweredBy`;
128
+ return (0, module_js_1.getFullyQualifiedName)(context, n) === `${HELMET}.hidePoweredBy`;
126
129
  }
127
130
  return false;
128
131
  }
129
132
  function isProtecting(context) {
130
- return (n) => index_js_1.Express.isMiddlewareInstance(context, PROTECTING_MIDDLEWARES, n) ||
133
+ return (n) => (0, express_js_1.isMiddlewareInstance)(context, PROTECTING_MIDDLEWARES, n) ||
131
134
  isHidePoweredByFromHelmet(context, n);
132
135
  }
133
136
  function isDisabledXPoweredBy(callExpression, app) {
134
- if ((0, index_js_1.isMethodInvocation)(callExpression, app.name, 'disable', 1)) {
137
+ if ((0, ast_js_1.isMethodInvocation)(callExpression, app.name, 'disable', 1)) {
135
138
  const arg0 = callExpression.arguments[0];
136
139
  return arg0.type === 'Literal' && String(arg0.value).toLowerCase() === HEADER_X_POWERED_BY;
137
140
  }
@@ -144,7 +147,7 @@ function isSetTrueXPoweredBy(callExpression, app) {
144
147
  return getSetTrueXPoweredByValue(callExpression, app) === true;
145
148
  }
146
149
  function getSetTrueXPoweredByValue(callExpression, app) {
147
- if ((0, index_js_1.isMethodInvocation)(callExpression, app.name, 'set', APP_SET_NUM_ARGS)) {
150
+ if ((0, ast_js_1.isMethodInvocation)(callExpression, app.name, 'set', APP_SET_NUM_ARGS)) {
148
151
  const [headerName, onOff] = callExpression.arguments;
149
152
  if (headerName.type === 'Literal' &&
150
153
  String(headerName.value).toLowerCase() === HEADER_X_POWERED_BY &&
package/cjs/S5691/rule.js CHANGED
@@ -51,11 +51,13 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
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 meta = __importStar(require("./generated-meta.js"));
56
58
  const SERVE_STATIC = 'serve-static';
57
59
  exports.rule = {
58
- meta: (0, index_js_1.generateMeta)(meta, {
60
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
59
61
  messages: {
60
62
  safeHiddenFile: 'Make sure serving hidden files is safe here.',
61
63
  },
@@ -65,12 +67,12 @@ exports.rule = {
65
67
  CallExpression(node) {
66
68
  // serveStatic(...)
67
69
  const { callee, arguments: args } = node;
68
- if ((0, index_js_1.getFullyQualifiedName)(context, callee) === SERVE_STATIC && args.length > 1) {
70
+ if ((0, module_js_1.getFullyQualifiedName)(context, callee) === SERVE_STATIC && args.length > 1) {
69
71
  let options = args[1];
70
72
  if (options.type === 'Identifier') {
71
- options = (0, index_js_1.getUniqueWriteUsage)(context, options.name, node);
73
+ options = (0, ast_js_1.getUniqueWriteUsage)(context, options.name, node);
72
74
  }
73
- const dotfilesProperty = (0, index_js_1.getProperty)(options, 'dotfiles', context);
75
+ const dotfilesProperty = (0, ast_js_1.getProperty)(options, 'dotfiles', context);
74
76
  if (dotfilesProperty?.value.type === 'Literal' &&
75
77
  dotfilesProperty.value.value === 'allow') {
76
78
  context.report({ node: dotfilesProperty, messageId: 'safeHiddenFile' });