@interlace/eslint-devkit 1.21.2 → 1.21.3
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.21.
|
|
3
|
+
"version": "1.21.3",
|
|
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",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isPathAlias=isPathAlias;exports.sourceMatches=sourceMatches;exports.eitherOrigin=eitherOrigin;exports.isFunctionNode=isFunctionNode;exports.writtenAnnotation=writtenAnnotation;exports.createOriginClassifier=createOriginClassifier;const ast_node_types_1=require("../ast-node-types");const spellings_1=require("../ast/spellings");const type_syntax_1=require("../ast/type-syntax");const module_evidence_1=require("./module-evidence");const value_follow_1=require("./value-follow");const PLATFORM_GLOBALS=new Set(["Array","Map","Set","WeakMap","WeakSet","Object","JSON","Math","Promise","Reflect","URL","URLSearchParams","Headers","FormData","Date","globalThis","window","document","console","process","Buffer"]);function isPathAlias(specifier){return/^(?:[@~]\/|~|#)/.test(specifier)}function sourceMatches(source,modules){return modules.some(m=>source===m||source.startsWith(`${m}/`))}function eitherOrigin(a,b){if(a==="ours"||b==="ours")return"ours";return a==="foreign"&&b==="foreign"?"foreign":"unknown"}function isFunctionNode(node){return node.type===ast_node_types_1.AST_NODE_TYPES.FunctionDeclaration||node.type===ast_node_types_1.AST_NODE_TYPES.FunctionExpression||node.type===ast_node_types_1.AST_NODE_TYPES.ArrowFunctionExpression}function writtenAnnotation(identifier){const holder=identifier;return holder.typeAnnotation?.typeAnnotation}function enclosingClass(node){for(let n=node.parent;n;n=n.parent){if(n.type===ast_node_types_1.AST_NODE_TYPES.ClassDeclaration||n.type===ast_node_types_1.AST_NODE_TYPES.ClassExpression){return n}}return void 0}function typeRoot(name){let cursor=name;while(cursor.type===ast_node_types_1.AST_NODE_TYPES.TSQualifiedName)cursor=cursor.left;return cursor.type===ast_node_types_1.AST_NODE_TYPES.Identifier?cursor:null}function createOriginClassifier(modules){const loadsDriver=(0,module_evidence_1.createModuleEvidence)({packages:modules});const classOrigin=(cls,value,depth,seen)=>cls.superClass===null?"foreign":classify((0,value_follow_1.valueAt)(cls.superClass,value.env),depth+1,seen);const declarationOrigin=(value,depth,seen)=>{const node=value.node;if(node.type===ast_node_types_1.AST_NODE_TYPES.TSTypeAliasDeclaration){return typeOrigin((0,value_follow_1.valueAt)(node.typeAnnotation,value.env),depth+1,seen)}if(node.type===ast_node_types_1.AST_NODE_TYPES.TSInterfaceDeclaration){return node.extends.map(base=>classify((0,value_follow_1.valueAt)(base.expression,value.env),depth+1,seen)).includes("ours")?"ours":"foreign"}return classify(value,depth+1,seen)};const typeOrigin=(value,depth,seen)=>{const node=value.node;if(node.type===ast_node_types_1.AST_NODE_TYPES.TSUnionType||node.type===ast_node_types_1.AST_NODE_TYPES.TSIntersectionType){return node.types.map(t=>typeOrigin((0,value_follow_1.valueAt)(t,value.env),depth+1,seen)).reduce(eitherOrigin)}if(node.type===ast_node_types_1.AST_NODE_TYPES.TSTypeQuery){const root2=node.exprName.type===ast_node_types_1.AST_NODE_TYPES.TSImportType?null:typeRoot(node.exprName);return root2===null?"unknown":classify((0,value_follow_1.valueAt)(root2,value.env),depth+1,seen)}if(node.type!==ast_node_types_1.AST_NODE_TYPES.TSTypeReference)return"foreign";const root=typeRoot(node.typeName);const variable=(0,value_follow_1.lookup)(root.name,value.env.scopeOf(root));if(variable===null)return"unknown";if(variable.defs.length===0)return"foreign";const specifier=(0,value_follow_1.importSpecifierOf)(variable);if(specifier!==null){if(sourceMatches(specifier.source,modules))return"ours";if(!(0,value_follow_1.isRelativeSpecifier)(specifier.source))return isPathAlias(specifier.source)?"unknown":"foreign";const origin=(0,value_follow_1.importOrigin)(variable,value.env);const exported=origin===null||origin.name==="*"?null:(0,value_follow_1.exportedValue)(origin.module,origin.name,value.env.parser);return exported===null?"unknown":declarationOrigin(exported,depth+1,seen)}return declarationOrigin((0,value_follow_1.valueAt)(variable.defs[0].node,value.env),depth,seen)};const thisOrigin=(at,key,value,depth,seen)=>{const cls=enclosingClass(at);if(cls===void 0)return"unknown";for(const element of key===null?[]:cls.body.body){if(element.type===ast_node_types_1.AST_NODE_TYPES.PropertyDefinition&&!element.computed&&element.key.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&element.key.name===key){if(element.typeAnnotation){return typeOrigin((0,value_follow_1.valueAt)(element.typeAnnotation.typeAnnotation,value.env),depth+1,seen)}return element.value===null?"unknown":classify((0,value_follow_1.valueAt)(element.value,value.env),depth+1,seen)}if(element.type!==ast_node_types_1.AST_NODE_TYPES.MethodDefinition||element.kind!=="constructor"){continue}for(const param of element.value.params){if(param.type!==ast_node_types_1.AST_NODE_TYPES.TSParameterProperty)continue;const inner=param.parameter.type===ast_node_types_1.AST_NODE_TYPES.AssignmentPattern?param.parameter.left:param.parameter;if(inner.type!==ast_node_types_1.AST_NODE_TYPES.Identifier||inner.name!==key)continue;const annotation=writtenAnnotation(inner);return annotation===void 0?"unknown":typeOrigin((0,value_follow_1.valueAt)(annotation,value.env),depth+1,seen)}for(const statement of element.value.body?.body??[]){if(statement.type===ast_node_types_1.AST_NODE_TYPES.ExpressionStatement&&statement.expression.type===ast_node_types_1.AST_NODE_TYPES.AssignmentExpression&&statement.expression.left.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&statement.expression.left.object.type===ast_node_types_1.AST_NODE_TYPES.ThisExpression&&(0,spellings_1.propertyName)(statement.expression.left)===key){return classify((0,value_follow_1.valueAt)(statement.expression.right,value.env),depth+1,seen)}}}return classOrigin(cls,value,depth,seen)==="ours"?"ours":"unknown"};const parameterOrigin=(identifier,fn,value,depth,seen)=>{const annotation=writtenAnnotation(identifier);if(annotation!==void 0){return typeOrigin((0,value_follow_1.valueAt)(annotation,value.env),depth+1,seen)}const call=fn.parent;if(call?.type===ast_node_types_1.AST_NODE_TYPES.CallExpression&&call.callee.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&call.arguments.some(argument=>argument===fn)&&classify((0,value_follow_1.valueAt)(call.callee.object,value.env),depth+1,seen)==="ours"){return"ours"}return"unknown"};const identifierOrigin=(node,value,depth,seen)=>{const variable=(0,value_follow_1.lookup)(node.name,value.scope);if(variable===null)return PLATFORM_GLOBALS.has(node.name)?"foreign":"unknown";if(variable.defs.length===0)return"foreign";const specifier=(0,value_follow_1.importSpecifierOf)(variable);if(specifier!==null){if(sourceMatches(specifier.source,modules))return"ours";if(!(0,value_follow_1.isRelativeSpecifier)(specifier.source))return isPathAlias(specifier.source)?"unknown":"foreign";const followed2=(0,value_follow_1.follow)(value);const judged=followed2.node===value.node||followed2.node.type===ast_node_types_1.AST_NODE_TYPES.Program?"unknown":classify(followed2,depth+1,seen);if(judged!=="unknown")return judged;const origin=(0,value_follow_1.importOrigin)(variable,value.env);return origin!==null&&loadsDriver(origin.module.ast)?"ours":judged}const def=variable.defs[0];if(def.type==="Parameter"){return parameterOrigin(variable.identifiers[0],def.node,value,depth,seen)}if(def.type==="ClassName"){return classOrigin(def.node,value,depth,seen)}if(def.type!=="Variable")return"foreign";const annotation=writtenAnnotation(def.node.id);if(annotation!==void 0){const typed=typeOrigin((0,value_follow_1.valueAt)(annotation,value.env),depth+1,seen);if(typed!=="unknown")return typed}const followed=(0,value_follow_1.follow)(value);if(followed.node!==value.node)return classify(followed,depth+1,seen);const writes=variable.references.filter(r=>r.isWrite()&&r.writeExpr).map(r=>classify((0,value_follow_1.valueAt)(r.writeExpr,value.env),depth+1,seen));return writes.length===0?"unknown":writes.reduce(eitherOrigin)};function classify(value,depth=0,seen=new Set){if(depth>value_follow_1.MAX_FOLLOW_DEPTH||seen.has(value.node))return"unknown";seen.add(value.node);const node=(0,type_syntax_1.unwrapTypeSyntax)(value.node);const inner=target=>classify((0,value_follow_1.valueAt)(target,value.env),depth+1,seen);switch(node.type){case ast_node_types_1.AST_NODE_TYPES.AwaitExpression:return inner(node.argument);case ast_node_types_1.AST_NODE_TYPES.ChainExpression:return inner(node.expression);case ast_node_types_1.AST_NODE_TYPES.Identifier:return identifierOrigin(node,(0,value_follow_1.valueAt)(node,value.env),depth,seen);case ast_node_types_1.AST_NODE_TYPES.ThisExpression:return thisOrigin(node,null,value,depth,seen);case ast_node_types_1.AST_NODE_TYPES.MemberExpression:{if(node.object.type===ast_node_types_1.AST_NODE_TYPES.ThisExpression)return thisOrigin(node,(0,spellings_1.propertyName)(node),value,depth,seen);const followed=(0,value_follow_1.follow)((0,value_follow_1.valueAt)(node,value.env));if(followed.node!==node)return classify(followed,depth+1,seen);return inner(node.object)}case ast_node_types_1.AST_NODE_TYPES.CallExpression:{const callee=(0,value_follow_1.follow)((0,value_follow_1.valueAt)(node.callee,value.env));if(isFunctionNode(callee.node)){const returned=(0,value_follow_1.returnedValue)(callee.node);return returned===null?"unknown":classify((0,value_follow_1.valueAt)(returned,callee.env),depth+1,seen)}return inner(node.callee)}case ast_node_types_1.AST_NODE_TYPES.NewExpression:return inner(node.callee);case ast_node_types_1.AST_NODE_TYPES.ClassDeclaration:case ast_node_types_1.AST_NODE_TYPES.ClassExpression:return classOrigin(node,value,depth,seen);case ast_node_types_1.AST_NODE_TYPES.LogicalExpression:return eitherOrigin(inner(node.left),inner(node.right));case ast_node_types_1.AST_NODE_TYPES.ConditionalExpression:return eitherOrigin(inner(node.consequent),inner(node.alternate));case ast_node_types_1.AST_NODE_TYPES.Literal:case ast_node_types_1.AST_NODE_TYPES.TemplateLiteral:case ast_node_types_1.AST_NODE_TYPES.ObjectExpression:case ast_node_types_1.AST_NODE_TYPES.ArrayExpression:case ast_node_types_1.AST_NODE_TYPES.FunctionExpression:case ast_node_types_1.AST_NODE_TYPES.ArrowFunctionExpression:case ast_node_types_1.AST_NODE_TYPES.FunctionDeclaration:return"foreign";default:return"unknown"}}return Object.assign(value=>classify(value),{ofType:value=>typeOrigin(value,0,new Set)})}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isPathAlias=isPathAlias;exports.sourceMatches=sourceMatches;exports.eitherOrigin=eitherOrigin;exports.isFunctionNode=isFunctionNode;exports.writtenAnnotation=writtenAnnotation;exports.createOriginClassifier=createOriginClassifier;const ast_node_types_1=require("../ast-node-types");const spellings_1=require("../ast/spellings");const type_syntax_1=require("../ast/type-syntax");const module_evidence_1=require("./module-evidence");const value_follow_1=require("./value-follow");const PLATFORM_GLOBALS=new Set(["Array","Map","Set","WeakMap","WeakSet","Object","JSON","Math","Promise","Reflect","URL","URLSearchParams","Headers","FormData","Date","globalThis","window","document","console","process","Buffer"]);function isPathAlias(specifier){return/^(?:[@~]\/|~|#)/.test(specifier)}function sourceMatches(source,modules){return modules.some(m=>source===m||source.startsWith(`${m}/`))}function eitherOrigin(a,b){if(a==="ours"||b==="ours")return"ours";return a==="foreign"&&b==="foreign"?"foreign":"unknown"}function isFunctionNode(node){return node.type===ast_node_types_1.AST_NODE_TYPES.FunctionDeclaration||node.type===ast_node_types_1.AST_NODE_TYPES.FunctionExpression||node.type===ast_node_types_1.AST_NODE_TYPES.ArrowFunctionExpression}function writtenAnnotation(identifier){const holder=identifier;return holder.typeAnnotation?.typeAnnotation}function enclosingClass(node){for(let n=node.parent;n;n=n.parent){if(n.type===ast_node_types_1.AST_NODE_TYPES.ClassDeclaration||n.type===ast_node_types_1.AST_NODE_TYPES.ClassExpression){return n}}return void 0}function typeRoot(name){let cursor=name;while(cursor.type===ast_node_types_1.AST_NODE_TYPES.TSQualifiedName)cursor=cursor.left;return cursor.type===ast_node_types_1.AST_NODE_TYPES.Identifier?cursor:null}function createOriginClassifier(modules){const loadsDriver=(0,module_evidence_1.createModuleEvidence)({packages:modules});const classOrigin=(cls,value,depth,seen)=>cls.superClass===null?"foreign":classify((0,value_follow_1.valueAt)(cls.superClass,value.env),depth+1,seen);const declarationOrigin=(value,depth,seen)=>{const node=value.node;if(node.type===ast_node_types_1.AST_NODE_TYPES.TSTypeAliasDeclaration){return typeOrigin((0,value_follow_1.valueAt)(node.typeAnnotation,value.env),depth+1,seen)}if(node.type===ast_node_types_1.AST_NODE_TYPES.TSInterfaceDeclaration){return node.extends.map(base=>classify((0,value_follow_1.valueAt)(base.expression,value.env),depth+1,seen)).includes("ours")?"ours":"foreign"}return classify(value,depth+1,seen)};const typeOrigin=(value,depth,seen)=>{const node=value.node;if(node.type===ast_node_types_1.AST_NODE_TYPES.TSUnionType||node.type===ast_node_types_1.AST_NODE_TYPES.TSIntersectionType){return node.types.map(t=>typeOrigin((0,value_follow_1.valueAt)(t,value.env),depth+1,seen)).reduce(eitherOrigin)}if(node.type===ast_node_types_1.AST_NODE_TYPES.TSTypeQuery){const root2=node.exprName.type===ast_node_types_1.AST_NODE_TYPES.TSImportType?null:typeRoot(node.exprName);return root2===null?"unknown":classify((0,value_follow_1.valueAt)(root2,value.env),depth+1,seen)}if(node.type===ast_node_types_1.AST_NODE_TYPES.TSAnyKeyword||node.type===ast_node_types_1.AST_NODE_TYPES.TSUnknownKeyword){return"unknown"}if(node.type!==ast_node_types_1.AST_NODE_TYPES.TSTypeReference)return"foreign";const root=typeRoot(node.typeName);const variable=(0,value_follow_1.lookup)(root.name,value.env.scopeOf(root));if(variable===null)return"unknown";if(variable.defs.length===0)return"foreign";const specifier=(0,value_follow_1.importSpecifierOf)(variable);if(specifier!==null){if(sourceMatches(specifier.source,modules))return"ours";if(!(0,value_follow_1.isRelativeSpecifier)(specifier.source))return isPathAlias(specifier.source)?"unknown":"foreign";const origin=(0,value_follow_1.importOrigin)(variable,value.env);const exported=origin===null||origin.name==="*"?null:(0,value_follow_1.exportedValue)(origin.module,origin.name,value.env.parser);return exported===null?"unknown":declarationOrigin(exported,depth+1,seen)}return declarationOrigin((0,value_follow_1.valueAt)(variable.defs[0].node,value.env),depth,seen)};const thisOrigin=(at,key,value,depth,seen)=>{const cls=enclosingClass(at);if(cls===void 0)return"unknown";for(const element of key===null?[]:cls.body.body){if(element.type===ast_node_types_1.AST_NODE_TYPES.PropertyDefinition&&!element.computed&&element.key.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&element.key.name===key){if(element.typeAnnotation){return typeOrigin((0,value_follow_1.valueAt)(element.typeAnnotation.typeAnnotation,value.env),depth+1,seen)}return element.value===null?"unknown":classify((0,value_follow_1.valueAt)(element.value,value.env),depth+1,seen)}if(element.type!==ast_node_types_1.AST_NODE_TYPES.MethodDefinition||element.kind!=="constructor"){continue}for(const param of element.value.params){if(param.type!==ast_node_types_1.AST_NODE_TYPES.TSParameterProperty)continue;const inner=param.parameter.type===ast_node_types_1.AST_NODE_TYPES.AssignmentPattern?param.parameter.left:param.parameter;if(inner.type!==ast_node_types_1.AST_NODE_TYPES.Identifier||inner.name!==key)continue;const annotation=writtenAnnotation(inner);return annotation===void 0?"unknown":typeOrigin((0,value_follow_1.valueAt)(annotation,value.env),depth+1,seen)}for(const statement of element.value.body?.body??[]){if(statement.type===ast_node_types_1.AST_NODE_TYPES.ExpressionStatement&&statement.expression.type===ast_node_types_1.AST_NODE_TYPES.AssignmentExpression&&statement.expression.left.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&statement.expression.left.object.type===ast_node_types_1.AST_NODE_TYPES.ThisExpression&&(0,spellings_1.propertyName)(statement.expression.left)===key){return classify((0,value_follow_1.valueAt)(statement.expression.right,value.env),depth+1,seen)}}}return classOrigin(cls,value,depth,seen)==="ours"?"ours":"unknown"};const parameterOrigin=(identifier,fn,value,depth,seen)=>{const annotation=writtenAnnotation(identifier);if(annotation!==void 0){return typeOrigin((0,value_follow_1.valueAt)(annotation,value.env),depth+1,seen)}const call=fn.parent;if(call?.type===ast_node_types_1.AST_NODE_TYPES.CallExpression&&call.callee.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&call.arguments.some(argument=>argument===fn)&&classify((0,value_follow_1.valueAt)(call.callee.object,value.env),depth+1,seen)==="ours"){return"ours"}return"unknown"};const identifierOrigin=(node,value,depth,seen)=>{const variable=(0,value_follow_1.lookup)(node.name,value.scope);if(variable===null)return PLATFORM_GLOBALS.has(node.name)?"foreign":"unknown";if(variable.defs.length===0)return"foreign";const specifier=(0,value_follow_1.importSpecifierOf)(variable);if(specifier!==null){if(sourceMatches(specifier.source,modules))return"ours";if(!(0,value_follow_1.isRelativeSpecifier)(specifier.source))return isPathAlias(specifier.source)?"unknown":"foreign";const followed2=(0,value_follow_1.follow)(value);const judged=followed2.node===value.node||followed2.node.type===ast_node_types_1.AST_NODE_TYPES.Program?"unknown":classify(followed2,depth+1,seen);if(judged!=="unknown")return judged;const origin=(0,value_follow_1.importOrigin)(variable,value.env);return origin!==null&&loadsDriver(origin.module.ast)?"ours":judged}const def=variable.defs[0];if(def.type==="Parameter"){return parameterOrigin(variable.identifiers[0],def.node,value,depth,seen)}if(def.type==="ClassName"){return classOrigin(def.node,value,depth,seen)}if(def.type!=="Variable")return"foreign";const annotation=writtenAnnotation(def.node.id);if(annotation!==void 0){const typed=typeOrigin((0,value_follow_1.valueAt)(annotation,value.env),depth+1,seen);if(typed!=="unknown")return typed}const followed=(0,value_follow_1.follow)(value);if(followed.node!==value.node)return classify(followed,depth+1,seen);const writes=variable.references.filter(r=>r.isWrite()&&r.writeExpr).map(r=>classify((0,value_follow_1.valueAt)(r.writeExpr,value.env),depth+1,seen));return writes.length===0?"unknown":writes.reduce(eitherOrigin)};function classify(value,depth=0,seen=new Set){if(depth>value_follow_1.MAX_FOLLOW_DEPTH||seen.has(value.node))return"unknown";seen.add(value.node);const node=(0,type_syntax_1.unwrapTypeSyntax)(value.node);const inner=target=>classify((0,value_follow_1.valueAt)(target,value.env),depth+1,seen);switch(node.type){case ast_node_types_1.AST_NODE_TYPES.AwaitExpression:return inner(node.argument);case ast_node_types_1.AST_NODE_TYPES.ChainExpression:return inner(node.expression);case ast_node_types_1.AST_NODE_TYPES.Identifier:return identifierOrigin(node,(0,value_follow_1.valueAt)(node,value.env),depth,seen);case ast_node_types_1.AST_NODE_TYPES.ThisExpression:return thisOrigin(node,null,value,depth,seen);case ast_node_types_1.AST_NODE_TYPES.MemberExpression:{if(node.object.type===ast_node_types_1.AST_NODE_TYPES.ThisExpression)return thisOrigin(node,(0,spellings_1.propertyName)(node),value,depth,seen);const followed=(0,value_follow_1.follow)((0,value_follow_1.valueAt)(node,value.env));if(followed.node!==node)return classify(followed,depth+1,seen);return inner(node.object)}case ast_node_types_1.AST_NODE_TYPES.CallExpression:{const callee=(0,value_follow_1.follow)((0,value_follow_1.valueAt)(node.callee,value.env));if(isFunctionNode(callee.node)){const returned=(0,value_follow_1.returnedValue)(callee.node);return returned===null?"unknown":classify((0,value_follow_1.valueAt)(returned,callee.env),depth+1,seen)}return inner(node.callee)}case ast_node_types_1.AST_NODE_TYPES.NewExpression:return inner(node.callee);case ast_node_types_1.AST_NODE_TYPES.ClassDeclaration:case ast_node_types_1.AST_NODE_TYPES.ClassExpression:return classOrigin(node,value,depth,seen);case ast_node_types_1.AST_NODE_TYPES.LogicalExpression:return eitherOrigin(inner(node.left),inner(node.right));case ast_node_types_1.AST_NODE_TYPES.ConditionalExpression:return eitherOrigin(inner(node.consequent),inner(node.alternate));case ast_node_types_1.AST_NODE_TYPES.Literal:case ast_node_types_1.AST_NODE_TYPES.TemplateLiteral:case ast_node_types_1.AST_NODE_TYPES.ObjectExpression:case ast_node_types_1.AST_NODE_TYPES.ArrayExpression:case ast_node_types_1.AST_NODE_TYPES.FunctionExpression:case ast_node_types_1.AST_NODE_TYPES.ArrowFunctionExpression:case ast_node_types_1.AST_NODE_TYPES.FunctionDeclaration:return"foreign";default:return"unknown"}}return Object.assign(value=>classify(value),{ofType:value=>typeOrigin(value,0,new Set)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.looksLikeSqlStatement=looksLikeSqlStatement;exports.createSqlInjectionRule=createSqlInjectionRule;const rule_creator_1=require("./rule-creator");const ast_node_types_1=require("../ast-node-types");const spellings_1=require("../ast/spellings");const type_syntax_1=require("../ast/type-syntax");const messaging_1=require("../messaging");const module_evidence_1=require("./module-evidence");const rule_creator_2=require("./rule-creator");const driver_origin_1=require("./driver-origin");const request_source_1=require("./request-source");const sql_safety_1=require("./sql-safety");const sql_position_1=require("./sql-position");const value_follow_1=require("./value-follow");const SQL_STATEMENTS=[/^[\s(]*select\b[\s\S]*\bfrom\b/i,/^[\s(]*select\s/i,/^\s*insert\s+(?:or\s+\w+\s+|ignore\s+)?into\b/i,/^\s*update\b[\s\S]*\bset\b/i,/^\s*delete\s+from\b/i,/^\s*(?:replace|merge)\s+into\b/i,/^\s*with\b[\s\S]*\bas\s*\(/i,/^\s*(?:create|drop|alter|truncate)\s+(?:unique\s+|temp(?:orary)?\s+|or\s+replace\s+)*(?:table|index|view|schema|database|sequence|trigger|function|procedure|user|role)\b/i,/^\s*(?:pragma|attach|detach|vacuum|analyze|reindex|show|describe|explain)\b/i,/^\s*call\s+[\w".`]+\s*\(/i];const PARTITION_SHARED_SINKS=new Set(["query","execute"]);function looksLikeSqlStatement(text){return SQL_STATEMENTS.some(pattern=>pattern.test(text))}function enclosingFunction(node){for(let n=node.parent;n;n=n.parent){if((0,driver_origin_1.isFunctionNode)(n))return n}return void 0}function callableName(fn){if(fn.type===ast_node_types_1.AST_NODE_TYPES.FunctionDeclaration&&fn.id)return fn.id.name;const parent=fn.parent;if(parent.type===ast_node_types_1.AST_NODE_TYPES.VariableDeclarator&&parent.id.type===ast_node_types_1.AST_NODE_TYPES.Identifier){return parent.id.name}if((parent.type===ast_node_types_1.AST_NODE_TYPES.MethodDefinition||parent.type===ast_node_types_1.AST_NODE_TYPES.PropertyDefinition||parent.type===ast_node_types_1.AST_NODE_TYPES.Property)&&parent.key.type===ast_node_types_1.AST_NODE_TYPES.Identifier){return parent.key.name}return void 0}function createSqlInjectionRule(config){const statementSinks=new Set(config.methods);const fragmentSinks=new Map;for(const sink of config.fragmentMethods??[]){const spec=typeof sink==="string"?{name:sink}:sink;fragmentSinks.set(spec.name,{name:spec.name,arg:spec.arg??0,requireDriverReceiver:spec.requireDriverReceiver??false})}const fragmentFunctions=new Set(config.fragmentFunctions??[]);const aliasCallbacks=new Set(config.aliasCallbacks??[]);const sqlTextProperties=new Set(config.sqlTextProperties??[]);const statementFactories=new Set(config.statementFactories??[]);const usesModule=(0,module_evidence_1.createModuleEvidence)({packages:config.modules});const originOf=(0,driver_origin_1.createOriginClassifier)(config.modules);const safety=(0,sql_safety_1.createSqlSafety)({origin:originOf,escapers:new Set(config.escapers??[]),fragmentFactories:new Set(config.fragmentFactories??[]),modules:config.modules,escaperModules:config.escaperModules});return rule_creator_1.RuleCreator.withoutDocs({meta:{interop:{runtimes:["eslint","oxlint"]},type:config.meta.type,docs:{...config.meta.docs},messages:{noUnsafeQuery:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"Unsafe SQL query detected. Variable interpolation found.",severity:"CRITICAL",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"high",fix:config.fix,documentationLink:config.documentationLink}),unsafeTemplateLiteral:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"Unsafe SQL query construction detected (template literal).",severity:"CRITICAL",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"high",fix:config.fix,documentationLink:config.documentationLink})},schema:[]},defaultOptions:[],createOnce(context){let env;let wrappers;let definitions;let wrapperFns;let pending;let ownsFile;let requestTextSink;const judge=(node,gate,depth=0)=>{const arg=(0,type_syntax_1.unwrapTypeSyntax)(node);if(arg.type===ast_node_types_1.AST_NODE_TYPES.TemplateLiteral||arg.type===ast_node_types_1.AST_NODE_TYPES.BinaryExpression&&arg.operator==="+"){if(arg.type===ast_node_types_1.AST_NODE_TYPES.TemplateLiteral&&arg.expressions.length===0){return false}const kind=arg.type===ast_node_types_1.AST_NODE_TYPES.TemplateLiteral?"template":"concat";const text=(0,sql_safety_1.sqlStaticText)(arg);if(kind==="concat"&&text.trim()==="")return false;if(gate&&!looksLikeSqlStatement(text))return false;return(0,sql_position_1.sqlHoles)(arg).some(isUnsafeHole)?kind:false}if(depth>2)return false;if(arg.type===ast_node_types_1.AST_NODE_TYPES.Identifier){return judgeBinding(arg,gate,depth)}if(arg.type===ast_node_types_1.AST_NODE_TYPES.CallExpression){const target=(0,value_follow_1.follow)((0,value_follow_1.valueAt)(arg.callee,env));if(target.env!==env||!(0,driver_origin_1.isFunctionNode)(target.node))return false;for(const result of(0,value_follow_1.returnedValues)(target.node)??[]){const kind=judge(result,gate,depth+1);if(kind)return kind}}return false};const isUnsafeHole=({expression,preceding})=>!safety.isSafe((0,value_follow_1.valueAt)(expression,env),(0,sql_position_1.isQuoted)(preceding))&&((0,sql_position_1.isValuePosition)(preceding,config.doubleQuotedStrings)||(0,sql_position_1.isRequestDerived)(expression,env));const judgeBinding=(node,gate,depth)=>{const variable=(0,value_follow_1.lookup)(node.name,env.scopeOf(node));if(variable===null||!variable.defs.some(def=>def.type==="Variable")||variable.defs.some(def=>def.type==="Parameter")){return false}const writes=variable.references.filter(r=>r.isWrite()&&r.writeExpr).map(r=>r.writeExpr);const text=writes.map(sql_safety_1.sqlStaticText).join(" ");if(gate&&!looksLikeSqlStatement(text))return false;for(const write of writes){const kind=judge(write,false,depth+1);if(kind)return kind}return false};const isRequestText=node=>{let cursor=(0,type_syntax_1.unwrapTypeSyntax)(node);while(cursor.type===ast_node_types_1.AST_NODE_TYPES.CallExpression&&cursor.callee.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&cursor.callee.name==="String"&&cursor.arguments.length===1){cursor=(0,type_syntax_1.unwrapTypeSyntax)(cursor.arguments[0])}for(let link=cursor;;link=link.object){if((0,request_source_1.isRequestPayload)(link,env))return true;if(link.type!==ast_node_types_1.AST_NODE_TYPES.MemberExpression)return false}};const report=(node,kind)=>{context.report({node,messageId:kind==="template"?"unsafeTemplateLiteral":"noUnsafeQuery"})};const isStatementObject=receiver=>{const value=(0,type_syntax_1.unwrapTypeSyntax)((0,value_follow_1.follow)((0,value_follow_1.valueAt)(receiver,env)).node);return value.type===ast_node_types_1.AST_NODE_TYPES.CallExpression&&value.callee.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&statementFactories.has((0,spellings_1.propertyName)(value.callee)??"")};const check=(arg,gate)=>{let text=(0,type_syntax_1.unwrapTypeSyntax)(arg);if(text.type===ast_node_types_1.AST_NODE_TYPES.ObjectExpression&&sqlTextProperties.size>0){const property=text.properties.find(p=>p.type===ast_node_types_1.AST_NODE_TYPES.Property&&sqlTextProperties.has((0,spellings_1.objectKeyName)(p)??""));if(property===void 0)return;text=property.value}const kind=judge(text,gate);if(kind){report(text,kind);return}if(requestTextSink&&isRequestText(text))report(text,"concat")};const importedName=callee=>{const variable=(0,value_follow_1.lookup)(callee.name,env.scopeOf(callee));const specifier=variable===null?null:(0,value_follow_1.importSpecifierOf)(variable);return specifier!==null&&config.modules.some(m=>specifier.source===m||specifier.source.startsWith(`${m}/`))?specifier.name:null};const checkAliasCallback=node=>{const callback=node.arguments[0];if(!callback||!(0,driver_origin_1.isFunctionNode)(callback))return;const alias=callback.params[0];for(const result of(0,value_follow_1.returnedValues)(callback)??[]){const text=(0,type_syntax_1.unwrapTypeSyntax)(result);if(text.type!==ast_node_types_1.AST_NODE_TYPES.TemplateLiteral)continue;const unsafe=(0,sql_position_1.sqlHoles)(text).some(hole=>!(hole.expression.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&alias?.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&hole.expression.name===alias.name)&&isUnsafeHole(hole));if(unsafe)report(text,"template")}};return{before(){if((0,rule_creator_2.isTestFilePath)(context.filename))return false;env=(0,value_follow_1.envOf)(context);wrappers=new Map;definitions=new Map;wrapperFns=new Map;pending=[];ownsFile=false;requestTextSink=true;return true},Program(program){ownsFile=usesModule(program)},"FunctionDeclaration, FunctionExpression, ArrowFunctionExpression"(node){const name=callableName(node);if(name!==void 0)definitions.set(name,(definitions.get(name)??0)+1)},CallExpression(node){const callee=node.callee;const isMember=callee.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression;const calleeName=isMember?(0,spellings_1.propertyName)(callee)??void 0:callee.type===ast_node_types_1.AST_NODE_TYPES.Identifier?callee.name:void 0;if(calleeName===void 0)return;if(!isMember&&ownsFile){const imported=importedName(callee);if(imported!==null&&fragmentFunctions.has(imported)){requestTextSink=true;if(node.arguments[0])check(node.arguments[0],false);return}if(imported!==null&&aliasCallbacks.has(imported)){checkAliasCallback(node);return}}const fragment=isMember?fragmentSinks.get(calleeName):void 0;if(!isMember||!statementSinks.has(calleeName)&&!fragment){for(const[index,arg]of node.arguments.entries()){if(arg.type===ast_node_types_1.AST_NODE_TYPES.SpreadElement)continue;pending.push({name:calleeName,index,arg})}return}const receiver=originOf((0,value_follow_1.valueAt)(callee.object,env));if(receiver==="foreign")return;if(fragment?.requireDriverReceiver&&receiver!=="ours")return;if(!ownsFile&&!(receiver==="ours"&&!PARTITION_SHARED_SINKS.has(calleeName))){return}const queryArg=node.arguments[fragment?.arg??0];if(!queryArg||queryArg.type===ast_node_types_1.AST_NODE_TYPES.SpreadElement)return;if(queryArg.type===ast_node_types_1.AST_NODE_TYPES.Identifier){const fn=enclosingFunction(node);const index=fn?.params.findIndex(p=>p.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&p.name===queryArg.name)??-1;const name=fn&&index>=0?callableName(fn):void 0;if(name!==void 0&&fn){wrappers.set(name,index);wrapperFns.set(fn,name)}}const gate=fragment===void 0&&config.requireSqlKeywords&&receiver!=="ours";requestTextSink=!isStatementObject(callee.object);check(queryArg,gate)},"Program:exit"(){if(!ownsFile)return;const proven=new Map;for(const name of wrapperFns.values())proven.set(name,(proven.get(name)??0)+1);for(const{name,index,arg}of pending){if(wrappers.get(name)!==index)continue;if(definitions.get(name)!==proven.get(name))continue;const kind=judge(arg,true);if(kind)report((0,type_syntax_1.unwrapTypeSyntax)(arg),kind)}}}}})}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.looksLikeSqlStatement=looksLikeSqlStatement;exports.createSqlInjectionRule=createSqlInjectionRule;const rule_creator_1=require("./rule-creator");const ast_node_types_1=require("../ast-node-types");const spellings_1=require("../ast/spellings");const type_syntax_1=require("../ast/type-syntax");const messaging_1=require("../messaging");const module_evidence_1=require("./module-evidence");const rule_creator_2=require("./rule-creator");const driver_origin_1=require("./driver-origin");const request_source_1=require("./request-source");const sql_safety_1=require("./sql-safety");const sql_position_1=require("./sql-position");const value_follow_1=require("./value-follow");const SQL_STATEMENTS=[/^[\s(]*select\b[\s\S]*\bfrom\b/i,/^[\s(]*select\s/i,/^\s*insert\s+(?:or\s+\w+\s+|ignore\s+)?into\b/i,/^\s*update\b[\s\S]*\bset\b/i,/^\s*delete\s+from\b/i,/^\s*(?:replace|merge)\s+into\b/i,/^\s*with\b[\s\S]*\bas\s*\(/i,/^\s*(?:create|drop|alter|truncate)\s+(?:unique\s+|temp(?:orary)?\s+|or\s+replace\s+)*(?:table|index|view|schema|database|sequence|trigger|function|procedure|user|role)\b/i,/^\s*(?:pragma|attach|detach|vacuum|analyze|reindex|show|describe|explain)\b/i,/^\s*call\s+[\w".`]+\s*\(/i];const PARTITION_SHARED_SINKS=new Set(["query","execute"]);function looksLikeSqlStatement(text){return SQL_STATEMENTS.some(pattern=>pattern.test(text))}function enclosingFunction(node){for(let n=node.parent;n;n=n.parent){if((0,driver_origin_1.isFunctionNode)(n))return n}return void 0}function callableName(fn){if(fn.type===ast_node_types_1.AST_NODE_TYPES.FunctionDeclaration&&fn.id)return fn.id.name;const parent=fn.parent;if(parent.type===ast_node_types_1.AST_NODE_TYPES.VariableDeclarator&&parent.id.type===ast_node_types_1.AST_NODE_TYPES.Identifier){return parent.id.name}if((parent.type===ast_node_types_1.AST_NODE_TYPES.MethodDefinition||parent.type===ast_node_types_1.AST_NODE_TYPES.PropertyDefinition||parent.type===ast_node_types_1.AST_NODE_TYPES.Property)&&parent.key.type===ast_node_types_1.AST_NODE_TYPES.Identifier){return parent.key.name}return void 0}function createSqlInjectionRule(config){const statementSinks=new Set(config.methods);const fragmentSinks=new Map;for(const sink of config.fragmentMethods??[]){const spec=typeof sink==="string"?{name:sink}:sink;fragmentSinks.set(spec.name,{name:spec.name,arg:spec.arg??0,requireDriverReceiver:spec.requireDriverReceiver??false})}const fragmentFunctions=new Set(config.fragmentFunctions??[]);const aliasCallbacks=new Set(config.aliasCallbacks??[]);const sqlTextProperties=new Set(config.sqlTextProperties??[]);const statementFactories=new Set(config.statementFactories??[]);const usesModule=(0,module_evidence_1.createModuleEvidence)({packages:config.modules});const originOf=(0,driver_origin_1.createOriginClassifier)(config.modules);const safety=(0,sql_safety_1.createSqlSafety)({origin:originOf,escapers:new Set(config.escapers??[]),fragmentFactories:new Set(config.fragmentFactories??[]),modules:config.modules,escaperModules:config.escaperModules});return rule_creator_1.RuleCreator.withoutDocs({meta:{interop:{runtimes:["eslint","oxlint"]},type:config.meta.type,docs:{...config.meta.docs},messages:{noUnsafeQuery:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"Unsafe SQL query detected. Variable interpolation found.",severity:"CRITICAL",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"high",fix:config.fix,documentationLink:config.documentationLink}),unsafeTemplateLiteral:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"Unsafe SQL query construction detected (template literal).",severity:"CRITICAL",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"high",fix:config.fix,documentationLink:config.documentationLink})},schema:[]},defaultOptions:[],createOnce(context){let env;let wrappers;let definitions;let wrapperFns;let pending;let ownsFile;const judge=(node,gate,depth=0)=>{const arg=(0,type_syntax_1.unwrapTypeSyntax)(node);if(arg.type===ast_node_types_1.AST_NODE_TYPES.TemplateLiteral||arg.type===ast_node_types_1.AST_NODE_TYPES.BinaryExpression&&arg.operator==="+"){if(arg.type===ast_node_types_1.AST_NODE_TYPES.TemplateLiteral&&arg.expressions.length===0){return false}const kind=arg.type===ast_node_types_1.AST_NODE_TYPES.TemplateLiteral?"template":"concat";const text=(0,sql_safety_1.sqlStaticText)(arg);if(kind==="concat"&&text.trim()==="")return false;if(gate&&!looksLikeSqlStatement(text))return false;return(0,sql_position_1.sqlHoles)(arg).some(isUnsafeHole)?kind:false}if(depth>2)return false;if(arg.type===ast_node_types_1.AST_NODE_TYPES.Identifier){return judgeBinding(arg,gate,depth)}if(arg.type===ast_node_types_1.AST_NODE_TYPES.CallExpression){const target=(0,value_follow_1.follow)((0,value_follow_1.valueAt)(arg.callee,env));if(target.env!==env||!(0,driver_origin_1.isFunctionNode)(target.node))return false;for(const result of(0,value_follow_1.returnedValues)(target.node)??[]){const kind=judge(result,gate,depth+1);if(kind)return kind}}return false};const isUnsafeHole=({expression,preceding})=>!safety.isSafe((0,value_follow_1.valueAt)(expression,env),(0,sql_position_1.isQuoted)(preceding))&&((0,sql_position_1.isValuePosition)(preceding,config.doubleQuotedStrings)||(0,sql_position_1.isRequestDerived)(expression,env));const judgeBinding=(node,gate,depth)=>{const variable=(0,value_follow_1.lookup)(node.name,env.scopeOf(node));if(variable===null||!variable.defs.some(def=>def.type==="Variable")||variable.defs.some(def=>def.type==="Parameter")){return false}const writes=variable.references.filter(r=>r.isWrite()&&r.writeExpr).map(r=>r.writeExpr);const text=writes.map(sql_safety_1.sqlStaticText).join(" ");if(gate&&!looksLikeSqlStatement(text))return false;for(const write of writes){const kind=judge(write,false,depth+1);if(kind)return kind}return false};const isRequestText=node=>{let cursor=(0,type_syntax_1.unwrapTypeSyntax)(node);while(cursor.type===ast_node_types_1.AST_NODE_TYPES.CallExpression&&cursor.callee.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&cursor.callee.name==="String"&&cursor.arguments.length===1){cursor=(0,type_syntax_1.unwrapTypeSyntax)(cursor.arguments[0])}for(let link=cursor;;link=link.object){if((0,request_source_1.isRequestPayload)(link,env))return true;if(link.type!==ast_node_types_1.AST_NODE_TYPES.MemberExpression)return false}};const report=(node,kind)=>{context.report({node,messageId:kind==="template"?"unsafeTemplateLiteral":"noUnsafeQuery"})};const isStatementObject=receiver=>{const value=(0,type_syntax_1.unwrapTypeSyntax)((0,value_follow_1.follow)((0,value_follow_1.valueAt)(receiver,env)).node);return value.type===ast_node_types_1.AST_NODE_TYPES.CallExpression&&value.callee.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&statementFactories.has((0,spellings_1.propertyName)(value.callee)??"")};const check=(arg,gate)=>{let text=(0,type_syntax_1.unwrapTypeSyntax)(arg);if(text.type===ast_node_types_1.AST_NODE_TYPES.ObjectExpression&&sqlTextProperties.size>0){const property=text.properties.find(p=>p.type===ast_node_types_1.AST_NODE_TYPES.Property&&sqlTextProperties.has((0,spellings_1.objectKeyName)(p)??""));if(property===void 0)return;text=property.value}const kind=judge(text,gate);if(kind){report(text,kind);return}if(isRequestText(text))report(text,"concat")};const importedName=callee=>{const variable=(0,value_follow_1.lookup)(callee.name,env.scopeOf(callee));const specifier=variable===null?null:(0,value_follow_1.importSpecifierOf)(variable);return specifier!==null&&config.modules.some(m=>specifier.source===m||specifier.source.startsWith(`${m}/`))?specifier.name:null};const checkAliasCallback=node=>{const callback=node.arguments[0];if(!callback||!(0,driver_origin_1.isFunctionNode)(callback))return;const alias=callback.params[0];for(const result of(0,value_follow_1.returnedValues)(callback)??[]){const text=(0,type_syntax_1.unwrapTypeSyntax)(result);if(text.type!==ast_node_types_1.AST_NODE_TYPES.TemplateLiteral)continue;const unsafe=(0,sql_position_1.sqlHoles)(text).some(hole=>!(hole.expression.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&alias?.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&hole.expression.name===alias.name)&&isUnsafeHole(hole));if(unsafe)report(text,"template")}};return{before(){if((0,rule_creator_2.isTestFilePath)(context.filename))return false;env=(0,value_follow_1.envOf)(context);wrappers=new Map;definitions=new Map;wrapperFns=new Map;pending=[];ownsFile=false;return true},Program(program){ownsFile=usesModule(program)},"FunctionDeclaration, FunctionExpression, ArrowFunctionExpression"(node){const name=callableName(node);if(name!==void 0)definitions.set(name,(definitions.get(name)??0)+1)},CallExpression(node){const callee=node.callee;const isMember=callee.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression;const calleeName=isMember?(0,spellings_1.propertyName)(callee)??void 0:callee.type===ast_node_types_1.AST_NODE_TYPES.Identifier?callee.name:void 0;if(calleeName===void 0)return;if(!isMember&&ownsFile){const imported=importedName(callee);if(imported!==null&&fragmentFunctions.has(imported)){if(node.arguments[0])check(node.arguments[0],false);return}if(imported!==null&&aliasCallbacks.has(imported)){checkAliasCallback(node);return}}const fragment=isMember?fragmentSinks.get(calleeName):void 0;if(!isMember||!statementSinks.has(calleeName)&&!fragment){for(const[index,arg]of node.arguments.entries()){if(arg.type===ast_node_types_1.AST_NODE_TYPES.SpreadElement)continue;pending.push({name:calleeName,index,arg})}return}const receiver=originOf((0,value_follow_1.valueAt)(callee.object,env));if(receiver==="foreign")return;if(fragment?.requireDriverReceiver&&receiver!=="ours")return;if(!ownsFile&&!(receiver==="ours"&&!PARTITION_SHARED_SINKS.has(calleeName))){return}const queryArg=node.arguments[fragment?.arg??0];if(!queryArg||queryArg.type===ast_node_types_1.AST_NODE_TYPES.SpreadElement)return;if(isStatementObject(callee.object))return;if(queryArg.type===ast_node_types_1.AST_NODE_TYPES.Identifier){const fn=enclosingFunction(node);const index=fn?.params.findIndex(p=>p.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&p.name===queryArg.name)??-1;const name=fn&&index>=0?callableName(fn):void 0;if(name!==void 0&&fn){wrappers.set(name,index);wrapperFns.set(fn,name)}}const gate=fragment===void 0&&config.requireSqlKeywords&&receiver!=="ours";check(queryArg,gate)},"Program:exit"(){if(!ownsFile)return;const proven=new Map;for(const name of wrapperFns.values())proven.set(name,(proven.get(name)??0)+1);for(const{name,index,arg}of pending){if(wrappers.get(name)!==index)continue;if(definitions.get(name)!==proven.get(name))continue;const kind=judge(arg,true);if(kind)report((0,type_syntax_1.unwrapTypeSyntax)(arg),kind)}}}}})}
|