c# - 源代码中的 .net 核心连接字符串
问题描述
我正在研究实体框架的 .net 核心示例。
默认示例在数据库上下文的构造函数中包含以下内容。
#warning To protect potentially sensitive information in your connection string, you should move it out of source code.
See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
optionsBuilder.UseSqlServer("Server=servername");
正如警告所述,链接中没有提到它,我已将此反馈提供给 Microsoft。https://github.com/aspnet/EntityFramework.Docs/issues/1269
是否有存储 sql 连接字符串的首选做法?如果连接字符串在 appsettings.json 中,它仍然会在源代码管理中进行跟踪。包含来自 appsettings.json 的未跟踪文件的最佳解决方案是什么?
解决方案
如果攻击者可以访问您的源代码信息,那么无论如何您都会被搞砸。
编译的 .NET 代码可以被反编译,从而允许攻击者泄露敏感数据,例如 db 用户密码。
配置文件可以在发布前加密以隐藏敏感数据。请参阅https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-strings-and-configuration-files#encrypting-configuration-file-sections-using-protected-configuration
推荐阅读
- flutter - 更改flutter BLoC中的placeID后数据未更新
- excel - 无法解决 VBA 数组错误 13 类型不匹配
- node.js - 如何使用驱动程序管理客户端加密数据密钥?
- angular - Angular NgFor 总是从输入的对象中获取最后一个值
- vim - 如何在 Vim 缓冲区中找到“<html>”?
- shopify - 无需 Shopify 应用程序即可在 Shopify 中自动导出自定义报告
- google-colaboratory - Colab 经常断开连接
- vue.js - Vue 组件数据对象属性的行为不符合预期 [已解决]
- reactjs - 如何将一个组件中查询的数据传递给另一个组件以用作查询变量?
- angular - 从服务器端接收多个通知