This is a demo program of PatchGNN, a graph neural network based model to detect security patches with their code property graphs (PatchCPGs).
We use Ubuntu 20.04.2.0 LTS (Focal Fossa) desktop version.
Download Link: https://releases.ubuntu.com/20.04/ubuntu-20.04.2.0-desktop-amd64.iso
The virtualization software in our experiments is VirtualBox 5.2.24.
Download Link: https://www.virtualbox.org/wiki/Download_Old_Builds_5_2.
You can use other software like VMware Workstation.
System configurations:
RAM: 2GB
Disk: 25GB
CPU: 1 core in i7-7700HQ @ 2.8GHz
We use home
directory to store the project folder.
cd ~
Install git
tool.
sudo apt install git
Download PatchGNN-demo
project to local disk. (You may need to enter your github account/password.)
git clone https://github.com/shuwang127/PatchGNN-demo
(1) Install pip
tool for python3
.
sudo apt install python3-pip
(2) Install common dependencies.
pip3 install numpy
pip3 install pandas
(3) Install CPU-version PyTorch. Official website: https://pytorch.org/.
pip3 install torch==1.10.0+cpu torchvision==0.11.1+cpu torchaudio==0.10.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
(4) Install clang
tool.
pip3 install clang==6.0.0.2
Configurate the clang environment.
sudo apt install clang
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libclang-*.so.1 libclang.so
(5) Install Torch-Geometric. Official website: https://pytorch-geometric.readthedocs.io/en/latest/.
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.10.0+cpu.html
cd ~/PatchGNN-demo/
python3 test.py
There are 6 input test samples stored in ~/PatchGNN-demo/testdata/
, the output results are saved in ~/PatchGNN-demo/logs/test_results.txt
.
cat logs/test_results.txt
You can find the results.
filename,prediction
./testdata/02cca547\out_slim_ninf_noast_n1_w.log,0
./testdata/661e4086\out_slim_ninf_noast_n1_w.log,1
./testdata/9a3ec202\out_slim_ninf_noast_n1_w.log,1
./testdata/dac90a4b\out_slim_ninf_noast_n1_w.log,1
./testdata/e3797a66\out_slim_ninf_noast_n1_w.log,0
./testdata/fc785b12\out_slim_ninf_noast_n1_w.log,0