@interlace/eslint-devkit 1.4.4 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +22 -12
- package/src/aria-definitions.js +0 -14
- package/src/ast/ast-utils.js +0 -72
- package/src/ast/index.js +0 -6
- package/src/ast-node-types.d.ts +29 -0
- package/src/ast-node-types.js +174 -0
- package/src/index.d.ts +11 -2
- package/src/index.js +5 -38
- package/src/messaging/config.js +0 -88
- package/src/messaging/constants.js +20 -142
- package/src/messaging/formatters-ai.js +0 -89
- package/src/messaging/formatters-v2.js +0 -151
- package/src/messaging/formatters.js +2 -145
- package/src/messaging/index.js +0 -6
- package/src/messaging/types-v2.js +0 -5
- package/src/messaging/types.js +0 -5
- package/src/node/fs.js +0 -61
- package/src/node/index.js +0 -6
- package/src/node/os.js +0 -33
- package/src/node/path.js +0 -126
- package/src/resolver/dependency-analysis.js +64 -562
- package/src/resolver/index.js +0 -6
- package/src/resolver/resolver-adapter.js +0 -39
- package/src/resolver/resolver-detection.js +0 -48
- package/src/resolver/resolver.d.ts +11 -0
- package/src/resolver/resolver.js +49 -112
- package/src/resolver.js +0 -5
- package/src/rule-creation/index.d.ts +1 -0
- package/src/rule-creation/index.js +1 -6
- package/src/rule-creation/mock-context.d.ts +5 -0
- package/src/rule-creation/mock-context.js +1 -9
- package/src/rule-creation/rule-creator.d.ts +59 -10
- package/src/rule-creation/rule-creator.js +64 -40
- package/src/rule-creation/sql-injection-rule.d.ts +68 -0
- package/src/rule-creation/sql-injection-rule.js +116 -0
- package/src/security/index.js +0 -6
- package/src/security/security-utils.js +9 -287
- package/src/types/index.js +0 -9
- package/src/types/meta-augmentation.js +0 -5
- package/src/types/type-utils.d.ts +1 -1
- package/src/types/type-utils.js +34 -145
- package/AGENTS.md +0 -151
- package/CHANGELOG.md +0 -153
|
@@ -6,14 +6,60 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Rule Creator - Main utility for creating well-typed ESLint rules
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Ported from typescript-eslint's ESLintUtils.RuleCreator.
|
|
10
10
|
* Provides a factory function for creating rules with proper types and documentation
|
|
11
|
+
*
|
|
12
|
+
* ponytail: this ~40-line port is the whole reason `@typescript-eslint/utils`
|
|
13
|
+
* can be an OPTIONAL peer instead of a hard dependency. `RuleCreator` was the
|
|
14
|
+
* only runtime import we ever made from it, and pulling it in as a dependency
|
|
15
|
+
* dragged its non-optional `typescript` peer — 24 MB of compiler — into every
|
|
16
|
+
* install of every plugin built on this devkit, including plain-JS projects.
|
|
17
|
+
* Types still come from the package (type-only imports cost nothing at
|
|
18
|
+
* runtime); `rule-creator.parity.test.ts` diffs this implementation against
|
|
19
|
+
* the upstream one on every run so the port can't silently drift.
|
|
11
20
|
*/
|
|
12
|
-
import {
|
|
21
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
13
22
|
/**
|
|
14
23
|
* Documentation URL resolver function type
|
|
15
24
|
*/
|
|
16
25
|
type DocsUrl = (ruleName: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Pure function - doesn't mutate either parameter!
|
|
28
|
+
* Uses the default options and overrides with the options provided by the user
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyDefault<Options extends readonly unknown[]>(defaultOptions: Options, userOptions: readonly unknown[] | null): Options;
|
|
31
|
+
/**
|
|
32
|
+
* Rule shapes, mirroring `ESLintUtils`'s own. Reconstructed from the
|
|
33
|
+
* `TSESLint` type namespace so they survive `@typescript-eslint/utils` being
|
|
34
|
+
* an optional peer — these are type-only and emit nothing.
|
|
35
|
+
*/
|
|
36
|
+
export type NamedCreateRuleMeta<MessageIds extends string, PluginDocs = unknown, Options extends readonly unknown[] = []> = {
|
|
37
|
+
docs: PluginDocs & TSESLint.RuleMetaDataDocs;
|
|
38
|
+
} & Omit<TSESLint.RuleMetaData<MessageIds, PluginDocs, Options>, 'docs'>;
|
|
39
|
+
export interface RuleCreateAndOptions<Options extends readonly unknown[], MessageIds extends string> {
|
|
40
|
+
create: (context: Readonly<TSESLint.RuleContext<MessageIds, Options>>, optionsWithDefault: Readonly<Options>) => TSESLint.RuleListener;
|
|
41
|
+
defaultOptions?: Readonly<Options>;
|
|
42
|
+
}
|
|
43
|
+
export interface RuleWithMeta<Options extends readonly unknown[], MessageIds extends string, Docs = unknown> extends RuleCreateAndOptions<Options, MessageIds> {
|
|
44
|
+
meta: TSESLint.RuleMetaData<MessageIds, Docs, Options>;
|
|
45
|
+
name?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface RuleWithMetaAndName<Options extends readonly unknown[], MessageIds extends string, Docs = unknown> extends RuleCreateAndOptions<Options, MessageIds> {
|
|
48
|
+
meta: NamedCreateRuleMeta<MessageIds, Docs, Options>;
|
|
49
|
+
name: string;
|
|
50
|
+
}
|
|
51
|
+
export type RuleModuleWithName<MessageIds extends string, Options extends readonly unknown[] = [], Docs = unknown> = TSESLint.RuleModule<MessageIds, Options, Docs> & {
|
|
52
|
+
name: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Port of `ESLintUtils.RuleCreator`.
|
|
56
|
+
*
|
|
57
|
+
* Creates a reusable factory for rules with default options and docs URLs.
|
|
58
|
+
*/
|
|
59
|
+
export declare function RuleCreator<PluginDocs = unknown>(urlCreator: DocsUrl): <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<RuleWithMetaAndName<Options, MessageIds, PluginDocs>>) => RuleModuleWithName<MessageIds, Options, PluginDocs>;
|
|
60
|
+
export declare namespace RuleCreator {
|
|
61
|
+
var withoutDocs: <Options extends readonly unknown[], MessageIds extends string>(args: Readonly<RuleWithMeta<Options, MessageIds>>) => TSESLint.RuleModule<MessageIds, Options>;
|
|
62
|
+
}
|
|
17
63
|
/**
|
|
18
64
|
* Create a rule creator with a custom documentation URL resolver
|
|
19
65
|
*
|
|
@@ -34,18 +80,21 @@ type DocsUrl = (ruleName: string) => string;
|
|
|
34
80
|
* });
|
|
35
81
|
* ```
|
|
36
82
|
*/
|
|
37
|
-
export declare function createRuleCreator(urlCreator: DocsUrl): <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<
|
|
38
|
-
name: string;
|
|
39
|
-
};
|
|
83
|
+
export declare function createRuleCreator<PluginDocs = unknown>(urlCreator: DocsUrl): <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<RuleWithMetaAndName<Options, MessageIds, PluginDocs>>) => RuleModuleWithName<MessageIds, Options, PluginDocs>;
|
|
40
84
|
/**
|
|
41
85
|
* Default rule creator with a generic documentation URL pattern
|
|
42
86
|
*
|
|
43
87
|
* This can be used directly if you don't need custom URL generation
|
|
44
88
|
*/
|
|
45
|
-
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<
|
|
46
|
-
name: string;
|
|
47
|
-
};
|
|
89
|
+
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<RuleWithMetaAndName<Options, MessageIds, unknown>>) => RuleModuleWithName<MessageIds, Options, unknown>;
|
|
48
90
|
/**
|
|
49
|
-
*
|
|
91
|
+
* Drop-in replacement for the `ESLintUtils` namespace this module used to
|
|
92
|
+
* re-export from `@typescript-eslint/utils`. Only `RuleCreator` was ever used
|
|
93
|
+
* by this ecosystem; anything else should import `@typescript-eslint/utils`
|
|
94
|
+
* directly.
|
|
50
95
|
*/
|
|
51
|
-
export
|
|
96
|
+
export declare const ESLintUtils: {
|
|
97
|
+
RuleCreator: typeof RuleCreator;
|
|
98
|
+
applyDefault: typeof applyDefault;
|
|
99
|
+
};
|
|
100
|
+
export type { TSESLint };
|
|
@@ -1,46 +1,70 @@
|
|
|
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.ESLintUtils = exports.createRule = void 0;
|
|
4
|
+
exports.applyDefault = applyDefault;
|
|
5
|
+
exports.RuleCreator = RuleCreator;
|
|
9
6
|
exports.createRuleCreator = createRuleCreator;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
7
|
+
function isObjectNotArray(obj) {
|
|
8
|
+
return typeof obj === 'object' && obj != null && !Array.isArray(obj);
|
|
9
|
+
}
|
|
10
|
+
function deepMerge(first, second) {
|
|
11
|
+
const keys = new Set([...Object.keys(first), ...Object.keys(second)]);
|
|
12
|
+
return Object.fromEntries([...keys].map((key) => {
|
|
13
|
+
const firstHasKey = key in first;
|
|
14
|
+
const secondHasKey = key in second;
|
|
15
|
+
const firstValue = first[key];
|
|
16
|
+
const secondValue = second[key];
|
|
17
|
+
if (firstHasKey && secondHasKey) {
|
|
18
|
+
return [
|
|
19
|
+
key,
|
|
20
|
+
isObjectNotArray(firstValue) && isObjectNotArray(secondValue)
|
|
21
|
+
? deepMerge(firstValue, secondValue)
|
|
22
|
+
: secondValue,
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
return [key, firstHasKey ? firstValue : secondValue];
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
function applyDefault(defaultOptions, userOptions) {
|
|
29
|
+
const options = structuredClone(defaultOptions);
|
|
30
|
+
if (userOptions == null) {
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
33
|
+
options.forEach((opt, i) => {
|
|
34
|
+
if (userOptions[i] !== undefined) {
|
|
35
|
+
const userOpt = userOptions[i];
|
|
36
|
+
options[i] =
|
|
37
|
+
isObjectNotArray(userOpt) && isObjectNotArray(opt)
|
|
38
|
+
? deepMerge(opt, userOpt)
|
|
39
|
+
: userOpt;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return options;
|
|
43
|
+
}
|
|
44
|
+
function createRuleInternal({ create, defaultOptions, meta, name, }) {
|
|
45
|
+
const resolvedDefaultOptions = (defaultOptions ?? []);
|
|
46
|
+
return {
|
|
47
|
+
create(context) {
|
|
48
|
+
return create(context, applyDefault(resolvedDefaultOptions, context.options));
|
|
49
|
+
},
|
|
50
|
+
defaultOptions: resolvedDefaultOptions,
|
|
51
|
+
meta,
|
|
52
|
+
name: name,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function RuleCreator(urlCreator) {
|
|
56
|
+
return ({ meta, name, ...rule }) => createRuleInternal({
|
|
57
|
+
meta: {
|
|
58
|
+
...meta,
|
|
59
|
+
docs: { ...meta.docs, url: urlCreator(name) },
|
|
60
|
+
},
|
|
61
|
+
name,
|
|
62
|
+
...rule,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
RuleCreator.withoutDocs = (args) => createRuleInternal(args);
|
|
38
66
|
function createRuleCreator(urlCreator) {
|
|
39
|
-
return
|
|
67
|
+
return RuleCreator(urlCreator);
|
|
40
68
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
* This can be used directly if you don't need custom URL generation
|
|
45
|
-
*/
|
|
46
|
-
exports.createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin/docs/rules/${name}.md`);
|
|
69
|
+
exports.createRule = RuleCreator((name) => `https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin/docs/rules/${name}.md`);
|
|
70
|
+
exports.ESLintUtils = { RuleCreator, applyDefault };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
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';
|
|
25
|
+
/** Message ids every rule built by this factory reports. */
|
|
26
|
+
export type SqlInjectionMessageIds = 'noUnsafeQuery' | 'unsafeTemplateLiteral';
|
|
27
|
+
export interface SqlInjectionRuleConfig {
|
|
28
|
+
/**
|
|
29
|
+
* The rule's own `meta.type` + `meta.docs`, spelled out by the caller.
|
|
30
|
+
*
|
|
31
|
+
* Deliberately NOT derived inside this factory: `scripts/audit-rule-meta-completeness.ts`
|
|
32
|
+
* reads rule metadata by *statically parsing the rule's source file*, so
|
|
33
|
+
* metadata hidden in here is invisible to it — a factory-built rule scores
|
|
34
|
+
* 0% and fails the strict gate. Keeping it at the call site also puts each
|
|
35
|
+
* driver's CWE/CVSS where a reader expects to find it.
|
|
36
|
+
*/
|
|
37
|
+
readonly meta: {
|
|
38
|
+
readonly type: 'problem';
|
|
39
|
+
readonly docs: {
|
|
40
|
+
readonly description: string;
|
|
41
|
+
readonly url: string;
|
|
42
|
+
readonly cwe: string;
|
|
43
|
+
readonly cvss: number;
|
|
44
|
+
readonly confidence: 'high' | 'medium' | 'low';
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/** Method names treated as raw-SQL sinks, e.g. `['query']` or `['query', 'raw', 'execute']`. */
|
|
48
|
+
readonly methods: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* Require SQL keywords in the *static* part of the string before reporting.
|
|
51
|
+
* Precision guard for broad sink lists (`.raw()`, `.execute()` are not
|
|
52
|
+
* SQL-only names). `false` keeps the historical pg behaviour: any
|
|
53
|
+
* interpolation into a sink is a finding.
|
|
54
|
+
*/
|
|
55
|
+
readonly requireSqlKeywords: boolean;
|
|
56
|
+
/** Remediation line in the emitted message. */
|
|
57
|
+
readonly fix: string;
|
|
58
|
+
/** Reference link in the emitted message. */
|
|
59
|
+
readonly documentationLink: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Build a CWE-89 rule for the given sinks and remediation copy.
|
|
63
|
+
*
|
|
64
|
+
* Detects three shapes: direct concatenation into a sink, direct
|
|
65
|
+
* interpolation into a sink, and a variable tainted by either (including via
|
|
66
|
+
* `+=`) that is later passed to a sink.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createSqlInjectionRule(config: SqlInjectionRuleConfig): TSESLint.RuleModule<SqlInjectionMessageIds, []>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSqlInjectionRule = createSqlInjectionRule;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const messaging_1 = require("../messaging");
|
|
6
|
+
const SQL_KEYWORDS = /\b(?:select|insert|update|delete|drop|alter|truncate|union|from|where|values|set)\b/i;
|
|
7
|
+
function staticText(node) {
|
|
8
|
+
if (node.type === utils_1.AST_NODE_TYPES.TemplateLiteral) {
|
|
9
|
+
return node.quasis.map((q) => q.value.raw).join(' ');
|
|
10
|
+
}
|
|
11
|
+
if (node.type === utils_1.AST_NODE_TYPES.BinaryExpression) {
|
|
12
|
+
return `${staticText(node.left)} ${staticText(node.right)}`;
|
|
13
|
+
}
|
|
14
|
+
if (node.type === utils_1.AST_NODE_TYPES.Literal && typeof node.value === 'string') {
|
|
15
|
+
return node.value;
|
|
16
|
+
}
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
function classify(node, requireSqlKeywords) {
|
|
20
|
+
let kind = false;
|
|
21
|
+
if (node.type === utils_1.AST_NODE_TYPES.BinaryExpression && node.operator === '+') {
|
|
22
|
+
kind = 'concat';
|
|
23
|
+
}
|
|
24
|
+
if (node.type === utils_1.AST_NODE_TYPES.TemplateLiteral && node.expressions.length > 0) {
|
|
25
|
+
kind = 'template';
|
|
26
|
+
}
|
|
27
|
+
if (kind === false)
|
|
28
|
+
return false;
|
|
29
|
+
if (kind === 'concat' && staticText(node).trim() === '')
|
|
30
|
+
return false;
|
|
31
|
+
if (requireSqlKeywords && !SQL_KEYWORDS.test(staticText(node)))
|
|
32
|
+
return false;
|
|
33
|
+
return kind;
|
|
34
|
+
}
|
|
35
|
+
function createSqlInjectionRule(config) {
|
|
36
|
+
const sinks = new Set(config.methods);
|
|
37
|
+
return {
|
|
38
|
+
meta: {
|
|
39
|
+
type: config.meta.type,
|
|
40
|
+
docs: { ...config.meta.docs },
|
|
41
|
+
messages: {
|
|
42
|
+
noUnsafeQuery: (0, messaging_1.formatLLMMessage)({
|
|
43
|
+
icon: messaging_1.MessageIcons.SECURITY,
|
|
44
|
+
issueName: 'SQL Injection Risk',
|
|
45
|
+
description: 'Unsafe SQL query detected. Variable interpolation found.',
|
|
46
|
+
severity: 'CRITICAL',
|
|
47
|
+
cwe: config.meta.docs.cwe,
|
|
48
|
+
owasp: 'A03:2021',
|
|
49
|
+
compliance: ['SOC2', 'PCI-DSS', 'NIST-CSF'],
|
|
50
|
+
effort: 'high',
|
|
51
|
+
fix: config.fix,
|
|
52
|
+
documentationLink: config.documentationLink,
|
|
53
|
+
}),
|
|
54
|
+
unsafeTemplateLiteral: (0, messaging_1.formatLLMMessage)({
|
|
55
|
+
icon: messaging_1.MessageIcons.SECURITY,
|
|
56
|
+
issueName: 'SQL Injection Risk',
|
|
57
|
+
description: 'Unsafe SQL query construction detected (template literal).',
|
|
58
|
+
severity: 'CRITICAL',
|
|
59
|
+
fix: config.fix,
|
|
60
|
+
documentationLink: config.documentationLink,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
schema: [],
|
|
64
|
+
},
|
|
65
|
+
defaultOptions: [],
|
|
66
|
+
create(context) {
|
|
67
|
+
const tainted = new Map();
|
|
68
|
+
const sqlish = new Set();
|
|
69
|
+
const report = (node, kind) => {
|
|
70
|
+
context.report({
|
|
71
|
+
node,
|
|
72
|
+
messageId: kind === 'template' ? 'unsafeTemplateLiteral' : 'noUnsafeQuery',
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
VariableDeclarator(node) {
|
|
77
|
+
if (node.id.type === utils_1.AST_NODE_TYPES.Identifier && node.init) {
|
|
78
|
+
const kind = classify(node.init, config.requireSqlKeywords);
|
|
79
|
+
if (kind)
|
|
80
|
+
tainted.set(node.id.name, kind);
|
|
81
|
+
if (SQL_KEYWORDS.test(staticText(node.init)))
|
|
82
|
+
sqlish.add(node.id.name);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
AssignmentExpression(node) {
|
|
86
|
+
if (node.operator === '+=' && node.left.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
87
|
+
const gate = config.requireSqlKeywords && !sqlish.has(node.left.name);
|
|
88
|
+
const kind = classify(node.right, gate);
|
|
89
|
+
if (kind)
|
|
90
|
+
tainted.set(node.left.name, kind);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
CallExpression(node) {
|
|
94
|
+
if (node.callee.type !== utils_1.AST_NODE_TYPES.MemberExpression ||
|
|
95
|
+
node.callee.property.type !== utils_1.AST_NODE_TYPES.Identifier ||
|
|
96
|
+
!sinks.has(node.callee.property.name)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const queryArg = node.arguments[0];
|
|
100
|
+
if (!queryArg)
|
|
101
|
+
return;
|
|
102
|
+
const direct = classify(queryArg, config.requireSqlKeywords);
|
|
103
|
+
if (direct) {
|
|
104
|
+
report(queryArg, direct);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (queryArg.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
108
|
+
const taint = tainted.get(queryArg.name);
|
|
109
|
+
if (taint)
|
|
110
|
+
report(queryArg, taint);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
package/src/security/index.js
CHANGED
|
@@ -1,10 +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
|
const tslib_1 = require("tslib");
|
|
9
|
-
// Security utilities for reducing false positives in security rules
|
|
10
4
|
tslib_1.__exportStar(require("./security-utils"), exports);
|