eslint-plugin-secure-coding 3.4.0 → 3.4.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 (65) hide show
  1. package/README.md +4 -2
  2. package/package.json +5 -18
  3. package/src/index.d.ts +17 -23
  4. package/src/index.js +2 -131
  5. package/src/oxlint.d.ts +17 -20
  6. package/src/oxlint.js +0 -18
  7. package/src/rules/detect-non-literal-regexp/index.js +5 -79
  8. package/src/rules/detect-object-injection/index.js +2 -221
  9. package/src/rules/detect-weak-password-validation/index.js +0 -12
  10. package/src/rules/no-directive-injection/index.js +0 -33
  11. package/src/rules/no-electron-security-issues/index.js +0 -41
  12. package/src/rules/no-format-string-injection/index.js +0 -82
  13. package/src/rules/no-graphql-injection/index.js +8 -133
  14. package/src/rules/no-hardcoded-credentials/index.js +3 -297
  15. package/src/rules/no-hardcoded-session-tokens/index.js +0 -11
  16. package/src/rules/no-improper-sanitization/index.js +0 -44
  17. package/src/rules/no-improper-type-validation/index.js +1 -51
  18. package/src/rules/no-insecure-comparison/index.js +8 -47
  19. package/src/rules/no-ldap-injection/index.js +8 -61
  20. package/src/rules/no-missing-authentication/index.js +2 -56
  21. package/src/rules/no-pii-in-logs/index.js +0 -13
  22. package/src/rules/no-privilege-escalation/index.js +2 -49
  23. package/src/rules/no-redos-vulnerable-regex/index.js +3 -49
  24. package/src/rules/no-sensitive-data-exposure/index.js +5 -29
  25. package/src/rules/no-template-injection/index.js +0 -6
  26. package/src/rules/no-unchecked-loop-condition/index.js +3 -99
  27. package/src/rules/no-unlimited-resource-allocation/index.js +2 -75
  28. package/src/rules/no-unsafe-deserialization/index.js +1 -111
  29. package/src/rules/no-unsafe-regex-construction/index.js +22 -62
  30. package/src/rules/no-weak-password-recovery/index.js +0 -43
  31. package/src/rules/no-xpath-injection/index.js +13 -75
  32. package/src/rules/no-xxe-injection/index.js +1 -47
  33. package/src/rules/require-backend-authorization/index.js +0 -10
  34. package/src/rules/require-secure-defaults/index.js +0 -10
  35. package/src/types/index.js +0 -5
  36. package/AGENTS.md +0 -131
  37. package/CHANGELOG.md +0 -379
  38. package/src/rules/detect-non-literal-regexp/index.d.ts +0 -28
  39. package/src/rules/detect-object-injection/index.d.ts +0 -35
  40. package/src/rules/detect-weak-password-validation/index.d.ts +0 -12
  41. package/src/rules/no-directive-injection/index.d.ts +0 -38
  42. package/src/rules/no-electron-security-issues/index.d.ts +0 -36
  43. package/src/rules/no-format-string-injection/index.d.ts +0 -44
  44. package/src/rules/no-graphql-injection/index.d.ts +0 -47
  45. package/src/rules/no-hardcoded-credentials/index.d.ts +0 -95
  46. package/src/rules/no-hardcoded-session-tokens/index.d.ts +0 -12
  47. package/src/rules/no-improper-sanitization/index.d.ts +0 -38
  48. package/src/rules/no-improper-type-validation/index.d.ts +0 -36
  49. package/src/rules/no-insecure-comparison/index.d.ts +0 -26
  50. package/src/rules/no-ldap-injection/index.d.ts +0 -53
  51. package/src/rules/no-missing-authentication/index.d.ts +0 -32
  52. package/src/rules/no-pii-in-logs/index.d.ts +0 -12
  53. package/src/rules/no-privilege-escalation/index.d.ts +0 -32
  54. package/src/rules/no-redos-vulnerable-regex/index.d.ts +0 -28
  55. package/src/rules/no-sensitive-data-exposure/index.d.ts +0 -30
  56. package/src/rules/no-template-injection/index.d.ts +0 -23
  57. package/src/rules/no-unchecked-loop-condition/index.d.ts +0 -38
  58. package/src/rules/no-unlimited-resource-allocation/index.d.ts +0 -38
  59. package/src/rules/no-unsafe-deserialization/index.d.ts +0 -40
  60. package/src/rules/no-unsafe-regex-construction/index.d.ts +0 -30
  61. package/src/rules/no-weak-password-recovery/index.d.ts +0 -38
  62. package/src/rules/no-xpath-injection/index.d.ts +0 -39
  63. package/src/rules/no-xxe-injection/index.d.ts +0 -36
  64. package/src/rules/require-backend-authorization/index.d.ts +0 -12
  65. package/src/rules/require-secure-defaults/index.d.ts +0 -12
@@ -1,9 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2025 Ofri Peretz
4
- * Licensed under the MIT License. Use of this source code is governed by the
5
- * MIT license that can be found in the LICENSE file.
6
- */
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noGraphqlInjection = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -181,39 +176,29 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
181
176
  const options = context.options[0] || {};
182
177
  const { allowIntrospection = false, maxQueryDepth = 10, trustedGraphqlLibraries = ['graphql', 'apollo-server', 'graphql-tools', 'graphql-tag'], validationFunctions = ['validate', 'sanitize', 'isValid', 'assertValid'], safeTemplateLiteralCallers = [], trustedSanitizers = [], trustedAnnotations = [], strictMode = false, } = options;
183
178
  const filename = context.filename;
184
- // Create safety checker for false positive detection
185
179
  const safetyChecker = (0, eslint_devkit_3.createSafetyChecker)({
186
180
  trustedSanitizers,
187
181
  trustedAnnotations,
188
182
  trustedOrmPatterns: [],
189
183
  strictMode,
190
184
  });
191
- /**
192
- * Check if this is a GraphQL-related operation
193
- */
194
185
  const isGraphqlRelated = (node) => {
195
186
  const callee = node.callee;
196
- // Check for GraphQL library calls
197
187
  if (callee.type === 'Identifier') {
198
188
  return trustedGraphqlLibraries.some(lib => callee.name.toLowerCase().includes(lib.toLowerCase()));
199
189
  }
200
- // Check for member expressions like graphql.parse, apollo.executeQuery
201
190
  if (callee.type === 'MemberExpression' && callee.object.type === 'Identifier') {
202
191
  const objectName = callee.object.name;
203
192
  return trustedGraphqlLibraries.some(lib => objectName.toLowerCase().includes(lib.toLowerCase()));
204
193
  }
205
194
  return false;
206
195
  };
207
- // ─── AST-based safe caller detection ───────────────────────────────
208
- // Hard-coded safe callers that should NEVER contain GraphQL queries.
209
- // Users can extend via safeTemplateLiteralCallers option.
210
196
  const BUILTIN_SAFE_MEMBER_CALLERS = new Set([
211
197
  'console.log', 'console.warn', 'console.error', 'console.info', 'console.debug',
212
198
  'console.trace', 'logger.log', 'logger.info', 'logger.warn', 'logger.error',
213
199
  'logger.debug',
214
200
  ]);
215
201
  const BUILTIN_SAFE_CONSTRUCTORS = new Set(['URL', 'Error', 'TypeError', 'RangeError']);
216
- // Merge user-provided callers
217
202
  const safeMemberCallers = new Set(BUILTIN_SAFE_MEMBER_CALLERS);
218
203
  const safeConstructors = new Set(BUILTIN_SAFE_CONSTRUCTORS);
219
204
  for (const caller of safeTemplateLiteralCallers) {
@@ -224,17 +209,11 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
224
209
  safeConstructors.add(caller);
225
210
  }
226
211
  }
227
- /**
228
- * AST-based check: is this node inside a call that can't be GraphQL?
229
- * Walks up from the TemplateLiteral to its nearest CallExpression/NewExpression parent.
230
- */
231
212
  const isInSafeCallerContext = (node) => {
232
213
  let current = node.parent;
233
214
  while (current) {
234
- // Direct arg to a call: console.log(`...`)
235
215
  if (current.type === 'CallExpression') {
236
216
  const callee = current.callee;
237
- // object.method() pattern
238
217
  if (callee.type === 'MemberExpression' &&
239
218
  callee.object.type === 'Identifier' &&
240
219
  callee.property.type === 'Identifier') {
@@ -242,9 +221,8 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
242
221
  if (safeMemberCallers.has(key))
243
222
  return true;
244
223
  }
245
- break; // Stop at first enclosing call
224
+ break;
246
225
  }
247
- // new URL(`...`), new Error(`...`)
248
226
  if (current.type === eslint_devkit_1.AST_NODE_TYPES.NewExpression) {
249
227
  if (current.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
250
228
  safeConstructors.has(current.callee.name)) {
@@ -252,7 +230,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
252
230
  }
253
231
  break;
254
232
  }
255
- // Don't walk past function boundaries
256
233
  if (current.type === eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression ||
257
234
  current.type === eslint_devkit_1.AST_NODE_TYPES.FunctionExpression ||
258
235
  current.type === eslint_devkit_1.AST_NODE_TYPES.FunctionDeclaration) {
@@ -262,33 +239,16 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
262
239
  }
263
240
  return false;
264
241
  };
265
- // ─── AST-based GraphQL detection helpers ──────────────────────────
266
- // oxlint-disable-next-line consistent-function-scoping
267
242
  const isWordChar = (ch) => {
268
243
  const code = ch.charCodeAt(0);
269
- return (code >= 65 && code <= 90) || // A-Z
270
- (code >= 97 && code <= 122) || // a-z
271
- (code >= 48 && code <= 57) || // 0-9
272
- code === 95; // _
244
+ return (code >= 65 && code <= 90) ||
245
+ (code >= 97 && code <= 122) ||
246
+ (code >= 48 && code <= 57) ||
247
+ code === 95;
273
248
  };
274
- // oxlint-disable-next-line consistent-function-scoping
275
249
  const isWhitespace = (ch) => ch === ' ' || ch === '\n' || ch === '\t' || ch === '\r';
276
- /** Operation keywords that must be followed by optional name + { or ( */
277
250
  const GRAPHQL_OP_KEYWORDS = ['query', 'mutation', 'subscription'];
278
- /** Schema keywords that must be followed by a type name */
279
251
  const GRAPHQL_SCHEMA_KEYWORDS = ['type', 'interface', 'enum', 'scalar', 'input'];
280
- /**
281
- * A GraphQL document declares its operations and type definitions at the
282
- * START of a line. An English sentence mentions them mid-clause.
283
- *
284
- * Without this, the keyword scan matched `type` (and `input`, `enum`, ...)
285
- * anywhere in any string, which is how ordinary message templates became
286
- * CVSS 9.8 GraphQL-injection findings on a 1,470-file corpus:
287
- * `Please specify --type ${a} or ${b}` (ack-nestjs-boilerplate)
288
- * `Invalid type annotation` (generic)
289
- * 24 of 41 corpus findings came from this one relaxation.
290
- */
291
- // oxlint-disable-next-line consistent-function-scoping
292
252
  const isAtLineStart = (text, idx) => {
293
253
  for (let i = idx - 1; i >= 0; i--) {
294
254
  const ch = text[i];
@@ -299,14 +259,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
299
259
  }
300
260
  return true;
301
261
  };
302
- /**
303
- * A bare selection set (`{ users { name } }`) is only a GraphQL document
304
- * when it IS the whole string. Nested braces appearing inside a larger
305
- * message or a generated-code template are not selection sets — that is
306
- * webpack's `resolve.fallback: { "${request}": ... }` and every other
307
- * brace-bearing message string in the corpus (17 of 41 findings).
308
- */
309
- // oxlint-disable-next-line consistent-function-scoping
310
262
  const isStandaloneSelectionSet = (text) => {
311
263
  const trimmed = text.trim();
312
264
  if (!trimmed.startsWith('{') || !trimmed.endsWith('}'))
@@ -324,21 +276,8 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
324
276
  }
325
277
  return false;
326
278
  };
327
- /**
328
- * Find keyword at word boundary in text. Returns index or -1.
329
- * Uses simple character checks instead of regex \b.
330
- */
331
- // NOTE: this loop always terminates via one of its two internal `return`
332
- // statements: `text.indexOf` eventually returns -1 for any finite input,
333
- // and each successful-but-boundary-failing match only advances `pos` by 1
334
- // (never past `text.length`) before the next `indexOf` call runs. There is
335
- // no fallthrough path once the `while` condition becomes false, so the
336
- // loop is written with `while (true)` + internal returns instead of a
337
- // trailing `return -1` that static analysis (and coverage) would flag as
338
- // dead code.
339
279
  const findKeywordAtBoundary = (text, keyword, startFrom = 0) => {
340
280
  let pos = startFrom;
341
- // oxlint-disable-next-line no-constant-condition
342
281
  while (true) {
343
282
  const idx = text.indexOf(keyword, pos);
344
283
  if (idx === -1)
@@ -351,17 +290,10 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
351
290
  pos = idx + 1;
352
291
  }
353
292
  };
354
- /**
355
- * AST-based: Check if a TemplateLiteral contains GraphQL syntax.
356
- * Examines quasis (static template parts) directly — no regex, no sourceCode.getText().
357
- */
358
293
  const isGraphqlTemplate = (node) => {
359
- // Build combined static text from quasis for keyword scanning
360
294
  const staticText = node.quasis
361
295
  .map(q => (q.value.cooked ?? q.value.raw).toLowerCase())
362
296
  .join('');
363
- // 1. Check for GraphQL operation keywords (query, mutation, subscription)
364
- // Must be followed by optional name then { or (
365
297
  for (const keyword of GRAPHQL_OP_KEYWORDS) {
366
298
  let pos = 0;
367
299
  while (pos < staticText.length) {
@@ -371,7 +303,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
371
303
  pos = idx + 1;
372
304
  if (!isAtLineStart(staticText, idx))
373
305
  continue;
374
- // Scan past keyword, skip whitespace, skip optional name, skip whitespace, expect { or (
375
306
  let scan = idx + keyword.length;
376
307
  while (scan < staticText.length && isWhitespace(staticText[scan]))
377
308
  scan++;
@@ -384,7 +315,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
384
315
  }
385
316
  }
386
317
  }
387
- // Check for fragment keyword: fragment Name on Type
388
318
  {
389
319
  let pos = 0;
390
320
  while (pos < staticText.length) {
@@ -394,14 +324,14 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
394
324
  pos = idx + 1;
395
325
  if (!isAtLineStart(staticText, idx))
396
326
  continue;
397
- let scan = idx + 8; // 'fragment'.length
327
+ let scan = idx + 8;
398
328
  while (scan < staticText.length && isWhitespace(staticText[scan]))
399
329
  scan++;
400
330
  const nameStart = scan;
401
331
  while (scan < staticText.length && isWordChar(staticText[scan]))
402
332
  scan++;
403
333
  if (scan === nameStart)
404
- continue; // no name
334
+ continue;
405
335
  while (scan < staticText.length && isWhitespace(staticText[scan]))
406
336
  scan++;
407
337
  if (staticText.slice(scan, scan + 2) === 'on' && (scan + 2 >= staticText.length || !isWordChar(staticText[scan + 2]))) {
@@ -409,11 +339,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
409
339
  }
410
340
  }
411
341
  }
412
- // 2. Check for schema definition keywords (type User, interface Foo, etc.)
413
- // A schema definition always has a body, so the text must contain a
414
- // brace. Without this, `enum value with ',' delimiter. Available values:
415
- // ${...}` (ack-nestjs-boilerplate's Swagger docs) reads as an `enum`
416
- // definition named `value`.
417
342
  if (staticText.includes('{'))
418
343
  for (const keyword of GRAPHQL_SCHEMA_KEYWORDS) {
419
344
  let pos = 0;
@@ -425,7 +350,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
425
350
  if (!isAtLineStart(staticText, idx))
426
351
  continue;
427
352
  let scan = idx + keyword.length;
428
- // Must have whitespace then a word (type name)
429
353
  if (scan >= staticText.length || !isWhitespace(staticText[scan]))
430
354
  continue;
431
355
  while (scan < staticText.length && isWhitespace(staticText[scan]))
@@ -435,24 +359,14 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
435
359
  }
436
360
  }
437
361
  }
438
- // 3. Check for selection sets (nested braces): { users { name } }
439
362
  return isStandaloneSelectionSet(staticText);
440
363
  };
441
- /**
442
- * Check if a TemplateLiteral contains introspection patterns.
443
- * AST-based: scans quasis directly.
444
- */
445
- // oxlint-disable-next-line consistent-function-scoping
446
364
  const templateHasIntrospection = (node) => {
447
365
  return node.quasis.some(q => {
448
366
  const text = (q.value.cooked ?? q.value.raw).toLowerCase();
449
367
  return text.includes('__schema') || text.includes('__type');
450
368
  });
451
369
  };
452
- /**
453
- * Calculate query depth from template quasis (brace depth scan).
454
- */
455
- // oxlint-disable-next-line consistent-function-scoping
456
370
  const templateQueryDepth = (node) => {
457
371
  let depth = 0;
458
372
  let braceCount = 0;
@@ -470,13 +384,8 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
470
384
  }
471
385
  return depth;
472
386
  };
473
- /**
474
- * Text-based GraphQL detection for string Literals and BinaryExpressions.
475
- * Uses simple string methods — only regex is for fragment pattern.
476
- */
477
387
  const containsGraphqlText = (text) => {
478
388
  const lower = text.toLowerCase();
479
- // Check operation keywords
480
389
  for (const keyword of GRAPHQL_OP_KEYWORDS) {
481
390
  const idx = findKeywordAtBoundary(lower, keyword);
482
391
  if (idx === -1)
@@ -493,7 +402,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
493
402
  if (scan < lower.length && (lower[scan] === '{' || lower[scan] === '('))
494
403
  return true;
495
404
  }
496
- // Check fragment
497
405
  const fragIdx = findKeywordAtBoundary(lower, 'fragment');
498
406
  if (fragIdx !== -1 && isAtLineStart(lower, fragIdx)) {
499
407
  let scan = fragIdx + 8;
@@ -509,7 +417,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
509
417
  return true;
510
418
  }
511
419
  }
512
- // Check schema keywords — a schema definition always has a body.
513
420
  if (lower.includes('{'))
514
421
  for (const keyword of GRAPHQL_SCHEMA_KEYWORDS) {
515
422
  const idx = findKeywordAtBoundary(lower, keyword);
@@ -525,13 +432,8 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
525
432
  if (scan < lower.length && isWordChar(lower[scan]))
526
433
  return true;
527
434
  }
528
- // Check nested braces — only as a standalone selection set.
529
435
  return isStandaloneSelectionSet(text);
530
436
  };
531
- /**
532
- * Flatten a `+` concatenation to the string it would produce, keeping only
533
- * the statically known parts. Interpolated identifiers contribute nothing.
534
- */
535
437
  const concatenatedStaticText = (node) => {
536
438
  if (node.type === 'BinaryExpression' && node.operator === '+') {
537
439
  return concatenatedStaticText(node.left) + concatenatedStaticText(node.right);
@@ -543,13 +445,8 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
543
445
  }
544
446
  return '';
545
447
  };
546
- /**
547
- * Check if input is validated before use
548
- */
549
448
  const isInputValidated = (inputNode) => {
550
- // Check if input comes from a validation function
551
449
  let current = inputNode;
552
- // Walk up the AST to find validation calls
553
450
  while (current) {
554
451
  if (current.type === 'CallExpression' &&
555
452
  current.callee.type === 'Identifier' &&
@@ -561,19 +458,14 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
561
458
  return false;
562
459
  };
563
460
  return {
564
- // Check template literals for GraphQL queries
565
461
  TemplateLiteral(node) {
566
- // AST-based context check: skip templates inside safe callers
567
462
  if (isInSafeCallerContext(node)) {
568
463
  return;
569
464
  }
570
- // AST-based GraphQL detection: scan quasis, no regex
571
465
  if (!isGraphqlTemplate(node)) {
572
466
  return;
573
467
  }
574
- // Check for introspection queries (AST-based)
575
468
  if (!allowIntrospection && templateHasIntrospection(node)) {
576
- // FALSE POSITIVE REDUCTION: Skip if annotated as safe
577
469
  if (safetyChecker.isSafe(node, context)) {
578
470
  return;
579
471
  }
@@ -587,9 +479,7 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
587
479
  });
588
480
  return;
589
481
  }
590
- // Check for unsafe interpolation (AST-based: just check expressions array)
591
482
  if (node.expressions.length > 0) {
592
- // FALSE POSITIVE REDUCTION: Skip if all expressions are validated
593
483
  const allExpressionsSafe = node.expressions.every((expr) => isInputValidated(expr) || safetyChecker.isSafe(expr, context));
594
484
  if (!allExpressionsSafe) {
595
485
  context.report({
@@ -602,13 +492,12 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
602
492
  suggest: [
603
493
  {
604
494
  messageId: 'useQueryBuilder',
605
- fix: () => null // Complex to auto-fix
495
+ fix: () => null
606
496
  },
607
497
  ],
608
498
  });
609
499
  }
610
500
  }
611
- // Check query depth for DoS protection (AST-based)
612
501
  const depth = templateQueryDepth(node);
613
502
  if (depth > maxQueryDepth) {
614
503
  context.report({
@@ -627,7 +516,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
627
516
  });
628
517
  }
629
518
  },
630
- // Check string literals for GraphQL queries
631
519
  Literal(node) {
632
520
  if (typeof node.value !== 'string') {
633
521
  return;
@@ -636,7 +524,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
636
524
  if (!containsGraphqlText(queryText)) {
637
525
  return;
638
526
  }
639
- // Check for introspection queries
640
527
  const lowerQuery = queryText.toLowerCase();
641
528
  if (!allowIntrospection && (lowerQuery.includes('__schema') || lowerQuery.includes('__type'))) {
642
529
  if (safetyChecker.isSafe(node, context)) {
@@ -651,7 +538,6 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
651
538
  },
652
539
  });
653
540
  }
654
- // Check query depth via brace scanner
655
541
  let depth = 0;
656
542
  let bc = 0;
657
543
  for (const ch of queryText) {
@@ -674,21 +560,14 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
674
560
  });
675
561
  }
676
562
  },
677
- // Check binary expressions (string concatenation)
678
563
  BinaryExpression(node) {
679
564
  if (node.operator !== '+') {
680
565
  return;
681
566
  }
682
- // Use the concatenation's STATIC STRING VALUE, not its source text.
683
- // `sourceCode.getText()` includes the JS quoting and the `+ ident +`
684
- // scaffolding, so a query starting at the very beginning of the string
685
- // is preceded by a `"` — which defeats the start-of-line check that
686
- // keeps ordinary message strings from being read as GraphQL.
687
567
  const fullText = concatenatedStaticText(node);
688
568
  if (!containsGraphqlText(fullText)) {
689
569
  return;
690
570
  }
691
- // String concatenation in GraphQL queries is dangerous
692
571
  if (safetyChecker.isSafe(node, context)) {
693
572
  return;
694
573
  }
@@ -703,20 +582,16 @@ exports.noGraphqlInjection = (0, eslint_devkit_1.createRule)({
703
582
  },
704
583
  });
705
584
  },
706
- // Check GraphQL execution calls
707
585
  CallExpression(node) {
708
586
  if (!isGraphqlRelated(node)) {
709
587
  return;
710
588
  }
711
589
  const callee = node.callee;
712
- // Check for execute/query methods
713
590
  if (callee.type === 'MemberExpression' &&
714
591
  callee.property.type === 'Identifier' &&
715
592
  ['execute', 'executeQuery', 'query', 'mutate', 'subscribe'].includes(callee.property.name)) {
716
- // Check arguments for unvalidated inputs
717
593
  for (const arg of node.arguments) {
718
594
  if (arg.type === 'Identifier' && !isInputValidated(arg)) {
719
- // FALSE POSITIVE REDUCTION
720
595
  if (safetyChecker.isSafe(arg, context)) {
721
596
  continue;
722
597
  }