@interlace/eslint-devkit 1.6.0 → 1.6.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interlace/eslint-devkit",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Toolkit for building ESLint plugins in TypeScript — AST helpers, type utilities, rule-creation scaffolding, security benchmarks, and SARIF output.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -64,12 +64,6 @@
|
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=18.0.0"
|
|
66
66
|
},
|
|
67
|
-
"scripts": {
|
|
68
|
-
"build": "tsx ../../scripts/build-package.ts",
|
|
69
|
-
"test": "vitest run",
|
|
70
|
-
"test:coverage": "vitest run --coverage",
|
|
71
|
-
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
72
|
-
},
|
|
73
67
|
"peerDependencies": {
|
|
74
68
|
"@typescript-eslint/utils": "^7.0.0 || ^8.0.0",
|
|
75
69
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
@@ -88,14 +82,6 @@
|
|
|
88
82
|
"optional": true
|
|
89
83
|
}
|
|
90
84
|
},
|
|
91
|
-
"devDependencies": {
|
|
92
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
93
|
-
"gpt-tokenizer": "^3.4.0",
|
|
94
|
-
"@typescript-eslint/types": "^8.46.2",
|
|
95
|
-
"@typescript-eslint/utils": "^8.46.2",
|
|
96
|
-
"oxc-resolver": "^11.24.2",
|
|
97
|
-
"typescript": "^5.0.0 || ^6.0.0"
|
|
98
|
-
},
|
|
99
85
|
"funding": {
|
|
100
86
|
"type": "github",
|
|
101
87
|
"url": "https://github.com/ofri-peretz/eslint"
|
|
@@ -3,25 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
* Shared raw-SQL-injection detector (CWE-89).
|
|
8
|
-
*
|
|
9
|
-
* The AST work — string concatenation or an interpolated template literal
|
|
10
|
-
* reaching a raw-SQL sink — is identical for every driver. What differs is
|
|
11
|
-
* the sink list and the remediation copy (`$1, $2` for Postgres, `?` for
|
|
12
|
-
* mysql2, `replacements` for Sequelize), so those are the parameters.
|
|
13
|
-
*
|
|
14
|
-
* This exists because the detection first shipped inside `eslint-plugin-pg`,
|
|
15
|
-
* where it works fine on `sequelize.query()` — but nobody on Sequelize,
|
|
16
|
-
* SQLite or MySQL installs the Postgres plugin, so textbook injections in
|
|
17
|
-
* those stacks went unreported. Each driver plugin now instantiates this
|
|
18
|
-
* factory, which keeps one implementation and one finding per line.
|
|
19
|
-
*
|
|
20
|
-
* The rule must stay in a driver-scoped plugin: it keys on driver method
|
|
21
|
-
* names, not language primitives, so it does not belong in the code-agnostic
|
|
22
|
-
* plugins (`secure-coding`, `node-security`, `browser-security`).
|
|
23
|
-
*/
|
|
24
|
-
import { TSESLint } from '@typescript-eslint/utils';
|
|
6
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
25
7
|
/** Message ids every rule built by this factory reports. */
|
|
26
8
|
export type SqlInjectionMessageIds = 'noUnsafeQuery' | 'unsafeTemplateLiteral';
|
|
27
9
|
export interface SqlInjectionRuleConfig {
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSqlInjectionRule = createSqlInjectionRule;
|
|
4
|
-
const
|
|
4
|
+
const ast_node_types_1 = require("../ast-node-types");
|
|
5
5
|
const messaging_1 = require("../messaging");
|
|
6
6
|
const SQL_KEYWORDS = /\b(?:select|insert|update|delete|drop|alter|truncate|union|from|where|values|set)\b/i;
|
|
7
7
|
function staticText(node) {
|
|
8
|
-
if (node.type ===
|
|
8
|
+
if (node.type === ast_node_types_1.AST_NODE_TYPES.TemplateLiteral) {
|
|
9
9
|
return node.quasis.map((q) => q.value.raw).join(' ');
|
|
10
10
|
}
|
|
11
|
-
if (node.type ===
|
|
11
|
+
if (node.type === ast_node_types_1.AST_NODE_TYPES.BinaryExpression) {
|
|
12
12
|
return `${staticText(node.left)} ${staticText(node.right)}`;
|
|
13
13
|
}
|
|
14
|
-
if (node.type ===
|
|
14
|
+
if (node.type === ast_node_types_1.AST_NODE_TYPES.Literal && typeof node.value === 'string') {
|
|
15
15
|
return node.value;
|
|
16
16
|
}
|
|
17
17
|
return '';
|
|
18
18
|
}
|
|
19
19
|
function classify(node, requireSqlKeywords) {
|
|
20
20
|
let kind = false;
|
|
21
|
-
if (node.type ===
|
|
21
|
+
if (node.type === ast_node_types_1.AST_NODE_TYPES.BinaryExpression && node.operator === '+') {
|
|
22
22
|
kind = 'concat';
|
|
23
23
|
}
|
|
24
|
-
if (node.type ===
|
|
24
|
+
if (node.type === ast_node_types_1.AST_NODE_TYPES.TemplateLiteral && node.expressions.length > 0) {
|
|
25
25
|
kind = 'template';
|
|
26
26
|
}
|
|
27
27
|
if (kind === false)
|
|
@@ -74,7 +74,7 @@ function createSqlInjectionRule(config) {
|
|
|
74
74
|
};
|
|
75
75
|
return {
|
|
76
76
|
VariableDeclarator(node) {
|
|
77
|
-
if (node.id.type ===
|
|
77
|
+
if (node.id.type === ast_node_types_1.AST_NODE_TYPES.Identifier && node.init) {
|
|
78
78
|
const kind = classify(node.init, config.requireSqlKeywords);
|
|
79
79
|
if (kind)
|
|
80
80
|
tainted.set(node.id.name, kind);
|
|
@@ -83,7 +83,7 @@ function createSqlInjectionRule(config) {
|
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
AssignmentExpression(node) {
|
|
86
|
-
if (node.operator === '+=' && node.left.type ===
|
|
86
|
+
if (node.operator === '+=' && node.left.type === ast_node_types_1.AST_NODE_TYPES.Identifier) {
|
|
87
87
|
const gate = config.requireSqlKeywords && !sqlish.has(node.left.name);
|
|
88
88
|
const kind = classify(node.right, gate);
|
|
89
89
|
if (kind)
|
|
@@ -91,8 +91,8 @@ function createSqlInjectionRule(config) {
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
CallExpression(node) {
|
|
94
|
-
if (node.callee.type !==
|
|
95
|
-
node.callee.property.type !==
|
|
94
|
+
if (node.callee.type !== ast_node_types_1.AST_NODE_TYPES.MemberExpression ||
|
|
95
|
+
node.callee.property.type !== ast_node_types_1.AST_NODE_TYPES.Identifier ||
|
|
96
96
|
!sinks.has(node.callee.property.name)) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
@@ -104,7 +104,7 @@ function createSqlInjectionRule(config) {
|
|
|
104
104
|
report(queryArg, direct);
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
if (queryArg.type ===
|
|
107
|
+
if (queryArg.type === ast_node_types_1.AST_NODE_TYPES.Identifier) {
|
|
108
108
|
const taint = tainted.get(queryArg.name);
|
|
109
109
|
if (taint)
|
|
110
110
|
report(queryArg, taint);
|