Skip to content

VulDet/FraMe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

41 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FraMe: Fine-Grained Reasoning Enhanced Vulnerability Patch Generation with Multi-View Fix Knowledge

Overview

In this repository, you will find a Python implementation of our FraMe. FraMe is a novel automated approach that leverages fine-grained reasoning with multi-view fix knowledge to enhance LLM-based vulnerability patch generation. It consists of two modules: stepwise fix-reasoning path collection and multi-view knowledge augmented patch generation.

Setting up the environment

You can set up the environment by following commands.

conda create -n FraMe python=3.8.5
conda install pytorch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 pytorch-cuda=11.8 -c pytorch -c nvidia
pip install transformers==4.46.3
pip install openai==1.84.0
pip install scikit-learn
pip install tree-sitter
pip install tree-sitter-c

Package Structure

β”œβ”€β”€ Code
    β”œβ”€β”€ code_embedding
        β”œβ”€β”€ utils
            β”œβ”€β”€ __init__.py
            β”œβ”€β”€ early_stopping.py
        β”œβ”€β”€ model.py
        β”œβ”€β”€ run.py
    β”œβ”€β”€ graph_embedding
        β”œβ”€β”€ gat.py
        β”œβ”€β”€ loss.py
        β”œβ”€β”€ train.py
        β”œβ”€β”€ utils.py
    β”œβ”€β”€ patch generation
        β”œβ”€β”€ data_preprocess.py
        β”œβ”€β”€ model.py
        β”œβ”€β”€ repair_direct_reasoning.py
        β”œβ”€β”€ repair_frame.py
    β”œβ”€β”€ VulKG_construction
        β”œβ”€β”€ import
            β”œβ”€β”€ bigvul
                β”œβ”€β”€ ...
            β”œβ”€β”€ reposvul
                β”œβ”€β”€ ...
        β”œβ”€β”€ VulKG_Deployment.cypher
β”œβ”€β”€ Datasets
    β”œβ”€β”€ graph_data
        β”œβ”€β”€ bigvul_graph_data.pkl 
        β”œβ”€β”€ reposvul_graph_data.pkl 
    β”œβ”€β”€ graph_embedding
        β”œβ”€β”€ bigvul_graph_embeddings.pkl
        β”œβ”€β”€ reposvul_graph_embeddings.pkl
    β”œβ”€β”€ prompt
        β”œβ”€β”€ generate_prompt.txt
        β”œβ”€β”€ repair_prompt.txt
    β”œβ”€β”€ source_code
        β”œβ”€β”€ bigvul
            β”œβ”€β”€ ...
        β”œβ”€β”€ reposvul
            β”œβ”€β”€ ...
   

How to use

Example usage to run repair_frame:

n_example: Number of generated candidate patches.

sample: The maximum number of FiRP generation attempts.

api_key: Place your deepseek access key.

python repair_frame.py --dataset bigvul --n_example 10 --sample 25 --model_dir ./saved_models

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages