在源代码中自动定位易受攻击的陈述至关重要,以确保软件安全性和缓解开发人员的调试工作。这在当今软件生态系统中变得更加重要,其中易受攻击的代码可以在像GitHub这样的软件存储库中轻松且无意中流动。在这类数百万的代码行中,传统的静态和动态方法争取缩放。虽然基于机器学习的方法在这样的设置中看起来很有希望,但大多数工作都在较高的粒度下检测到脆弱的代码 - 在方法或文件级别。因此,开发人员仍然需要检查大量代码以找到需要修复的弱势陈述。本文提出了一种新的集合学习方法来定位脆弱的陈述。我们的模型结合了基于图形的基于序列的神经网络,以成功捕获程序图的本地和全局上下文,并有效地了解代码语义和易受攻击的模式。为了研究天鹅绒的效果,我们使用了一个现成的合成数据集和最近发布的现实世界数据集。在静态分析设置中,未提前检测到易受攻击功能,Velvet可以实现4.5倍的性能,而不是真实世界数据上的基线静态分析仪。对于孤立的漏洞本地化任务,在我们假设特定漏洞声明未知的同时知道函数的漏洞,我们将天鹅绒与几个神经网络进行比较,这些内部网络也参加了本地和全局代码背景。天鹅绒分别达到99.6%和43.6%的13.6%,分别在合成数据和现实世界数据上实现了高精度,优于基线深度学习模型5.3-29.0%。
translated by 谷歌翻译
在本文中,我们解决了深入学习的软件漏洞自动修复问题。数据驱动漏洞修复的主要问题是已知确认漏洞的少数现有数据集仅由几千例组成。然而,培训深度学习模型通常需要数十万例的例子。在这项工作中,我们利用了错误修复任务和漏洞修复任务的直觉相关,并且可以传输来自错误修复的知识可以传输到修复漏洞。在机器学习界中,这种技术称为转移学习。在本文中,我们提出了一种修复名为Vreepair的安全漏洞的方法,该方法是基于转移学习。 vreepair首先在大型错误修复语料库上培训,然后在漏洞修复数据集上调整,这是一个较小的数量级。在我们的实验中,我们表明,仅在错误修复语料库上培训的模型可能已经修复了一些漏洞。然后,我们证明转移学习改善了修复易受攻击的C功能的能力。我们还表明,转移学习模型比具有去噪任务训练的模型更好,并在漏洞固定任务上进行微调。总而言之,本文表明,与在小型数据集上的学习相比,转移学习适用于修复C中的安全漏洞。
translated by 谷歌翻译
深度学习方法的最新突破引发了人们对基于学习的错误探测器的兴趣。与传统的静态分析工具相比,这些错误检测器是直接从数据中学到的,因此更容易创建。另一方面,它们很难训练,需要大量数据,而这些数据不容易获得。在本文中,我们提出了一种称为Meta Bug检测的新方法,该方法比现有基于学习的错误探测器具有三个至关重要的优势:Bug-Type通用(即,能够捕获在培训期间完全没有观察到的错误类型),可以自我解释(即能够在没有任何外部可解释方法的情况下解释其自身的预测)和样本有效(即,比标准错误检测器所需的培训数据要少得多)。我们的广泛评估表明,我们的元错误检测器(MBD)有效地捕获了各种错误,包括NULL指针解除,阵列索引外部漏洞,文件句柄泄漏甚至是并发程序中的数据竞赛;在此过程中,MBD还大大优于几个值得注意的基线,包括Facebook推断,一种著名的静态分析工具和FICS,即最新的异常检测方法。
translated by 谷歌翻译
Deep learning (DL) models of code have recently reported great progress for vulnerability detection. In some cases, DL-based models have outperformed static analysis tools. Although many great models have been proposed, we do not yet have a good understanding of these models. This limits the further advancement of model robustness, debugging, and deployment for the vulnerability detection. In this paper, we surveyed and reproduced 9 state-of-the-art (SOTA) deep learning models on 2 widely used vulnerability detection datasets: Devign and MSR. We investigated 6 research questions in three areas, namely model capabilities, training data, and model interpretation. We experimentally demonstrated the variability between different runs of a model and the low agreement among different models' outputs. We investigated models trained for specific types of vulnerabilities compared to a model that is trained on all the vulnerabilities at once. We explored the types of programs DL may consider "hard" to handle. We investigated the relations of training data sizes and training data composition with model performance. Finally, we studied model interpretations and analyzed important features that the models used to make predictions. We believe that our findings can help better understand model results, provide guidance on preparing training data, and improve the robustness of the models. All of our datasets, code, and results are available at https://figshare.com/s/284abfba67dba448fdc2.
translated by 谷歌翻译
由不同类型的节点和边缘组成的学习异质图增强了均匀图技术的结果。这样的图形的一个有趣示例是代表可能的软件代码执行流的控制流图。由于此类图代表了代码的更多语义信息,因此为这些图形开发技术和工具可能对检测软件中的漏洞的可靠性非常有益。但是,现有的异质图技术仍然不足以处理复杂的图形,在处理复杂的图形中,不同类型的节点和边缘数量较大且可变。本文集中于以太坊智能合约作为由构建在控制流图和包含不同类型的节点和链接的呼叫图的异质合同图表示的软件代码样本。我们提出了曼多(Mando),这是一种新的异质图表示,以学习这种异质合同图的结构。 Mando提取自定义的Metapaths,该Metapaths在不同类型的节点及其邻居之间建立了关系连接。此外,它开发了一个多米达异构图注意网络,以学习不同类型的节点及其在异质合同图中的多层嵌入,可以更准确地捕获智能合约的代码语义,并便利两者。 - 水平和粗粒合同级别的漏洞检测。我们对大型智能合同数据集的广泛评估表明,曼多(Mando)在粗粒合同水平上改善了其他技术的脆弱性检测结果。更重要的是,它是第一种基于学习的方法,能够在细粒度的线条层面上识别漏洞,并在F1分数方面将基于代码分析的传统漏洞检测方法显着提高了11.35%至70.81%。
translated by 谷歌翻译
代码搜索目标是根据自然语言查询检索相关的代码片段,以提高软件生产力和质量。但是,由于源代码和查询之间的语义间隙,自动代码搜索是具有挑战性的。大多数现有方法主要考虑嵌入的顺序信息,其中文本背后的结构信息不完全考虑。在本文中,我们设计了一个名为GraphsearchNet的新型神经网络框架,通过共同学习源代码和查询的富集语义来启用有效和准确的源代码搜索。具体地,我们建议将源代码和查询编码为两个图,其中双向GGNN以捕获图表的本地结构信息。此外,我们通过利用有效的多主题来增强BigGNN,以补充BigGNN错过的全球依赖。关于Java和Python数据集的广泛实验说明了GraphSearchNet优于当前最先进的工作原位。
translated by 谷歌翻译
Automated software debugging is a crucial task for improving the productivity of software developers. Many neural-based techniques have been proven effective for debugging-related tasks such as bug localization and program repair (or bug fixing). However, these techniques often focus only on either one of them or approach them in a stage-wise manner, ignoring the mutual benefits between them. In this work, we propose a novel unified \emph{Detect-Localize-Repair} framework based on a pretrained programming language model CodeT5 to seamlessly address these tasks, named CodeT5-DLR. Specifically, we propose three objectives to adapt the generic CodeT5 for debugging: a bug detection objective to determine whether a given code snippet is buggy or not, a bug localization objective to identify the buggy lines, and a program repair objective to translate the buggy code to its fixed version. We evaluate it on each of these tasks and their combined setting on two newly collected line-level debugging datasets in Java and Python. Extensive results show that our model significantly outperforms existing baselines from both NLP and software engineering domains.
translated by 谷歌翻译
基于机器学习的程序分析最近显示了整合正式和概率推理对辅助软件开发的承诺。但是,在没有大型注释的语料库的情况下,培训这些分析是挑战性的。为了解决这个问题,我们呈现Buglab,一种自我监督学习的错误检测和修复方法。Buglab Co-Trains两种型号:(1)检测仪模型,用于检测和修复代码中的错误,(2)选择器模型,了解为探测器创建用于训练数据的错误代码。在2374个真实错误的测试数据集上,Buglab的Python实现在基线方法上提高了30%,并在开源软件中找到19个以前未知的错误。
translated by 谷歌翻译
Machine Learning for Source Code (ML4Code) is an active research field in which extensive experimentation is needed to discover how to best use source code's richly structured information. With this in mind, we introduce JEMMA, an Extensible Java Dataset for ML4Code Applications, which is a large-scale, diverse, and high-quality dataset targeted at ML4Code. Our goal with JEMMA is to lower the barrier to entry in ML4Code by providing the building blocks to experiment with source code models and tasks. JEMMA comes with a considerable amount of pre-processed information such as metadata, representations (e.g., code tokens, ASTs, graphs), and several properties (e.g., metrics, static analysis results) for 50,000 Java projects from the 50KC dataset, with over 1.2 million classes and over 8 million methods. JEMMA is also extensible allowing users to add new properties and representations to the dataset, and evaluate tasks on them. Thus, JEMMA becomes a workbench that researchers can use to experiment with novel representations and tasks operating on source code. To demonstrate the utility of the dataset, we also report results from two empirical studies on our data, ultimately showing that significant work lies ahead in the design of context-aware source code models that can reason over a broader network of source code entities in a software project, the very task that JEMMA is designed to help with.
translated by 谷歌翻译
Deep learning-based vulnerability detection models have recently been shown to be effective and, in some cases, outperform static analysis tools. However, the highest-performing approaches use token-based transformer models, which do not leverage domain knowledge. Classical program analysis techniques such as dataflow analysis can detect many types of bugs and are the most commonly used methods in practice. Motivated by the causal relationship between bugs and dataflow analysis, we present DeepDFA, a dataflow analysis-guided graph learning framework and embedding that uses program semantic features for vulnerability detection. We show that DeepDFA is performant and efficient. DeepDFA ranked first in recall, first in generalizing over unseen projects, and second in F1 among all the state-of-the-art models we experimented with. It is also the smallest model in terms of the number of parameters, and was trained in 9 minutes, 69x faster than the highest-performing baseline. DeepDFA can be used with other models. By integrating LineVul and DeepDFA, we achieved the best vulnerability detection performance of 96.4 F1 score, 98.69 precision, and 94.22 recall.
translated by 谷歌翻译
在开源存储库中发现的真正错误修复似乎是学习本地化和修复实际错误的理想来源。但是,缺乏大规模的错误修复集合使过去难以有效利用过去的较大神经模型的真正错误修复。相比之下,人工错误 - 通过突变现有源代码产生的人为错误可以轻松地以足够的规模获得,因此在培训现有方法时通常是首选的。尽管如此,在面对真正的错误时,经过对人造错误的培训的本地化和维修模型通常在表现不佳。这就提出了一个问题,是否在实际错误修复程序上培训的错误本地化和维修模型在本地化和维修实际错误方面更有效。我们通过引入Realit,这是一种预先培训和预先计算方法,以有效地学习从真正的错误修复中进行本地化和修复真实的错误来解决这个问题。 Realit首先是在传统突变操作员产生的大量人造错误上进行的,然后在较小的一组实际错误修复程序上进行了微调。微调不需要对学习算法进行任何修改,因此可以轻松地在各种培训方案中用于错误定位或维修(即使实际培训数据很少)。此外,我们发现,对使用真实错误修复的培训在经验上几乎使现有模型在实际错误上的本地化性能翻了一番,同时维护甚至改善了维修性能。
translated by 谷歌翻译
构建静态呼叫图需要在健全和精度之间进行权衡。不幸的是,用于构建呼叫图的程序分析技术通常不精确。为了解决这个问题,研究人员最近提出了通过机器学习为静态分析构建的后处理呼叫图所授权的呼叫图。机器学习模型的构建是为了通过在随机森林分类器中提取结构特征来捕获呼叫图中的信息。然后,它消除了预测为误报的边缘。尽管机器学习模型显示了改进,但它们仍然受到限制,因为它们不考虑源代码语义,因此通常无法有效地区分真实和误报。在本文中,我们提出了一种新颖的呼叫图修剪技术AutoRoprouner,用于通过统计语义和结构分析消除呼叫图中的假阳性。给定一个由传统静态分析工具构建的呼叫图,AutoProuner采用基于变压器的方法来捕获呼叫者与呼叫图中每个边缘相关的呼叫者和Callee函数之间的语义关系。为此,AutoProuner微型调节模型是在大型语料库上预先训练的代码模型,以根据其语义的描述表示源代码。接下来,该模型用于从与呼叫图中的每个边缘相关的功能中提取语义特征。 AutoProuner使用这些语义功能以及从呼叫图提取的结构特征通过馈送前向神经网络分类。我们在现实世界程序的基准数据集上进行的经验评估表明,AutoProuner的表现优于最先进的基线,从而改善了F量级,在识别静态呼叫图中识别错误阳性边缘方面,高达13%。
translated by 谷歌翻译
The automation of an increasingly large number of software engineering tasks is becoming possible thanks to Machine Learning (ML). One foundational building block in the application of ML to software artifacts is the representation of these artifacts (e.g., source code or executable code) into a form that is suitable for learning. Many studies have leveraged representation learning, delegating to ML itself the job of automatically devising suitable representations. Yet, in the context of Android problems, existing models are either limited to coarse-grained whole-app level (e.g., apk2vec) or conducted for one specific downstream task (e.g., smali2vec). Our work is part of a new line of research that investigates effective, task-agnostic, and fine-grained universal representations of bytecode to mitigate both of these two limitations. Such representations aim to capture information relevant to various low-level downstream tasks (e.g., at the class-level). We are inspired by the field of Natural Language Processing, where the problem of universal representation was addressed by building Universal Language Models, such as BERT, whose goal is to capture abstract semantic information about sentences, in a way that is reusable for a variety of tasks. We propose DexBERT, a BERT-like Language Model dedicated to representing chunks of DEX bytecode, the main binary format used in Android applications. We empirically assess whether DexBERT is able to model the DEX language and evaluate the suitability of our model in two distinct class-level software engineering tasks: Malicious Code Localization and Defect Prediction. We also experiment with strategies to deal with the problem of catering to apps having vastly different sizes, and we demonstrate one example of using our technique to investigate what information is relevant to a given task.
translated by 谷歌翻译
In software development, it is common for programmers to copy-paste or port code snippets and then adapt them to their use case. This scenario motivates the code adaptation task -- a variant of program repair which aims to adapt variable identifiers in a pasted snippet of code to the surrounding, preexisting source code. However, no existing approach has been shown to effectively address this task. In this paper, we introduce AdaptivePaste, a learning-based approach to source code adaptation, based on transformers and a dedicated dataflow-aware deobfuscation pre-training task to learn meaningful representations of variable usage patterns. We evaluate AdaptivePaste on a dataset of code snippets in Python. Results suggest that our model can learn to adapt source code with 79.8% accuracy. To evaluate how valuable is AdaptivePaste in practice, we perform a user study with 10 Python developers on a hundred real-world copy-paste instances. The results show that AdaptivePaste reduces the dwell time to nearly half the time it takes for manual code adaptation, and helps to avoid bugs. In addition, we utilize the participant feedback to identify potential avenues for improvement of AdaptivePaste.
translated by 谷歌翻译
在实际执行或基准测试之前预测生产代码的性能是高度挑战的。在本文中,我们提出了一个被称为TEP-GNN的预测模型,该模型表明,对于预测单位测试执行时间的特殊情况,高准确性的性能预测是可能的。 Tep-gnn使用FA-asts或流动的ASTS作为基于图的代码表示方法,并使用强大的图形神经网络(GNN)深度学习模型预测测试执行时间。我们基于从项目公共存储库中开采的922个测试文件,使用四个现实生活中的Java开源程序评估TEP-GNN。我们发现我们的方法达到了0.789的较高的Pearson相关性,表现优于基线深度学习模型。但是,我们还发现,训练有素的模型需要更多的工作来概括看不见的项目。我们的工作表明,FA-asts和GNN是预测绝对性能值的可行方法,并作为能够在执行前预测任意代码的性能的重要中介步骤。
translated by 谷歌翻译
深度学习最近在程序分析任务(例如错误检测)方面取得了最初的成功。缺乏真正的错误,大多数现有的作品通过将合成错误注入正确的程序来构建培训和测试数据。尽管达到了高测试精度(例如90%),但发现所得的错误检测器在实践中令人惊讶地无法使用,即用于扫描真实软件存储库时<10%的精度。在这项工作中,我们认为这种巨大的性能差异是由分布变化引起的,即实际错误分布与用于训练和评估检测器的合成错误分布之间的基本不匹配。为了应对这一关键挑战,我们建议在两个阶段训练一个错误检测器,首先是合成错误分布,以使模型适应错误检测域,然后在真实的错误分布上调整模型,以将模型驱动到真实分布。在这两个阶段中,我们利用多任务层次结构,焦点损失和对比度学习来进一步提高性能。我们对三种经过广泛研究的错误类型进行了广泛的评估,为此,我们仔细设计了新的数据集,以捕获真正的错误分布。结果表明,我们的方法实际上是有效的,并且可以成功地减轻分配的转变:我们学到的检测器在测试集和最新版本的开源存储库中都表现出色。我们的代码,数据集和模型可在https://github.com/eth-sri/learning-real-bug-detector上公开获取。
translated by 谷歌翻译
深度学习在各种软件工程任务中广泛使用,例如,节目分类和缺陷预测。虽然该技术消除了特征工程所需的过程,但源代码模型的构建显着影响了这些任务的性能。最近的作品主要集中在通过引入从CFG提取的上下文依赖项来补充基于AST的源代码模型。但是,所有这些都关注基本块的表示,这是上下文依赖性的基础。在本文中,我们集成了AST和CFG,并提出了一种嵌入了分层依赖项的新型源代码模型。基于此,我们还设计了一种神经网络,这取决于图表关注机制。特殊地,我们介绍了基本块的句法结构,即其对应的AST,在源代码模型中提供足够的信息并填补间隙。我们在三种实际软件工程任务中评估了该模型,并将其与其他最先进的方法进行了比较。结果表明,我们的模型可以显着提高性能。例如,与最佳性能的基线相比,我们的模型将参数的比例降低了50 \%并实现了对程序分类任务的准确性的4 \%改进。
translated by 谷歌翻译
代码摘要可帮助开发人员理解程序并减少在软件维护过程中推断程序功能的时间。最近的努力诉诸深度学习技术,例如序列到序列模型,以生成准确的代码摘要,其中基于变压器的方法已实现了有希望的性能。但是,在此任务域中,有效地将代码结构信息集成到变压器中的情况不足。在本文中,我们提出了一种名为SG-Trans的新方法,将代码结构属性纳入变压器。具体而言,我们将局部符号信息(例如,代码令牌和语句)和全局句法结构(例如,数据流程图)注入变压器的自我发项模块中。为了进一步捕获代码的层次结构特征,局部信息和全局结构旨在分布在下层和变压器高层的注意力头中。广泛的评估表明,SG-trans的表现优于最先进的方法。与表现最佳的基线相比,SG-Trans在流星评分方面仍然可以提高1.4%和2.0%,这是一个广泛用于测量发电质量的度量,分别在两个基准数据集上。
translated by 谷歌翻译
The International Workshop on Reading Music Systems (WoRMS) is a workshop that tries to connect researchers who develop systems for reading music, such as in the field of Optical Music Recognition, with other researchers and practitioners that could benefit from such systems, like librarians or musicologists. The relevant topics of interest for the workshop include, but are not limited to: Music reading systems; Optical music recognition; Datasets and performance evaluation; Image processing on music scores; Writer identification; Authoring, editing, storing and presentation systems for music scores; Multi-modal systems; Novel input-methods for music to produce written music; Web-based Music Information Retrieval services; Applications and projects; Use-cases related to written music. These are the proceedings of the 3rd International Workshop on Reading Music Systems, held in Alicante on the 23rd of July 2021.
translated by 谷歌翻译
Pre-trained language models for programming languages have shown a powerful ability on processing many Software Engineering (SE) tasks, e.g., program synthesis, code completion, and code search. However, it remains to be seen what is behind their success. Recent studies have examined how pre-trained models can effectively learn syntax information based on Abstract Syntax Trees. In this paper, we figure out what role the self-attention mechanism plays in understanding code syntax and semantics based on AST and static analysis. We focus on a well-known representative code model, CodeBERT, and study how it can learn code syntax and semantics by the self-attention mechanism and Masked Language Modelling (MLM) at the token level. We propose a group of probing tasks to analyze CodeBERT. Based on AST and static analysis, we establish the relationships among the code tokens. First, Our results show that CodeBERT can acquire syntax and semantics knowledge through self-attention and MLM. Second, we demonstrate that the self-attention mechanism pays more attention to dependence-relationship tokens than to other tokens. Different attention heads play different roles in learning code semantics; we show that some of them are weak at encoding code semantics. Different layers have different competencies to represent different code properties. Deep CodeBERT layers can encode the semantic information that requires some complex inference in the code context. More importantly, we show that our analysis is helpful and leverage our conclusions to improve CodeBERT. We show an alternative approach for pre-training models, which makes fully use of the current pre-training strategy, i.e, MLM, to learn code syntax and semantics, instead of combining features from different code data formats, e.g., data-flow, running-time states, and program outputs.
translated by 谷歌翻译