EUVIMEDEUVIMED entdecken
Crossref

SafeNet: Towards mitigating replaceable unsafe Rust code via a recommendation‐based approach

Yan Dong, Zhicong Zhang, Mohan Cui, Hui Xu

Software Testing, Verification and Reliability · 2024-08 · 34 (5)

DOI: 10.1002/stvr.1875 ↗

Kurz gefasst

Fachartikel in der Zeitschrift Software Testing, Verification and Reliability, online erschienen am 02.03.2024. Verfasst von Yan Dong und 3 weiteren Autor:innen. Die Arbeit wurde bisher 6-mal zitiert (Crossref) und nennt 23 Literaturangaben.

AbstractBibliografische AngabenZitierenVerwandte Studien

Abstract (Originalsprache)

Rust is a system‐level programming language with advantages in memory safety. It ensures that any Rust programs without unsafe code should not incur undefined behaviours. However, unsafe code still plays an essential role in Rust to achieve low‐level control. Therefore, a major design pattern of Rust programs is interior unsafe, which wraps unsafe code as safe APIs and handles all undefined behaviours internally. Rust standard library already provides a rich set of safe APIs to facilitate Rust code development. Nevertheless, due to unfamiliarity with these APIs, developers may misuse unnecessary unsafe code and suffer memory‐safety risks. In this paper, we investigate an approach to mitigate replaceable unsafe code. We first analyse unsafe APIs of the Rust standard library and summarize their common usage patterns. Each pattern corresponds to one or several code samples in our knowledge base. Then, we develop an approach to automatically recognize the usage pattern and recommend corresponding code samples. Our approach leverages dataflow analysis to exclude impossible patterns and employs a BERT‐based machine learning model to find the most similar pattern among the rest. We have conducted evaluation experiments with 472 unsafe code snippets collected from GitHub projects and successfully recognized the pattern of 394 snippets. We hope our approach can assist developers in detecting unnecessary unsafe code and suggesting safe alternatives.

Zitieren

APA

Dong, Y., Zhang, Z., Cui, M., & Xu, H. (2024). SafeNet: Towards mitigating replaceable unsafe Rust code via a recommendation‐based approach. Software Testing, Verification and Reliability, 34(5). https://doi.org/10.1002/stvr.1875

Vancouver

Dong Y, Zhang Z, Cui M, Xu H. SafeNet: Towards mitigating replaceable unsafe Rust code via a recommendation‐based approach. Software Testing, Verification and Reliability. 2024;34(5). doi:10.1002/stvr.1875

BibTeX
@article{Dong2024,
  author = {Dong, Yan and Zhang, Zhicong and Cui, Mohan and Xu, Hui},
  title = {SafeNet: Towards mitigating replaceable unsafe Rust code via a recommendation‐based approach},
  journal = {Software Testing, Verification and Reliability},
  year = {2024},
  volume = {34},
  number = {5},
  doi = {10.1002/stvr.1875}
}
Kostenlos starten →