《電子技術(shù)應(yīng)用》
您所在的位置:首頁 > 其他 > 設(shè)計(jì)應(yīng)用 > 函數(shù)級別的復(fù)用開源代碼檢測方法
函數(shù)級別的復(fù)用開源代碼檢測方法
信息技術(shù)與網(wǎng)絡(luò)安全
張德浩1,,2,,徐 云1,2
(1.中國科學(xué)技術(shù)大學(xué) 計(jì)算機(jī)科學(xué)與技術(shù)學(xué)院,,安徽 合肥230027,; 2.中國科學(xué)技術(shù)大學(xué) 國家高性能計(jì)算中心,安徽 合肥230026)
摘要: 軟件開發(fā)中對開源代碼的復(fù)用會帶來開源代碼漏洞和違反開源許可等問題,。傳統(tǒng)復(fù)用代碼檢測方法常常檢出較多偶然克隆代碼,,影響了復(fù)用代碼的檢測準(zhǔn)確性,。為此,提出了一種基于復(fù)用度量指標(biāo)的函數(shù)級別復(fù)用開源代碼檢測方法,。該方法對被測代碼和開源代碼庫,,先使用克隆檢測工具獲取克隆函數(shù),然后使用依據(jù)克隆代碼行和共用標(biāo)識符在開源代碼庫中的出現(xiàn)頻率的復(fù)用度量指標(biāo),,判定每對克隆函數(shù)是否為復(fù)用,。在公開有標(biāo)注數(shù)據(jù)集和真實(shí)數(shù)據(jù)集上的實(shí)驗(yàn)結(jié)果均表明所提方法優(yōu)于基于逆文檔頻率的方法。
中圖分類號: 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://forexkbc.com/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)載,。