Leveraging syntactic dual-graph representations for security patch identification via structural latent alignment

IF 3.8 2区 计算机科学 Q1 COMPUTER SCIENCE, SOFTWARE ENGINEERING
Journal of Systems and Software Pub Date : 2026-04-01 Epub Date: 2025-12-10 DOI:10.1016/j.jss.2025.112742
Jiajun Tong, Zhixiao Wang, Xiaobin Rui
{"title":"Leveraging syntactic dual-graph representations for security patch identification via structural latent alignment","authors":"Jiajun Tong,&nbsp;Zhixiao Wang,&nbsp;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.
利用句法双图表示,通过结构潜在对齐进行安全补丁识别
安全补丁识别是从大量代码差异中自动检测与安全相关的提交。先前的工作通过引入预训练模型,显著提高了安全补丁自动识别的性能。然而,大多数现有的方法都无法捕获代码差异之间的结构演变,这对于理解代码行为在打补丁期间如何变化是至关重要的。此外,代码差异的变化通常是微妙的,导致结构变化的稀疏表示,难以区分不同结构变化的影响。最后,现有的方法都不能从代码差异和提交消息中完全捕获语法和语义信息。在这项工作中,我们提出了DualGraphPatcher框架,该框架旨在通过联合建模语义信息和结构代码进化来学习潜在空间中结构良好的判别特征。为了捕获细粒度的代码结构变化,而不是依赖于单个功能快照,我们为原始代码差异的更改前和更改后版本构建了两个独立的抽象语法树(AST)结构,以对每个版本的整个图拓扑进行建模,从而实现跨代码差异的结构演变的显式建模。为了缓解结构变化的稀疏表示,我们提出了一个潜在结构对齐模块,该模块对变化前和变化后的ast表示进行软聚类,并最小化它们在共享潜在空间中的分布差异。为了从代码差异和提交消息中共同学习语法和语义信息,我们设计了一个三编码器架构,其中CodeBERT和BERT从代码差异和提交消息中提取语义嵌入,GCN对更改前和更改后ast的语法结构进行编码。在三个真实数据集上的实验表明,DualGraphPatcher在安全补丁识别方面始终优于最先进的基线,验证了双图建模、潜在结构对齐和三编码器的有效性。代码和数据在https://github.com/AppleMax1992/DualGraphPatcher中共享。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
Journal of Systems and Software
Journal of Systems and Software 工程技术-计算机:理论方法
CiteScore
8.60
自引率
5.70%
发文量
193
审稿时长
16 weeks
期刊介绍: 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.
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信
小红书