arXiv:2610.24479cs.SEOct 2026

Manuscript Offprint

arXiv:2610.24479

Effective Construction of Feature Database of Fingerprinting Functions for Code-Clone SCA

Zhiling Zhu, Tieming Chen, Chengwei Liu, Jiahui Wu, Qijie Song, Zhengzi Xu, Yueming Wu, Yang Liu

Zhiling Zhu, Tieming Chen, Chengwei Liu, Jiahui Wu, Qijie Song, Zhengzi Xu, Yueming Wu, and Yang Liu

Abstract—In contemporary software development, the extensive adoption of third-party libraries has become a standard practice to avoid reinventing the wheel. This trend is particularly evident in programming ecosystems that lack mature package managers, such as C/C++. Within this context, Code Clone Detection (CCD) techniques have emerged as essential tools for identifying instances of code reuse, thereby mitigating security and legal concerns. Despite significant scholarly advancements aimed at enhancing the accuracy of CCD algorithms, a notable gap persists between the capabilities of academic tools and the demands of real-world applications. This disparity primarily arises from the reliance on academic tools on experimental datasets composed of a limited number of indexed repositories, whereas real-world applications require a much broader scope of code sources.

To address this challenge, we propose a novel, systematic approach for selecting appropriate open-source repositories to construct a more effective CCD feature dataset. Our method, OSSScope, employs a greedy algorithm to analyze the diversity of fingerprinting functions across 2.55 million C repositories on GitHub. The objective is to maximize the inclusion of unique fingerprinting functions while minimizing the number of repositories required. OSSScope successfully compiles an optimal feature dataset containing 61 million fingerprinting functions from 190K repositories, resulting in a 22.65% improvement in recall over SOTA tools. Moreover, the constructed dataset covers over 95% of the features from other sources, demonstrating its diversity and coverage. Furthermore, leveraging the repositories selected by OSSScope, we introduce RClassifier, a lightweight classification model that streamlines the construction process for migration to other language ecosystems. By capturing key metrics, RClassifier directly determines whether a repository should be included in the dataset. Our comprehensive evaluation of RClassifier within the Golang ecosystem validates its effectiveness, achieving recall performance comparable to the feature dataset produced by OSSScope.

Index Terms—Software Component Analysis, Code Clone Detection, Fingerprinting Function

I. INTRODUCTION

A S the extensive reuse of open-source artifacts in modern software development prevents reinventing wheels, software composition analysis (SCA) techniques have been widely populated to detect the reuse of third-party source code to avoid potential risks, such as security vulnerabilities and license compliance, etc. Apart from the reuse of third-party libraries as dependencies, which could be easily identified by corresponding package managers (e.g., Maven for Java, NPM for JavaScript), direct copy-paste of code fragments from existing software repositories is a much more common practice in software ecosystems that have no popular package managers, such as C/C++ ecosystem [1]. To this end, code clone detection (CCD) techniques have been introduced to detect such copy-paste reuse of third-party code fragments.

CCD tool usually consists of a pre-constructed feature dataset and a well-designed code clone detection algorithm. Typically, CCD tools report potential code clones by comparing target projects with feature databases based on the code clone detection algorithms. Many CCD tools have been proposed to improve their accuracy and performance by strengthening code clone detection algorithms. For instance, SourcererCC [2] and Vuddy [3] employed code tokens as the representations of features to enable scalable code clone detections, Yang et al. [4] introduced the AST representation and adopted Smith-Waterman algorithm to enhance the precision, CCSharp [5] further improved code clone detection by utilizing program dependency graph for semantic level similarity, CENTRIS [6] adopted locality-sensitive hashing to mapping type 1 and type 2 code clones for recognizing the integrated TPLs, and OSSFP [7] further improved the accuracy by filtering the fingerprinting functions for similarity calculation. However, these tools are only implemented and evaluated with feature datasets derived from limited open-source code to demonstrate the capability, e.g., roughly selecting C/C++ repositories with over 100 stars in SOTA tools (CENTRIS [6] and OSSFP [7]). While overlooking that limited datasets could also heavily impact the generalization of SCA tools in real-world applications, as revealed by Jiang et al. [8]. More specifically, since it is impossible to detect if cloned codes are not included in the feature dataset, these existing works usually evaluate algorithms and tools by ground truths that are included in the scope of their experimental feature datasets, which overlook the case that code clones could happen on a much larger range of open-source repositories, leading to the compromised applicability in real-world SCA detection. Moreover, commercial tools choose to collect all available source code (i.e., BlackDuck [9] had collected 6.3 million components as its feature database [10]) to ensure the recall, but this, on the other hand, could be resource-consuming and result in a bloated feature dataset that could compromise the

Chengwei Liu and Tieming Chen are corresponding authors of this work.

Zhiling Zhu, Tieming Chen and Qijie Song are with Zhejiang University of Technology, China. (e-mail: zhilingzhu@zjut.edu.cn, tmchen@zjut.edu.cn, songqijie@zjut.edu.cn).

Chengwei Liu, Jiahui Wu and Yang Liu are with Nanyang Technological University, Singapore (e-mail: chengwei.liu@ntu.edu.sg, jiahui004@e.ntu.edu.sg, yangliu@ntu.edu.sg).

Zhengzi Xu is with Imperial Global Singapore and Imperial College London (e-mail:z.xu@imperial.ac.uk)

Yueming Wu is with Huazhong University of Science and Technology, China (e-mail: wuyueming21@gmail.com).

performance of CCD tools [11], [12], which makes it difficult to employ complex CCD algorithms in these commercial tools. Therefore, it is non-trivial to construct effective-efficient datasets for code clone-based SCA tools. We aim to explore the proper methodology to construct such effective-efficient datasets for code clone detection.

To achieve this, we need to balance the trade-offs between the coverage and high quality of feature datasets. 1) Code Coverage. There are tens of millions of open source repositories on open source repositories; it would be resource-consuming to construct feature datasets for all source codes of these repositories. Moreover, considering that repositories could be updated constantly, the various versions of historical code could exponentially increase the difficulties when constructing feature datasets. 2) Code Clone Efficiency. There could be a significantly large portion of source codes that are not necessarily included in the feature dataset (not IP-significant [7]), these unnecessary code features should be further excluded to ensure the efficiency of code clone detection. However, there is a lack of sufficient and comprehensive solutions for such feature dataset refinement.

To balance the trade-off, we first take the ecosystem of C language as an example to conduct a comprehensive investigation on the diversity of C code, as well as the preference of code clones in the C ecosystem. Specifically, we first propose a novel approach to explore the proper scope of C repositories from the perspective of including all identical C functions. Since it is a huge consumption of time and resources to directly download all existing C repositories and parse the code in all versions, we propose a novel approach to greedily construct the feature dataset by including as many unique functions as possible while retrieving minimal numbers of repositories. After reaching the theoretic upper bound number of unique functions, we exclude repositories that contribute little to code clone detection by three proposed metrics on repository values, to approximate the optimal feature dataset (i.e., OSSScope) of CCD with balanced precision and performance. As a result, after analyzing 385,000 repositories, OSSScope identified and included 73,135,396 unique functions, accounting for 95% of the theoretical upper bound of unique functions as predicted by curve fitting. Furthermore, after filtering out repositories with low contributions to CCD, we obtained an effective and efficient feature dataset comprising 61,746,893 unique functions (79.52% of all identified functions) from 193,026 repositories, which represent only 7.57% of all C repositories on GitHub. Our evaluation demonstrated that OSSScope significantly enhances the recall of existing CCD tools by 22.65% while incurring only a minimal performance overhead. This result highlights the superior balance achieved by OSSScope between accuracy and computational efficiency compared to existing feature dataset construction strategies. Additionally, the constructed dataset covers over 95% of the features from other sources, further validating its diversity and comprehensive representation.

Furthermore, although OSSScope is effective for feature dataset construction, it is still resource-consuming to analyze millions of repositories when generalized to other language ecosystems. We turned the repository selection into a binary classification problem, and trained a classification model, named RClassifier, based on the light-weighted and easy-obtained metrics. Our validation on the Golang ecosystem showed that the feature dataset constructed from repositories sorted out by RClassifier can reach 86.69% precision and 89.67% recall, which is only slightly lower than the recall (92.54%) of the dataset constructed by OSSScope.

In summary, the main contributions are as follows:

• We proposed OSSScope, a resource-consuming but very effective approach to construct a code clone feature database from the open-source repositories.

• Using OSSScope, we built an effective CCD feature dataset for C, containing 62M unique functions from 190K repositories (80.2% of unique functions from just 7.57% of GitHub C repositories), achieving a 22.65% recall improvement over SOTA CCD tools. Covering over 95% of features from other sources, the dataset demonstrates strong diversity and comprehensive coverage.

• We proposed RClassifier to construct CCD feature datasets using easily obtainable repository metrics. Evaluations on the Golang ecosystem showed that RClassifier effectively selects repositories with only a slight recall reduction (3%) compared to OSSScope, demonstrating its generalizability across language ecosystems.

• We have open-sourced the constructed feature dataset of C and Golang on our website [13]. To our best knowledge, so far, they are the largest open-source feature databases for code clone detection for C and Golang.

References (78)