《电子技术应用》
您所在的位置:首页 > 其他 > 设计应用 > 函数级别的复用开源代码检测方法
函数级别的复用开源代码检测方法
信息技术与网络安全
张德浩1,2,徐 云1,2
(1.中国科学技术大学 计算机科学与技术学院,安徽 合肥230027; 2.中国科学技术大学 国家高性能计算中心,安徽 合肥230026)
摘要: 软件开发中对开源代码的复用会带来开源代码漏洞和违反开源许可等问题。传统复用代码检测方法常常检出较多偶然克隆代码,影响了复用代码的检测准确性。为此,提出了一种基于复用度量指标的函数级别复用开源代码检测方法。该方法对被测代码和开源代码库,先使用克隆检测工具获取克隆函数,然后使用依据克隆代码行和共用标识符在开源代码库中的出现频率的复用度量指标,判定每对克隆函数是否为复用。在公开有标注数据集和真实数据集上的实验结果均表明所提方法优于基于逆文档频率的方法。
中图分类号: TP311.52
文献标识码: A
DOI: 10.19358/j.issn.2096-5133.2021.06.004
引用格式: 张德浩,徐云. 函数级别的复用开源代码检测方法[J].信息技术与网络安全,2021,40(6):22-27,49.
A method for function-level open-source code reuse detection
Zhang Dehao1,2,Xu Yun1,2
(1.School of Computer Science and Technology,University of Science and Technology of China,Hefei 230027,China; 2.National High Performance Computing Center,University of Science and Technology of China,Hefei 230026,China)
Abstract: Open-source code reuse in software development may cause problems such as code vulnerabilities and license violations. Existing code reuse detection methods often report a large amount of accidentally cloned code, which hampers the accuracy of reuse detection. To this end, a method for function-level open-source code reuse detection based on a novel metric is proposed. Cloned functions between developed code and an open-source code repository are firstly detected using a clone detection tool. A metric based on frequencies in the repository of cloned lines and shared identifiers between two functions is calculated to determine whether cloned functions are reused ones. The experimental results on a publicly available labeled dataset and on real-world code repositories show that the proposed method performs better than the method based on inverse document frequency.
Key words : code reuse;open-source software;code clone;accidental clone;code metric

0 引言

随着软件规模的日益增长和开源生态的发展,复用开源代码成为节省软件开发时间成本和人力成本的有效手段[1]。然而,复用开源代码存在引入开源漏洞和违反开源许可等问题。例如,基于Android的移动操作系统CyanogenMod使用含有漏洞的JDK 1.5示例代码解析证书,导致系统易于遭受中间人攻击[2]。又如,Oracle查出Google在其Android项目中复用了来自OracleJDK的rangeCheck函数源码和若干文件的反编译源码,为此双方展开长达数年的诉讼[3]。因此,有必要检测开发软件中函数级别的复用开源代码。

由于复用代码之间本身的相似性,使用代码克隆检测工具可以检测到复用代码。与此同时,现有的克隆检测工具检出的克隆代码中,还常常包含大量由于偶然原因而相似的代码,称为偶然克隆[4-5],并非复用代码。由于一些高度相似甚至相同的常见函数可能是偶然克隆(例如Java中的hashCode、equals等函数),而一些经过修改的复用代码与被复用的原始代码不完全相同,因此在代码克隆检测之后需要一种更为精准的方法检测复用代码,以减少偶然克隆代码的影响。据了解,关于复用代码检测的现有研究极少考虑到偶然克隆代码的影响,而关于偶然克隆的现有研究大多为实证研究[4-6],目前尚未应用到复用代码检测上。



本文详细内容请下载:http://www.chinaaet.com/resource/share/2000003595




作者信息:

张德浩1,2,徐  云1,2

(1.中国科学技术大学 计算机科学与技术学院,安徽 合肥230027;

2.中国科学技术大学 国家高性能计算中心,安徽 合肥230026)


此内容为AET网站原创,未经授权禁止转载。