《電子技術(shù)應(yīng)用》
您所在的位置:首頁 > 其他 > 设计应用 > 函数级别的复用开源代码检测方法
函数级别的复用开源代码检测方法
信息技术与网络安全
张德浩1,2,徐 云1,2
(1.中国科学技术大学 计算机科学与技术学院,安徽 合肥230027; 2.中国科学技术大学 国家高性能计算中心,安徽 合肥230026)
摘要: 软件开发中对开源代码的复用会带来开源代码漏洞和违反开源许可等问题。传统复用代码检测方法常常检出较多偶然克隆代码,影响了复用代码的检测准确性。为此,提出了一种基于复用度量指标的函数级别复用开源代码检测方法。该方法对被测代码和开源代码库,先使用克隆检测工具获取克隆函数,然后使用依据克隆代码行和共用标识符在开源代码库中的出现频率的复用度量指标,判定每对克隆函数是否为复用。在公开有标注数据集和真实数据集上的实验结果均表明所提方法优于基于逆文档频率的方法。
中圖分類號: TP311.52
文獻(xiàn)標(biāo)識碼: A
DOI: 10.19358/j.issn.2096-5133.2021.06.004
引用格式: 張德浩,徐云. 函數(shù)級別的復(fù)用開源代碼檢測方法[J].信息技術(shù)與網(wǎng)絡(luò)安全,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 引言

隨著軟件規(guī)模的日益增長和開源生態(tài)的發(fā)展,復(fù)用開源代碼成為節(jié)省軟件開發(fā)時(shí)間成本和人力成本的有效手段[1]。然而,復(fù)用開源代碼存在引入開源漏洞和違反開源許可等問題。例如,基于Android的移動(dòng)操作系統(tǒng)CyanogenMod使用含有漏洞的JDK 1.5示例代碼解析證書,導(dǎo)致系統(tǒng)易于遭受中間人攻擊[2]。又如,Oracle查出Google在其Android項(xiàng)目中復(fù)用了來自O(shè)racleJDK的rangeCheck函數(shù)源碼和若干文件的反編譯源碼,為此雙方展開長達(dá)數(shù)年的訴訟[3]。因此,有必要檢測開發(fā)軟件中函數(shù)級別的復(fù)用開源代碼。

由于復(fù)用代碼之間本身的相似性,使用代碼克隆檢測工具可以檢測到復(fù)用代碼。與此同時(shí),現(xiàn)有的克隆檢測工具檢出的克隆代碼中,還常常包含大量由于偶然原因而相似的代碼,稱為偶然克隆[4-5],并非復(fù)用代碼。由于一些高度相似甚至相同的常見函數(shù)可能是偶然克隆(例如Java中的hashCode、equals等函數(shù)),而一些經(jīng)過修改的復(fù)用代碼與被復(fù)用的原始代碼不完全相同,因此在代碼克隆檢測之后需要一種更為精準(zhǔn)的方法檢測復(fù)用代碼,以減少偶然克隆代碼的影響。據(jù)了解,關(guān)于復(fù)用代碼檢測的現(xiàn)有研究極少考慮到偶然克隆代碼的影響,而關(guān)于偶然克隆的現(xiàn)有研究大多為實(shí)證研究[4-6],目前尚未應(yīng)用到復(fù)用代碼檢測上。



本文詳細(xì)內(nèi)容請下載:http://m.ihrv.cn/resource/share/2000003595




作者信息:

張德浩1,2,徐  云1,2

(1.中國科學(xué)技術(shù)大學(xué) 計(jì)算機(jī)科學(xué)與技術(shù)學(xué)院,安徽 合肥230027;

2.中國科學(xué)技術(shù)大學(xué) 國家高性能計(jì)算中心,安徽 合肥230026)


此內(nèi)容為AET網(wǎng)站原創(chuàng),未經(jīng)授權(quán)禁止轉(zhuǎn)載。

相關(guān)內(nèi)容