Page 143 - 《软件学报》2026年第7期
P. 143
2828 软件学报 2026 年第 37 卷第 7 期
为此, 我们采用了基于签名的代码克隆检测方法 [4] . 具体而言, 我们将每个函数转换为哈希值, 并通过比较这
些哈希值来检测目标项目中是否存在与预先收集的代码库中相似或重复的函数. 在面对微小代码变动时, 与基于
文本和基于令牌的方法相比, 这种方法能够保持较高的准确性和健壮性, 因此更适用于软件成分分析.
如果预先收集的代码库中的函数缺乏代表性, 直接将这些函数映射到源库并视作目标项目的复用 TPL, 可能
会导致大量假阳性; 如果代码库不完整, SCA 过程可能遗漏 TPL 成分, 导致假阴性. 因此, 在应用代码克隆检测算
法进行成分识别之前, 必须构建一个全面的 TPL 代码库, 并保留能够充分表征 TPL 特征的函数. 本文设计并实现
了一种高效且灵活的数据收集机制. 该机制涵盖了操作系统中央仓库、应用程序级包管理器以及代码仓库这 3 个
层面, 选择了 15 个托管仓库作为 C/C++ TPL 的来源. 通过整合这些托管仓库提供的数据, 我们从 33 100 个 C/C++
TPL 中提取了 30 047 290 个函数特征, 进而构建大规模覆盖全面 C/C++ TPL 的特征库. 同时, 引入预处理步骤, 确
保特征库中每个 TPL 的函数特征能够唯一标识 TPL.
7 总 结
本文提出并实现了针对 C/C++源代码的软件成分分析工具 CAnalyzer, 面向软件库粒度的复用检测场景, 旨在
精准识别目标软件源代码中依赖的 C/C++ TPL 及其之间依赖关系. CAnalyzer 通过构建大规模、高质量的 TPL 特
征并引入预处理机制, 有效缓解了公共函数对检测结果的干扰. 在此基础上, 进一步引入多重阈值策略, 增强了工
具对实际工程场景的适应性, 并设计了基于文件间关系的依赖分析方法. 实验结果表明, CAnalyzer 在 TPL 识别准
确性方面优于代表性工具 CENTRIS、TPLite 和 OSSFP, 展现出良好的检测效果与性能表现. 作为对现有 SCA 技
术的系统性增强和适用性提升, CAnalyzer 在提高开源项目成分识别精度与依赖关系建模能力方面表现优越, 为开
源软件的透明管理与软件供应链安全保障提供了有力支持. 未来, 我们将进一步拓展 CAnalyzer 在其他程序语言
项目中的适用性, 并探索更高效的特征提取、特征库构建与依赖建模机制, 以持续提升 SCA 技术在实际软件开发
场景中的实用价值.
References
[1] The GitHub Blog—Thank you for 100 million repositories. 2025. https://github.blog/news-insights/company-news/100m-repos/
[2] Lopes CV, Maj P, Martins P, Saini V, Yang D, Zitny J, Sajnani H, Vitek J. DéjàVu: A map of code duplicates on GitHub. Proc. of the
ACM on Programming Languages, 2017, 1(OOPSLA): 84. [doi: 10.1145/3133908]
[3] Li HZ, Kwon H, Kwon J, Lee H. CLORIFI: Software vulnerability discovery using code clone verification. Concurrency and
Computation: Practice and Experience, 2016, 28(6): 1900–1917. [doi: 10.1002/cpe.3532]
[4] Kim S, Woo S, Lee H, Oh H. VUDDY: A scalable approach for vulnerable code clone discovery. In: Proc. of the 38th IEEE Symp. on
Security and Privacy (SP). San Jose: IEEE, 2017. 595–614. [doi: 10.1109/SP.2017.62]
[5] Duan RA, Bijlani A, Xu M, Kim T, Lee WK. Identifying open-source license violation and 1-day security risk at large scale. In: Proc. of
the 2017 ACM SIGSAC Conf. on Computer and Communications Security. Dallas: ACM, 2017. 2169–2185. [doi: 10.1145/3133956.
3134048]
[6] Kim S, Lee H. Software systems at risk: An empirical study of cloned vulnerabilities in practice. Computers & Security, 2018, 77:
720–736. [doi: 10.1016/j.cose.2018.02.007]
[7] Alqahtani SS, Eghan EE, Rilling J. Recovering semantic traceability links between APIs and security vulnerabilities: An ontological
modeling approach. In: Proc. of the 2017 IEEE Int’l Conf. on Software Testing, Verification and Validation (ICST). Tokyo: IEEE, 2017.
80–91. [doi: 10.1109/ICST.2017.15]
[8] Zhan X, Fan LL, Liu TM, Chen S, Li L, Wang HY, Xu YF, Luo XP, Liu Y. Automated third-party library detection for Android
applications: Are we there yet? In: Proc. of the 35th IEEE/ACM Int’l Conf. on Automated Software Engineering. ACM, 2020. 919–930.
[doi: 10.1145/3324884.3416582]
[9] BlackDuck. True scale application security for your software. 2025. https://www.blackduck.com/
[10] Sajnani H, Saini V, Svajlenko J, Roy CK, Lopes CV. SourcererCC: Scaling code clone detection to big-code. In: Proc. of the 38th Int’l
Conf. on Software Engineering. Austin: ACM, 2016. 1157–1168. [doi: 10.1145/2884781.2884877]
[11] Scantist, an open source management platform. 2025. https://app.scantist.io/

