寫在最前面
本文為鄒德清教授的《網(wǎng)絡(luò)安全專題》課堂筆記系列
的文章,本次專題主題為大模型。
Keep the Conversation Going: Fixing 162 out of 337 bugs for $0.42 each using ChatGPT
arXiv 2023.4.1
https://arxiv.org/pdf/2304.00385.pdf
Chunqiu Steven Xia, University of Illinois Urbana-Champaign
Lingming Zhang, University of Illinois Urbana-Champaign
記錄一位同學(xué)的分享
PPT簡約大方、重點突出,學(xué)到了一些很巧妙的小設(shè)計
同時梳理了自動程序修復(fù)APR的流程、常見方法,我之前沒接觸過但也有了一定的了解
分享論文循序漸進,這種閱讀論文的步驟之后或許可以嘗試
※ 之后自己可以?;仡?、多學(xué)習(xí)學(xué)習(xí)
背景介紹
自動程序修復(fù)流程Process of APR (automated program repair)
1、漏洞程序
Vulnerability Detection
(NDSS 18)Vuldeepecker: A deep learning-based system for vulnerability detection
(security 22)Mining Node.js Vulnerabilities via Object Dependence Graph and Query
2、漏洞定位模塊
Fault Localization
(TSE 23) Effective Isolation of Fault-Correlated Variables via Statistical and Mutation Analysis
3、補丁生成
Patch Generation
4、補丁驗證
Patch Correctness Checking
(FSE 23) A Large-scale Empirical Review of Patch Correctness Checking Approaches
(可以學(xué)習(xí)的PPT設(shè)計)經(jīng)典的APR方法traditional APR tools
- 啟發(fā)式搜索(GenProg)
insight:重用項目中的代碼產(chǎn)生正確的修復(fù)補丁
method:通過交叉和變異操作實現(xiàn)已有代碼的重新組合 - 基于歷史修復(fù)
insight:不同軟件中 bug 會重復(fù)出現(xiàn),可以作為后續(xù)修復(fù)的指導(dǎo)
method:通過歷史信息指導(dǎo)啟發(fā)式搜索 - 利用相似代碼
insight:與缺陷代碼相似的代碼可能存在同樣的錯誤
method:通過相似信息指導(dǎo)啟發(fā)式搜索 - 基于修復(fù)模版
insight:特定漏洞修復(fù)是可以總結(jié)的一些模式
method:專家總結(jié)定義修復(fù)模版,直接進行應(yīng)用 - 基于語義約束
insight:修復(fù) bug 就是改變程序使得滿足 test case 的約束
method:搜索約束并轉(zhuǎn)換為約束求解問題
learning-based APR tools
- 補丁排序模型
method:通過提取補丁特征給補丁排序 - 補丁模版獲取
method:聚類收集最常見的修復(fù)方式(模板) - 端到端補丁生成模型(模型選擇與訓(xùn)練數(shù)據(jù)的差別)
- NMT-based
- LLM-based
方法Methodology
Methodology - gap差距
當(dāng)前的方法current method
有bug的代碼被移除,LLM直接預(yù)測正確的代碼
buggy code is removed and a LLM directly predicts correct code
給定前綴和后綴上下文
given the prefix and suffix context
局限性
現(xiàn)有基于llm的APR工具的局限性:
limitation of existing LLM-based APR tools:
1.丟失測試失敗信息
missing test failure information
2.重復(fù)抽樣
repeated sampling
3.對合理補丁的無知
ignorance of plausible patches
可信的補丁:通過測試套件的補丁
plausible patches: patches that pass the test suite
方法概述overview
這頁PPT:將總覽圖黑色虛線框出
建立初始 prompt,得到第一個 patch
通過 test suite 判斷 patch 是否成立
- 如果成立進入下一階段
- 如果不成立持續(xù)詢問 Chatgpt 直到獲取一個 plausible patch
輸入已經(jīng)獲取的 plausible patch 及相關(guān)信息,獲取更多 plausible patch
可信的補丁:通過測試套件的補丁
plausible patches: patches that pass the test suite
① 建立初始 prompt,得到第一個 patch
初始輸入initial input(通過紅色虛線方框突出重點)
1、初始提示符:您是一個自動程序修復(fù)工具
初始 prompt:You are an Automated Program Repair Tool
2、在同一個bug項目中包含一些歷史bug修復(fù)的例子
include a few examples of historical bug fixes within the same buggy project
少樣本通過這樣做,我們將模型調(diào)整到修復(fù)任務(wù)并允許它
few-shot examples By doing so, we gear the model towards the repair task and allow it
學(xué)習(xí)任務(wù)的所需輸出格式(即補丁)。
to learn the desired output format (i.e. a patch) of the task.
3、用填充的位置指示器替換函數(shù)中有錯誤的代碼完全??
replace the buggy code within the function with an infill location indicator (? [ INFILL ] ?)
4、提供原始的bug行
provide the original buggy line
5、失敗的測試1)它的名稱,2)觸發(fā)測試失敗的相關(guān)代碼行,以及3)產(chǎn)生的錯誤信息
failing test(s) 1) its name, 2) the relevant code line(s) triggering the test failure, and 3) the error message produced
②通過 test suite 判斷 patch 是否成立
- 如果成立進入下一階段
- 如果不成立持續(xù)詢問 Chatgpt 直到獲取一個 plausible patch
可信的補丁:通過測試套件的補丁
plausible patches: patches that pass the test suite
③ 輸入已經(jīng)獲取的 plausible patch 及相關(guān)信息,獲取更多 plausible patch
可信的補丁:通過測試套件的補丁
plausible patches: patches that pass the test suite
最后兩個步驟
評估Evaluation
基線Baseline
1、8個最近的基于學(xué)習(xí)和llm的APR基線
8 recent learning-based and LLM-based APR baselines
2、12個精選的傳統(tǒng)方法
12 selected traditional techniques
3、BaseChatGPT
BaseChatGPT
基準Benchmark:
4j和QuixBugs的缺陷
Defects4j and QuixBugs
研究問題Research questions
1、RQ1:ChatRepair與最先進的APR技術(shù)相比,其性能如何?
? RQ1: How does the performance of ChatRepair compare against the state-of-the-art techniques for APR?
2、RQ2: ChatRepair在不同的修復(fù)場景下是如何執(zhí)行的?
? RQ2: How does ChatRepair perform when used in different repair scenarios?
3、RQ3: ChatRepair的不同組成部分對改進修復(fù)效果的貢獻是什么
? RQ3: What are the contributions of different components of ChatRepair in improving repair effectiveness?
RQ1:ChatRepair與最先進的APR技術(shù)相比,其性能如何
1.ChatRepair可以比僅使用ChatGPT模型的基線,分別在Defects4j 1.2和2.0上,提高修復(fù)了34和23個bug
ChatRepair can improve over the baseline of just using the ChatGPT model with 34 and 23 more bug fixes on Defects4j 1.2 and 2.0 respectively.
2.比目前最先進的APR工具多15和17個。
with 15 and 17 more than the current state-of-the-art APR tool.
ChatRepair能夠正確地修復(fù)quixbugs中的所有bug——java和python數(shù)據(jù)集,擊敗所有性能最好的技術(shù)
ChatRepair is able to correctly fix all bugs within the QuixBugs-Java and-Python datasets, beating out all top-performing techniques.
韋恩圖(展示不同方法修復(fù)的集合)
存在有些方法識別的漏洞,這篇文章不能識別
RQ2: ChatRepair在不同的修復(fù)場景下是如何執(zhí)行的?
基線:BaseChatGPT / CodexRepair
baseline: BaseChatGPT / CodexRepair
BaseChatGPT沒有產(chǎn)生令人印象深刻的改進
BaseChatGPT not yield impressive improvements文章來源:http://www.zghlxwxcb.cn/news/detail-771082.html
RQ3: ChatRepair的不同組成部分對改進修復(fù)效果的貢獻是什么
文章來源地址http://www.zghlxwxcb.cn/news/detail-771082.html
到了這里,關(guān)于【網(wǎng)安AIGC專題10.19】5 ChatRepair:ChatGPT+漏洞定位+補丁生成+補丁驗證+APR方法+ChatRepair+不同修復(fù)場景+修復(fù)效果(韋恩圖展示)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!