Stubbifier:消除动态服务器端JavaScript应用程序的膨胀
Stubbifier: Debloating Dynamic Server-Side JavaScript Applications
摘要:
JavaScript是一种越来越受欢迎的服务器端开发语言,部分原因是Node.js运行时环境及其庞大的模块生态系统。使用Node.js包管理器npm,用户可以轻松地将外部模块作为依赖项包含在项目中。然而,npm安装模块及其所有功能,即使只需要一小部分,这会导致代码大小的过度增加。从发行版中消除这种未使用的功能是可取的,但是由于JavaScript的极端动态性,找到未使用的代码所需的合理分析是困难的。我们提出了一个全自动的技术,通过构建静态或动态调用图从应用程序的测试,并取代代码被认为是无法访问的文件或函数级存根识别未使用的代码。如果调用存根,它将按需获取并执行原始代码,从而放松对调用图可靠性的要求。该技术还提供了一个可选的保护执行模式,以保护应用程序免受注入漏洞,在未经测试的代码,导致存根扩展。这项技术在一个名为Stubbifier的开源工具中实现,该工具支持ECMAScript 2019标准。在对15个Node.js应用程序和这些应用程序的75个客户端进行的实证评估中,Stubbifier平均将应用程序大小减少了56%,同时仅产生轻微的性能开销。评估还表明,Stubbifier的保护执行模式能够防止几个已知的注入漏洞,这些漏洞表现在隐藏的代码中。最后,Stubbifier还可以与一些流行的JavaScript工具一起工作,这些工具用于将应用程序与其依赖项捆绑在一起。对于所考虑的主题应用程序,我们测量到捆绑发行版的平均大小减少了37%。
英文摘要:
JavaScript is an increasingly popular language for server-side development, thanks in part to the Node.js runtime environment and its vast ecosystem of modules. With the Node.js package manager npm, users are able to easily include external modules as dependencies in their projects. However, npm installs modules with all of their functionality, even if only a fraction is needed, which causes an undue increase in code size. Eliminating this unused functionality from distributions is desirable, but the sound analysis required to find unused code is difficult due to JavaScript's extreme dynamicity. We present a fully automatic technique that identifies unused code by constructing static or dynamic call graphs from the application's tests, and replacing code deemed unreachable with either file- or function-level stubs. If a stub is called, it will fetch and execute the original code on-demand, thus relaxing the requirement that the call graph be sound. The technique also provides an optional guarded execution mode to guard application against injection vulnerabilities in untested code that resulted from stub expansion. This technique is implemented in an open source tool called Stubbifier, which supports the ECMAScript 2019 standard. In an empirical evaluation on 15 Node.js applications and 75 clients of these applications, Stubbifier reduced application size by 56% on average while incurring only minor performance overhead. The evaluation also shows that Stubbifier's guarded execution mode is capable of preventing several known injection vulnerabilities that are manifested in stubbed-out code. Finally, Stubbifier can work alongside bundlers, popular JavaScript tools for bundling an application with its dependencies. For the considered subject applications, we measured an average size reduction of 37% in bundled distributions.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。