简体   繁体   English

保护Web应用程序源代码的最佳做法?

[英]Best practices for protecting web application source code?

I am looking for best practices in how to secure/protect my web application code from being viewed/stolen/used. 我正在寻找有关如何保护/保护我的Web应用程序代码以免被查看/窃取/使用的最佳实践。 I am also looking into how to limit the amount of visible code ie, what should go in the server, and what in the client? 我也在研究如何限制可见代码的数量,即服务器中应包含哪些内容,客户端应包含哪些内容?

I am new to web dev so I am just learning about things like JavaScript is extremely difficult to protect. 我是Web开发人员的新手,所以我只是在学习像JavaScript这样的极难保护的事物。

I've read this thread how to protect jsp pages from being open source and duplicates that have been made, but these are older questions. 我已经阅读了该线程, 如何保护jsp页面免于开源和复制,但这是较老的问题。

I was curious what approaches are good ones to take if we have to use JavaScript/jQuery? 我很好奇,如果必须使用JavaScript / jQuery,哪种方法是好的? As mentioned above what kinds of logic should be on the server, what should be in the client? 如上所述,服务器上应采用哪种逻辑,客户端应采用什么逻辑? Does node.js do anything to stop the code from being shown or does it only serve js to the client (or do something else entirely)? node.js会采取任何措施阻止代码显示吗,还是只将js提供给客户端(或完全执行其他操作)?

I have read up and found a few applications that seem good, but as many have said it's "impossible to 100% protect Javascript code." 我已经阅读并发现了一些看起来不错的应用程序,但是正如许多人所说的那样,“不可能100%保护Javascript代码”。

https://github.com/jxcore/jxcore-release https://github.com/jxcore/jxcore-release

https://jscrambler.com/en/ https://jscrambler.com/en/

http://docs.sonhlab.com/protect-javascript-from-copying/ http://docs.sonhlab.com/protect-javascript-from-copying/

https://developers.google.com/closure/?csw=1 https://developers.google.com/closure/?csw=1

Are any of these good? 这些好吗? Is jscrambler worth the money? jscrambler值得花这笔钱吗?

I am also curious what other code (besides HTML and CSS) is available for people to view on the client? 我也很好奇人们可以在客户端上查看其他哪些代码(HTML和CSS除外)?

I also want to explain a little bit about the application I am trying to develop. 我还想解释一下我要开发的应用程序。 I am in the process of developing an application that draws shapes on the screen using SVG. 我正在开发一个使用SVG在屏幕上绘制形状的应用程序。 From there I have menu options to change the objects, ie, instead of a color, switch the element with its image that's provided. 从那里,我有菜单选项来更改对象,即,用颜色代替提供的图像来切换元素。 I wanted this to be fully AJAX and change instantly when the menu is clicked. 我希望它完全是AJAX,并在单击菜单时立即进行更改。 I am using jQuery for everything, and reading in my data via JSON which is on my server. 我正在使用jQuery进行所有操作,并通过服务器上的JSON读取数据。

Originally I was working with JSP/Servlets, but I still needed to create the data via SVG and do things with jQuery and AJAX, so I believe this would still have visible code. 最初,我使用JSP / Servlet,但是我仍然需要通过SVG创建数据并使用jQuery和AJAX进行操作,因此我相信这仍然会有可见的代码。

I do secure my application using Apache Shiro for authentication and authorization, but I also will be setting up a guest account for people to try out the product, so that limits how much security I do have on the source code if anyone can view the trial account. 我确实使用Apache Shiro进行身份验证和授权来保护我的应用程序的安全,但是我还将设置一个访客帐户来供人们试用该产品,以限制如果有人可以查看该试用版,我对源代码的安全性。帐户。

Most of my code is not in jQuery/JavaScript just the drawing of my elements. 我的大多数代码不只是在jQuery / JavaScript中绘制我的元素。 Eventually this will grow, so I am concerned overall. 最终,这种情况将会增长,因此,我总体上感到关注。 So I am curious, what are some best practices that one should take in order to make sure their application code is as protected as possible? 所以我很好奇,为了确保其应用程序代码受到尽可能的保护,应该采取哪些最佳实践?

What are some best practices in regards to what code should go where (or is that based on preference? I would assume there would be some useful tips though). 关于什么代码应该放在哪里有什么最佳实践(或者是基于首选项的?我会假设有一些有用的技巧)。

I too landed in a similar situation. 我也遇到了类似的情况。 This is what finally I adopted. 这就是我最终采纳的。 Basis for the decision primarily boiled down to following criteria 决定的依据主要归结为以下标准
1. Ease of maintenance - Just because I have to protect, should not impact my development version. 1.易于维护-仅出于保护目的,不应影响我的开发版本。 Also, it should be easier to release patches. 另外,应该更容易发布补丁。 Support cross platform installations and upgrades 2. Automating the process of protecting the source with Continuous Integration / deployment. 支持跨平台的安装和升级。2.通过持续集成/部署来自动化保护源的过程。
3. Time taken to decode the source code and make sense of it - Any skilled professionals would not spend huge effort in decrypting the source code as they can build one using that time. 3.解码和理解源代码所花费的时间-任何熟练的专业人员都不会花费很大的精力来解密源代码,因为他们可以使用这段时间来构建源代码。 Others who spend that much time in decrypting will not have that much skill to compete with us in guiding the product roadmap. 其他花费大量时间进行解密的人将没有那么多的技能来与我们竞争指导产品路线图。
Now coming to the answer 现在来回答
1. Client side protection: As the code runs in the browser and we are not interested in the log files, proven methodologies of script concatenation and obfuscation (uglify) would be good enough. 1.客户端保护:由于代码在浏览器中运行,并且我们对日志文件不感兴趣,因此经过验证的脚本连接和混淆(uglify)方法将足够了。

  1. Server side protection: This is required only when you do a license sale or deployed in customer site as otherwise (platform as a service) you would have protected access to these files. 服务器端保护:仅当您进行许可证销售或部署在客户站点中时才需要这样做,否则(平台即服务)您将可以保护对这些文件的访问。 So, when it is required, as we will also be interested in the log files too, the best option would be to go with exe. 因此,在需要时,因为我们也会对日志文件也感兴趣,所以最好的选择是使用exe。 The closest that is available for NodeJS platform to create something "like" exe is EncloseJS. 可用于NodeJS平台创建“类似” exe文件的最接近的是EncloseJS。 Here the problems are unoptimized code, tightly coupled nodejs version, etc. But, won't we normally tradeoff one for another in our architecture? 这里的问题是未优化的代码,紧密耦合的nodejs版本等。但是,我们通常不会在我们的体系结构中权衡吗? The other option is JXCore. 另一个选项是JXCore。 I am not able to get enough documentation on it as most of the doc links based on jxcore.com were breaking. 我无法获得足够的文档,因为基于jxcore.com的大多数文档链接都已断开。 It encrypts the source code and creates the package. 它加密源代码并创建程序包。 We execute our nodejs app through jxcore which decrypts the code before executing it. 我们通过jxcore执行我们的nodejs应用程序,该代码在执行之前将代码解密。 The problem is how the encryption key is stored and retrieved at the time of decryption as they employ symmetric encryption. 问题在于,由于解密密钥采用对称加密,因此在解密时如何存储和检索加密密钥。 (I am not too sure). (我不太确定)。

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

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