@interlace/eslint-devkit 1.19.1 → 1.19.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.19.1",
3
+ "version": "1.19.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",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.stripIdentifierGap=stripIdentifierGap;exports.lastClause=lastClause;exports.identifierPosition=identifierPosition;exports.calleeText=calleeText;exports.isExemptExpression=isExemptExpression;exports.tagName=tagName;exports.createRawIdentifierRule=createRawIdentifierRule;const ast_node_types_1=require("../ast-node-types");const messaging_1=require("../messaging");const unscoped_mutation_rule_1=require("./unscoped-mutation-rule");const IDENTIFIER_KEYWORDS=/\b(?:from|join|into|update|table|order\s+by|group\s+by|select|distinct\s+on)$/i;const GAP_CHAR=/[\s"'`[]/;function stripIdentifierGap(text){let end=text.length;while(end>0&&GAP_CHAR.test(text[end-1]))end--;return text.slice(0,end)}const CLAUSE_KEYWORDS=/\b(select|from|where|group\s+by|having|order\s+by|limit|offset|union|returning|values|set)\b/gi;function lastClause(text){const matches=[...text.matchAll(CLAUSE_KEYWORDS)];const last=matches.at(-1);return last?last[1].toLowerCase().replace(/\s+/g," "):""}function identifierPosition(precedingText){if(IDENTIFIER_KEYWORDS.test(stripIdentifierGap(precedingText)))return"identifier";if(lastClause(precedingText)==="order by")return"sortDirection";return false}function calleeText(node){if(node.type===ast_node_types_1.AST_NODE_TYPES.Identifier)return node.name;if(node.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&!node.computed){const object=calleeText(node.object);const property=calleeText(node.property);return object&&property?`${object}.${property}`:""}return""}function isExemptExpression(expr,identifierHelpers,tags){if(expr.type===ast_node_types_1.AST_NODE_TYPES.Literal)return true;if(expr.type===ast_node_types_1.AST_NODE_TYPES.CallExpression){if(identifierHelpers.includes(calleeText(expr.callee)))return true}if(expr.type===ast_node_types_1.AST_NODE_TYPES.TaggedTemplateExpression){const nested=tagName(expr.tag);return nested!==void 0&&tags.includes(nested)}return false}function tagName(tag){if(tag.type===ast_node_types_1.AST_NODE_TYPES.Identifier)return tag.name;if(tag.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&!tag.computed&&tag.property.type===ast_node_types_1.AST_NODE_TYPES.Identifier){return tag.property.name}return void 0}function createRawIdentifierRule(config){const tags=new Set(config.tags);return{meta:{type:config.meta.type,docs:{...config.meta.docs},messages:{identifierInterpolation:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"A table or column name is interpolated into a parameterized query. Bind parameters only ever substitute values, so this identifier is spliced into the SQL as text.",severity:"CRITICAL",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"medium",fix:config.fix,documentationLink:config.documentationLink}),sortDirectionInterpolation:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"A value is interpolated inside an ORDER BY clause, where a bind parameter cannot reach.",severity:"HIGH",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"low",fix:config.sortDirectionFix,documentationLink:config.documentationLink})},schema:[]},defaultOptions:[],create(context){let bindings=new Set;return{Program(program){bindings=(0,unscoped_mutation_rule_1.driverBindings)(program,config.modules)},TaggedTemplateExpression(node){const name=tagName(node.tag);if(name===void 0||!tags.has(name))return;if(config.requireImport){if(node.tag.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return;if(!bindings.has(name))return}const{quasis,expressions}=node.quasi;expressions.forEach((expr,index)=>{if(isExemptExpression(expr,config.identifierHelpers,config.tags))return;const preceding=quasis.slice(0,index+1).map(q=>q.value.raw).join(" ");const position=identifierPosition(preceding);if(position===false)return;context.report({node:expr,messageId:position==="identifier"?"identifierInterpolation":"sortDirectionInterpolation"})})}}}}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.stripIdentifierGap=stripIdentifierGap;exports.lastClause=lastClause;exports.identifierPosition=identifierPosition;exports.calleeText=calleeText;exports.isExemptExpression=isExemptExpression;exports.tagName=tagName;exports.createRawIdentifierRule=createRawIdentifierRule;const ast_node_types_1=require("../ast-node-types");const spellings_1=require("../ast/spellings");const messaging_1=require("../messaging");const unscoped_mutation_rule_1=require("./unscoped-mutation-rule");const IDENTIFIER_KEYWORDS=/\b(?:from|join|into|update|table|order\s+by|group\s+by|select|distinct\s+on)$/i;const GAP_CHAR=/[\s"'`[]/;function stripIdentifierGap(text){let end=text.length;while(end>0&&GAP_CHAR.test(text[end-1]))end--;return text.slice(0,end)}const CLAUSE_KEYWORDS=/\b(select|from|where|group\s+by|having|order\s+by|limit|offset|union|returning|values|set)\b/gi;function lastClause(text){const matches=[...text.matchAll(CLAUSE_KEYWORDS)];const last=matches.at(-1);return last?last[1].toLowerCase().replace(/\s+/g," "):""}function identifierPosition(precedingText){if(IDENTIFIER_KEYWORDS.test(stripIdentifierGap(precedingText)))return"identifier";if(lastClause(precedingText)==="order by")return"sortDirection";return false}function calleeText(node){if(node.type===ast_node_types_1.AST_NODE_TYPES.Identifier)return node.name;if(node.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression){const object=calleeText(node.object);const property=(0,spellings_1.propertyName)(node);return object&&property?`${object}.${property}`:""}return""}function isExemptExpression(expr,identifierHelpers,tags){if(expr.type===ast_node_types_1.AST_NODE_TYPES.Literal)return true;if(expr.type===ast_node_types_1.AST_NODE_TYPES.CallExpression){if(identifierHelpers.includes(calleeText(expr.callee)))return true}if(expr.type===ast_node_types_1.AST_NODE_TYPES.TaggedTemplateExpression){const nested=tagName(expr.tag);return nested!==void 0&&tags.includes(nested)}return false}function tagName(tag){if(tag.type===ast_node_types_1.AST_NODE_TYPES.Identifier)return tag.name;if(tag.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression){return(0,spellings_1.propertyName)(tag)??void 0}return void 0}function createRawIdentifierRule(config){const tags=new Set(config.tags);return{meta:{type:config.meta.type,docs:{...config.meta.docs},messages:{identifierInterpolation:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"A table or column name is interpolated into a parameterized query. Bind parameters only ever substitute values, so this identifier is spliced into the SQL as text.",severity:"CRITICAL",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"medium",fix:config.fix,documentationLink:config.documentationLink}),sortDirectionInterpolation:(0,messaging_1.formatLLMMessage)({icon:messaging_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"A value is interpolated inside an ORDER BY clause, where a bind parameter cannot reach.",severity:"HIGH",cwe:config.meta.docs.cwe,owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"low",fix:config.sortDirectionFix,documentationLink:config.documentationLink})},schema:[]},defaultOptions:[],create(context){let bindings=new Set;return{Program(program){bindings=(0,unscoped_mutation_rule_1.driverBindings)(program,config.modules)},TaggedTemplateExpression(node){const name=tagName(node.tag);if(name===void 0||!tags.has(name))return;if(config.requireImport){if(node.tag.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return;if(!bindings.has(name))return}const{quasis,expressions}=node.quasi;expressions.forEach((expr,index)=>{if(isExemptExpression(expr,config.identifierHelpers,config.tags))return;const preceding=quasis.slice(0,index+1).map(q=>q.value.raw).join(" ");const position=identifierPosition(preceding);if(position===false)return;context.report({node:expr,messageId:position==="identifier"?"identifierInterpolation":"sortDirectionInterpolation"})})}}}}}