异常源代码变更的信息论检测
Information-Theoretic Detection of Unusual Source Code Changes
AI总结:
本文从信息论角度定义源代码的文本熵与结构熵,分析95个开源项目并验证其不同于经典复杂度指标,实现精确率超60%的异常代码变更检测。
摘要:
软件项目的代码库本质上是通过向源代码中插入信息以及从源代码中移除信息而不断演化的。我们可以借助代码相应表示中的信息元素——token、词语和节点——来度量这种演化。在本研究中,我们从信息论的角度来度量开源项目源代码的信息内容。我们关注代码的两种基本表示的熵:token和抽象语法树节点,并由此推导文本熵与结构熵的定义。随后,我们进行了一项实证评估,考察95个被积极维护的开源项目的熵演化模式。我们计算了所推导的熵指标与经典代码复杂度度量方法之间的统计关系,发现熵所捕捉的复杂度维度可能不同于经典指标。最后,我们开展了基于熵的异常变更检测,以证明该方法能够有效识别异常源代码变更事件,精确率超过60%;本研究为改进源代码演化的信息论度量奠定基础,从而为在整个开发过程中静态评估程序复杂度提供一种新方法铺平道路。
英文摘要:
The code base of software projects evolves essentially through inserting and removing information to and from the source code. We can measure this evolution via the elements of information - tokens, words, nodes - of the respective representation of the code. In this work, we approach the measurement of the information content of the source code of open-source projects from an information-theoretic standpoint. Our focus is on the entropy of two fundamental representations of code: tokens and abstract syntax tree nodes, from which we derive definitions of textual and structural entropy. We proceed with an empirical assessment where we evaluate the evolution patterns of the entropy of 95 actively maintained open source projects. We calculate the statistical relationships between our derived entropy metrics and classic methods of measuring code complexity and learn that entropy may capture different dimensions of complexity than classic metrics. Finally, we conduct entropy-based anomaly detection of unusual changes to demonstrate that our approach may effectively recognise unusual source code change events with over 60% precision, and lay the groundwork for improvements to information-theoretic measurement of source code evolution, thus paving the way for a new approach to statically gauging program complexity throughout its development.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。