arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.16565cs.SE
收藏

PyRadar:面向PyPI包自动检索与验证源代码仓库信息

PyRadar: Towards Automatically Retrieving and Validating Source Code Repository Information for PyPI Packages

Kai Gao, Weiwei Xu, Wenhao Yang, Minghui Zhou

AI总结:

本文提出PyRadar框架,结合元数据与源码分发包检索并验证PyPI包的源代码仓库信息,解决了现有工具因元数据缺失或错误导致检索率低的问题,检索覆盖率达90.2%且准确率为0.970。

摘要:

包的源代码仓库记录了包的开发历史,为包的使用和风险监控提供了不可或缺的信息。然而,由于包的开发平台与分发平台相分离,包的发布版本通常缺失其源代码仓库信息。现有工具从发布版本的元数据中检索仓库信息,存在两个局限性:元数据可能不包含或包含错误信息。我们的分析表明,现有工具最多只能为70.5%的PyPI发布版本检索到仓库信息。针对这些局限性,本文提出了PyRadar,一个利用元数据和源码分发包来检索和验证PyPI发布版本仓库信息的新框架。我们首先进行实证研究,在4,227,425个PyPI发布版本上比较四种现有工具,并分析了14,375个正确的包-仓库链接和2,064个错误链接中的幻影文件(出现在发布版本分发包中但不在其仓库中的文件)。基于这些发现,我们将PyRadar设计为包含三个组件:基于元数据的检索器、源代码仓库验证器和基于源代码的检索器。其中,基于元数据的检索器结合了现有工具的最佳实践,成功为72.1%的PyPI发布版本从元数据中检索到仓库信息。源代码仓库验证器在六个精心设计的特征上应用常见机器学习算法,AUC最高达0.995。基于源代码的检索器使用发布版本源码分发包中所有Python文件的SHA-1哈希值查询World of Code,为数据集中90.2%的包检索到仓库信息,准确率为0.970。从业者与研究人员均可使用PyRadar以更好地利用PyPI包。

英文摘要:

A package's source code repository records the development history of the package, providing indispensable information for the use and risk monitoring of the package. However, a package release often misses its source code repository due to the separation of the package's development platform from its distribution platform. Existing tools retrieve the release's repository information from its metadata, which suffers from two limitations: the metadata may not contain or contain wrong information. Our analysis shows that existing tools can only retrieve repository information for up to 70.5% of PyPI releases. To address the limitations, this paper proposes PyRadar, a novel framework that utilizes the metadata and source distribution to retrieve and validate the repository information for PyPI releases. We start with an empirical study to compare four existing tools on 4,227,425 PyPI releases and analyze phantom files (files appearing in the release's distribution but not in the release's repository) in 14,375 correct package-repository links and 2,064 incorrect links. Based on the findings, we design PyRadar with three components, i.e., Metadata-based Retriever, Source Code Repository Validator, and Source Code-based Retriever. In particular, the Metadata-based Retriever combines best practices of existing tools and successfully retrieves repository information from the metadata for 72.1% of PyPI releases. The Source Code Repository Validator applies common machine learning algorithms on six crafted features and achieves an AUC of up to 0.995. The Source Code-based Retriever queries World of Code with the SHA-1 hashes of all Python files in the release's source distribution and retrieves repository information for 90.2% of packages in our dataset with an accuracy of 0.970. Both practitioners and researchers can employ the PyRadar to better use PyPI packages.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑