Giter VIP home page Giter VIP logo

Comments (4)

XiaoHeitu avatar XiaoHeitu commented on September 3, 2024

参数化有一个优势是天生可防御sql注入。这个问题可能需要一起考虑。

from smartsql.

xiangxiren avatar xiangxiren commented on September 3, 2024

foreach (var itemVal in enumParams)
{
string itemParamName = $"{paramName}_{itemIndex}";
inParamSql.AppendFormat("{0}{1},", _dbPrefix, itemParamName);
context.Parameters.TryAdd(itemParamName, itemVal);
itemIndex++;
}

通过集合的第一个元素判断集合元素类型,如果是int,long等数字类型就直接拼接,bool类型转换成0/1再拼接,字符串用'包围,日期转换成字符串再用'包含后拼接,应该不会有注入问题

from smartsql.

xuejmnet avatar xuejmnet commented on September 3, 2024

efcore是判断你是常量还是变量如果是变量那么就是参数化如果是常量才是直接在sql中

from smartsql.

xiangxiren avatar xiangxiren commented on September 3, 2024

efcore是判断你是常量还是变量如果是变量那么就是参数化如果是常量才是直接在sql中

我这项目里有很多查询都依赖于用户当前有权限的组织,所以组织每次都是通过调接口获取的。然后生成的查询里,组织Id都是直接在SQL里,并没有参数化。

from smartsql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.