This repository contains the PRISM-VD framework, a state-of-the-art vulnerability detection platform utilizing both Graph Neural Networks (GNNs) and LLM baselines.
The pipeline is fully divided into three core phases: Environment Setup, Data Creation, and Model Training.
Before running anything, ensure your environment is prepared by installing all required dependencies.
# Navigate to the project root
cd PRISM-VD/
# Install the Python requirements
pip install -r requirements.txtThe Data Creation phase involves taking raw C/C++ code and extracting multi-view structural graphs using the ATLAS adapter. We implement USCP (Universal Structural Causal Paths) extraction filtered by DSG (Dangerous Structure Graph) pruning rules to drastically reduce noise and computational limits.
To run the data creation pipeline:
cd data_processing/
# Run the SOTA USCP data preparation script
python prepare_data_uscp.py \
--input raw_dataset.jsonlines \
--format jsonlines \
--output_dir ../data/processed/BigVul/ \
--text_col "func_before" \
--label_col "vul" \
--lang c \
--max_workers 8 \
--skip_empty True- Sanitization: Code is cleaned, attributes are selectively stripped, and formatting is normalized.
- Graph Extraction:
atlas_adapter.pyinitiates ATLAS to extract the AST, CFG, and DFG representations into aMultiDiGraph. - DSG Filtering: Nodes are pruned using PRISM-VD's novel proposed DSG rules (retaining only
call_expression,if_statement,pointer_declarator, etc.). - USCP Extraction: AST nodes are classified into structural roles (
CALL,DEREF,ENTRY,EXIT,ASSIGN,GUARD) to map causal data flow pathways between these security-relevant boundaries.
Once the .jsonlines datasets containing uscp_paths and graph topology are created, you can train the GNN models. The scripts support distributing the training across multiple GPUs seamlessly.
cd graph_models/src/
# Example 1: Train the RGAT model on the BigVul dataset using the Divul Script
# This uses Focal Loss and generates models inside bv_res_v2/
./run_train_Divul.sh BigVul
# Example 2: Train using Random Walk with Restart (RWR) path slicing
./run_train_rwr.sh BigVul
# Example 3: Train Hop-based models on the Devign dataset
./run_train_hop_devign.sh DevignTraining Arguments Overview (Inside the Shell Scripts):
--gnn: Defines the backbone (e.g.,rgat,gatv2,gin,sage,ggcn). (Seegraph_models/algorithms.mdfor a detailed breakdown of all algorithms!)--loss_mode: Supports highly imbalanced dataset loss architectures (focal_only,wbce_only).--slice_method: How causal paths are sliced (vpc,cta_rwr).--fusion: Graph + Text fusion approach (e.g.,gated).--pooling: Pooling method across the graph (attention).
For direct LLM-based detection (GPT-4, DeepSeek, Codestral) without graph integration, refer to the llm_baselines/ directory and use the run_devign.py or run_devign_multicpu.sh evaluation wrappers.