简体   繁体   English

隐藏编程人员的部分代码

[英]Hiding parts of my code from a programmer employee

I am working on a C# project and have two programmers to help me on parts of the project. 我正在从事C#项目,并且有两个程序员来帮助我完成部分项目。 The problem is that I don't trust these programmers as they are joining recently and need to protect my company's property. 问题是我不信任这些程序员,因为他们最近才加入,需要保护我公司的财产。

I need to hide some parts of the code from the two programmers so they don't see it and they should still be able to work on their parts and run the full application to test it. 我需要向两位程序员隐藏代码的某些部分,以便他们看不到它们,并且他们仍然应该能够按部就班并运行完整的应用程序进行测试。

Is there such thing ? 有这样的事吗? :) :)

Know a few things: 知道几件事:

You Can't Hide Code Users Compile Against. 您不能隐藏代码用户进行编译。

C# makes it incredibly easy to see what you're compiling against, but this is actually true for all programming languages: if they are required to compile it, compile against a dll, or they can run it, either as a DLL or as raw C#, they can get access to the logic behind it. C#使得查看您要编译的内容变得异常容易,但这实际上适用于所有编程语言:如果需要它们进行编译,针对dll进行编译,或者它们可以作为DLL或原始文件运行, C#,他们可以访问其背后的逻辑。 There's no way around that. 没有办法解决。 If the computer can run the program and it all resides on your PC, then the human can look it over and learn how to do it too. 如果计算机可以运行该程序并且所有程序都驻留在您的PC上,那么人类可以查看该程序并学习如何做。

HOWEVER! 然而! You can design your program in such a way that they don't need to compile against it. 您可以以不需要编译的方式设计程序。

Use Interfaces. 使用接口。

Make the code that the other employees must write a plug-in. 编写其他员工必须编写插件的代码。 Have them write their code as an entirely separate project to an interface that the core part of your API loads dynamically at run time. 让他们将代码作为完全独立的项目编写到接口,该接口的API核心部分在运行时动态加载。

Take a look at The Managed Extensibility Framework for a tool to do this. 查看用于此目的的工具的可扩展性框架

Use Web or Remote Services. 使用Web或远程服务。

Components of particular secrecy can be abstracted away so the details of how it works can be hidden and then invoked via a web call. 可以将具有特殊机密性的组件抽象化,因此可以隐藏其工作原理的详细信息,然后通过网络调用将其调用。 This only works in situations where the core details you want to protect are not time sensitive. 这仅在您要保护的核心详细信息对时间不敏感的情况下有效。 This also doesn't protect the idea behind the feature: the employee will need to understand it's purpose to be able to use it, and that alone is enough to rebuild it from scratch. 这也并不能保护该功能背后的思想 :员工将需要了解能够使用它的目的,仅此一项就足以从头开始重建它。

Build Trust Through Code Reviews. 通过代码审查建立信任。

If you don't currently trust your employees, you need to develop it. 如果您当前不信任员工,则需要发展它。 You will not be able to know everything that everyone does always. 您将无法知道每个人总是做的所有事情。 This is a key skill in not just programming, but life. 这不仅是编程的关键技能,也是生活的关键技能。 If you feel that you can't ever trust them, then you either need to hire new employees that you can trust, or build trust in them. 如果您觉得自己永远不信任他们,那么您要么需要雇用可以信任的新员工,要么就可以建立信任。

One way to build trust in their capabilities is through code reviews. 建立对其功能的信任的一种方法是通过代码审查。 First, make sure you're using a version control system that allows for easy branching. 首先,请确保您使用的版本控制系统易于分支。 If you aren't, switch immediately to Mercurial *. 如果不是,请立即切换到Mercurial *。 Have an "integration" area and individual development areas, usually through cloned branches or named branches. 通常通过克隆的分支机构或命名的分支机构,具有“集成”区域和单个开发区域。 Before they commit code, get together with the employee and review the changes. 在他们提交代码之前,请与员工聚会并检查更改。 If you're happy with them, then have them commit it. 如果您对他们满意,请让他们提交。 This will consume a little bit of time on each commit, but if you do quick iterations on changes, then the reviews will also be quick. 每次提交都将花费一点时间,但是如果您对更改进行快速迭代,则审核也会很快。

Build Trust Through Camaraderie. 通过友情建立信任。

If you don't trust your employees, chances are they won't trust you either. 如果您不信任您的员工,他们很可能也不会信任您。 Mutual distrust will not breed loyalty. 相互之间的不信任不会滋生忠诚。 Without loyalty, you have no protection. 没有忠诚,就没有保护。 If they have access to your repository, and you don't trust them, there's a good chance they can get at the code you want anyway with a little bit of effort. 如果他们可以访问您的存储库,并且您不信任他们,那么他们很有可能反而会花点力气就能得到您想要的代码。

Most people are honest most of the time. 大多数人在大多数时间都是诚实的。 Work with them. 与他们一起工作。 Learn about them. 了解他们。 If one turns out to be working for a hostile entity, they've probably already obtained what they wanted to get and you're screwed anyway. 如果事实证明是在为一个敌对实体工作,那么他们可能已经获得了他们想要获得的东西,反正您被搞砸了。 If one turns out to be a pathological liar or incompetent, replace them immediately. 如果发现是病态的骗子或不称职,请立即将其更换。 Neither of these issues will be saved by "protecting" your code from their eyes. 通过从您的眼睛“保护”您的代码不会解决这些问题。

Perform Background Checks. 执行背景检查。

A further way to improve trust in your employee, from a security standpoint, is a background check. 从安全的角度来看,提高员工信任度的另一种方法是进行背景调查。 A couple hundred bucks and a few days, and you can find out all sorts of information about them. 几百美元和几天的时间,您就可以找到关于它们的各种信息。 If you're ready to hide code from them, and you're the employer, you might as well do due diligence before they steal the secrets to the universe. 如果您准备向他们隐藏代码,并且您是雇主,那么在他们窃取宇宙秘密之前,您还可以尽职调查。

Your Code is Not That Important. 您的代码不是那么重要。

I hate to break it to you, but there's almost a 100% chance that your code is not special. 我不愿意将它透露给您,但是您的代码不是特别的几率几乎为100%。 Trying to protect it through obscurity is a waste of time and a known, poor, protection method. 试图通过模糊保护它是浪费时间,并且是一种已知的,糟糕的保护方法。

Good luck! 祝好运!

**Why Mercurial? **为什么要水银? Just because it's one option that's easy to get started with. 只是因为这是一个很容易上手的选项。 Feel free to use any other, like Git, if it suits your fancy. 如果适合,请随意使用其他任何工具,例如Git。 Which one you use is entirely besides the point and irrelevant to this overall discussion.* 您所使用的是完全不重要的,与本次总体讨论无关。*

You can't do it, 你做不到

Even if you only give them a DLL with your code, they can extract the code with reflection tools, eg reflector . 即使您只给他们代码提供DLL,他们也可以使用反射工具(例如reflector提取代码。

保留单独的备份,然后将虚拟占位符提交给源代码管理。

The complicated way: set up an application server with VS2010 and all the files they need, lock everything down so they cannot access any files directly and can only run VS2010 and the built application, and provide only DLLs for the protected code. 复杂的方法:使用VS2010及其所需的所有文件设置应用程序服务器,锁定所有内容,以使它们无法直接访问任何文件,并且只能运行VS2010和已构建的应用程序,并且仅提供受保护代码的DLL。

Theoretically, they would be able to work on the code they need to but would never have direct access to the DLLs, nor would they have the ability to install or use a tool such as .NET Reflector to disassemble the files... might still be some holes you'd need to look for though. 从理论上讲,他们将能够处理所需的代码,但永远无法直接访问DLL,也无法安装或使用.NET Reflector之类的工具来分解文件...还是需要一些漏洞。

The right way: Hire trustworthy programmers. 正确的方法:雇用值得信赖的程序员。 ;) ;)

将您的代码放入DLL中,并使用Dotfuscator混淆内部工作原理。

The only way I can see is to give them compiled and obfuscated assemblies to reference. 我能看到的唯一方法是让它们经过编译和混淆的程序集可供参考。 Because you can only obfuscate private members you may possibly need to modify your code so that public methods do not do much if anything at all. 因为只能混淆私有成员,所以可能需要修改代码,以使公共方法根本不做任何事情。 If there is any interesting code in a public method you should rearrange your code like this: 如果公共方法中有任何有趣的代码,则应重新排列代码,如下所示:

public bool ProcessSomething()
{
    return this.DoProcessSomething();
}

private bool DoProcessSomething()
{
    // your code
}

Even obfuscator that comes free with VS will do some job to make it non-trivial to look into your code. 甚至VS附带的混淆器也将做一些工作,以使查看代码变得轻而易举。 If you require more protection you need better obfuscator of course. 如果您需要更多保护,那么您当然需要更好的混淆器。

But in the long run it is impractical and sends bad signals to those developers telling that you do not trust them. 但是从长远来看,这是不切实际的,并且会向那些开发人员发送不良信号,告知您不信任他们。 There can be nothing good coming out of this. 从这出来可能没有什么好处。 If you're not the boss (or owner of the code) I would not worry that much - after all it's not your property. 如果您不是老板(或代码的所有者),那么我就不必担心-毕竟这不是您的财产。 You can talk to your boss to express your concerns. 您可以与老板交谈,表达您的担忧。 If you are the boss you should have not employed people you do not trust in the first place. 如果您是老板,那么您本来就不应雇用不信任您的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM