{"title":"Leveraging syntactic dual-graph representations for security patch identification via structural latent alignment","authors":"Jiajun Tong, Zhixiao Wang, Xiaobin Rui","doi":"10.1016/j.jss.2025.112742","DOIUrl":null,"url":null,"abstract":"<div><div>Security patch identification is to automatically detect security-relevant commits from a vast number of code diffs. Previous works significantly improve the performance of automatic security patch identification by introducing pre-trained models. However, most existing approaches fail to capture the structural evolution across code diffs which is essential for understanding how code behavior changes during patching. Furthermore, the changes in code diffs are usually subtles, resulting in sparse representation of structural changes and making difficulty in distinguishing the effects of different structural changes. Finally, none of existing methods can fully capture the syntactic and semantic information from code diffs and commit message. In this work, we propose DualGraphPatcher, a framework designed to learn a well-structured and discriminative feature in the latent space by jointly modeling semantic information and structural code evolution. To capture fine-grained code structural changes, instead of relying on a single snapshot of a function, we construct two independent Abstract Syntax Tree (AST) structures for the pre-change and post-change versions from the original code diffs to model the entire graph topology of each version, enabling explicit modeling of structural evolution across code diffs. To alleviate the sparse representation of structural changes, we propose a latent structural alignment module, which performs soft clustering over the representations of pre-change and post-change ASTs and minimizes their distributional divergence in the shared latent space. To jointly learn syntactic and semantic information from code diffs and commit messages, we design a tri-encoder architecture, where CodeBERT and BERT extract semantic embeddings from code diffs and commit messages, and GCN encodes the syntactic structures of pre-change and post-change ASTs. Experiments on three real-world datasets demonstrate that DualGraphPatcher consistently outperforms state-of-the-art baselines in security patch identification, validating the effectiveness of both dual-graph modeling, latent structural alignment and tri-encoder. The code and data are shared in <span><span>https://github.com/AppleMax1992/DualGraphPatcher</span><svg><path></path></svg></span>.</div></div>","PeriodicalId":51099,"journal":{"name":"Journal of Systems and Software","volume":"234 ","pages":"Article 112742"},"PeriodicalIF":3.8000,"publicationDate":"2026-04-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Systems and Software","FirstCategoryId":"94","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S016412122500411X","RegionNum":2,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"2025/12/10 0:00:00","PubModel":"Epub","JCR":"Q1","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0
Abstract
Security patch identification is to automatically detect security-relevant commits from a vast number of code diffs. Previous works significantly improve the performance of automatic security patch identification by introducing pre-trained models. However, most existing approaches fail to capture the structural evolution across code diffs which is essential for understanding how code behavior changes during patching. Furthermore, the changes in code diffs are usually subtles, resulting in sparse representation of structural changes and making difficulty in distinguishing the effects of different structural changes. Finally, none of existing methods can fully capture the syntactic and semantic information from code diffs and commit message. In this work, we propose DualGraphPatcher, a framework designed to learn a well-structured and discriminative feature in the latent space by jointly modeling semantic information and structural code evolution. To capture fine-grained code structural changes, instead of relying on a single snapshot of a function, we construct two independent Abstract Syntax Tree (AST) structures for the pre-change and post-change versions from the original code diffs to model the entire graph topology of each version, enabling explicit modeling of structural evolution across code diffs. To alleviate the sparse representation of structural changes, we propose a latent structural alignment module, which performs soft clustering over the representations of pre-change and post-change ASTs and minimizes their distributional divergence in the shared latent space. To jointly learn syntactic and semantic information from code diffs and commit messages, we design a tri-encoder architecture, where CodeBERT and BERT extract semantic embeddings from code diffs and commit messages, and GCN encodes the syntactic structures of pre-change and post-change ASTs. Experiments on three real-world datasets demonstrate that DualGraphPatcher consistently outperforms state-of-the-art baselines in security patch identification, validating the effectiveness of both dual-graph modeling, latent structural alignment and tri-encoder. The code and data are shared in https://github.com/AppleMax1992/DualGraphPatcher.
期刊介绍:
The Journal of Systems and Software publishes papers covering all aspects of software engineering and related hardware-software-systems issues. All articles should include a validation of the idea presented, e.g. through case studies, experiments, or systematic comparisons with other approaches already in practice. Topics of interest include, but are not limited to:
•Methods and tools for, and empirical studies on, software requirements, design, architecture, verification and validation, maintenance and evolution
•Agile, model-driven, service-oriented, open source and global software development
•Approaches for mobile, multiprocessing, real-time, distributed, cloud-based, dependable and virtualized systems
•Human factors and management concerns of software development
•Data management and big data issues of software systems
•Metrics and evaluation, data mining of software development resources
•Business and economic aspects of software development processes
The journal welcomes state-of-the-art surveys and reports of practical experience for all of these topics.