Ana*_*uza 5 sql-server encryption msbuild visual-studio sql-server-data-tools
我正在从事企业项目中的存储过程加密.我们有一堆SP应该在生产时受到保护.在每个SP中
设置WITH ENCRYPTION参数没有问题sqlproj.但我想让这个指令可选:如果我在调试模式下构建项目 - 不要应用此过程选项,否则 - 使用它.实际上,这里的主要目标是为没有加密的开发人员提供数据库,但是在生产 - 加密的SP上.
在构建任务中
使用PowerShell脚本我可以修改生成的sql文件,结果得到带有加密参数的脚本,但我想知道它是如何工作的dacpac.
有什么建议?
更新:
花了一些时间玩msbuild.我决定PowerShell在SqlCore目标之后停止(至少现在)使用脚本任务的解决方案:
<Import Project="$(ExtensionTasksPath)MSBuild.ExtensionPack.tasks" Condition="Exists('$(ExtensionTasksPath)MSBuild.ExtensionPack.dll')" />
<UsingTask TaskFactory="PowershellTaskFactory" TaskName="CreateDecryptedScript" AssemblyFile="$(PowerShellTaskAssembly)" Condition="Exists('$(PowerShellTaskAssembly)')">
<ParameterGroup>
<File Required="true" ParameterType="System.String" />
<ResultFile Required="true" ParameterType="System.String" />
</ParameterGroup>
<Task>
<![CDATA[
(Get-Content $file) | Foreach-Object {$_ -replace 'WITH ENCRYPTION', '--WITH ENCRYPTION'} | Set-Content $resultfile
]]>
</Task>
</UsingTask>
<Target Name="CreateDecryptedScript" AfterTargets="SqlCore">
<CreateDecryptedScript File="$(OutputPath)$(CreateScriptFileName)" ResultFile="$(OutputPath)$(DecryptedScriptName)" Condition="Exists('$(PowerShellTaskAssembly)')" />
</Target>
Run Code Online (Sandbox Code Playgroud)
因此,在重建项目之后,我们有了无需加密即可创建数据库的脚本.
但是publish从项目中调用的不会强制发生这种情况,我们将使用加密来改变所有SP.
解密“加密”存储过程很容易。我建议你不要费心去加密它们。
如果必须对它们进行加密,我建议在 DEV 中执行部署后步骤,逐一解密每个加密的存储过程。sp_execsql您可以使用链接中的信息轻松创建这样的步骤。
| 归档时间: |
|
| 查看次数: |
2766 次 |
| 最近记录: |