Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,126 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: gpl-3.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: gpl-3.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# PatchitPy
|
| 6 |
+
|
| 7 |
+
This repository contains the code for implementing the patching tool used as VS Code extension proposed in the paper titled *Securing AI Code Generation Through Automated Pattern-Based Patching* accepted at the **8th Dependable and Secure Machine Learning (DSML 2025) workshop**, co-located with the **55th Annual IEEE/IFIP DSN 2025**. This repo is a guide for configuring the Visual Studio Code extension to run the tool locally in debug mode. The extension detect and patch software vulnerabilities for Python.
|
| 8 |
+
|
| 9 |
+
The repo also contains the appendix of the paper (file Appendix.pdf).
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
## Folder organization
|
| 13 |
+
- The `extension_PatchitPy` folder contains the code of the tool.
|
| 14 |
+
- The `code_test` folder includes some code samples to quickly test the extension
|
| 15 |
+
- The `generated_code.zip` folder contains the code generated for the analysis conducted in the related paper.
|
| 16 |
+
- The `img` folder contains the pictures included in this guide.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
## 🛠Setup
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
> **🚨 Prerequisites:**
|
| 24 |
+
> - Please run on a Linux OS or macOS. For Windows users, you can utilize the [Windows Subsystem for Linux](https://learn.microsoft.com/it-it/windows/wsl/install) (WSL); in this case, please ensure to have the WSL installed before proceeding.
|
| 25 |
+
> - Please ensure that Python 3.8 (or later versions) is installed. For Windows users, ensure to have Python installed in WSL.
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
### For Linux OS 🐧 or Windows Users 🪟(WSL):
|
| 29 |
+
|
| 30 |
+
#### (1) Install `jq`
|
| 31 |
+
|
| 32 |
+
Please install **jq** using the following commands:
|
| 33 |
+
|
| 34 |
+
> **⚠️ Disclaimer:** If you are a Windows user, you need to install jq in WSL.
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
sudo apt-get update
|
| 38 |
+
|
| 39 |
+
sudo apt-get install jq
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
#### (2) Make the file executable
|
| 43 |
+
Move to the `launch_tool` folder and type this command:
|
| 44 |
+
```bash
|
| 45 |
+
chmod u+x *.sh
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
Now, let's install NodeJS!
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
## ⬇️Install NodeJS
|
| 53 |
+
Windows and Linux users need the latest version of [Node.js](https://nodejs.org/en).
|
| 54 |
+
|
| 55 |
+
> **⚠️ Disclaimer:** Node.js must be installed on your machine. If you are a Windows user, Node.js must be installed on your Windows machine, not in WSL.
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
## ⬇️Install Yeoman
|
| 60 |
+
Before starting, ensure to have [Yeoman](http://yeoman.io) and the VS Code Extension Generator installed **on the machine where you launch the extension**. You can follow the instructions provided in the official [VS Code guide](https://code.visualstudio.com/api/get-started/your-first-extension) to set up the necessary tools.
|
| 61 |
+
|
| 62 |
+
> **⚠️ Disclaimer:** Again, if you are a Windows user, Yeoman must be installed on your Windows machine, not in WSL :)
|
| 63 |
+
|
| 64 |
+
To install them globally, run the following command:
|
| 65 |
+
```bash
|
| 66 |
+
sudo apt install npm
|
| 67 |
+
sudo npm install --global yo generator-code
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
## 🎯Quickstart
|
| 72 |
+
- First, clone the repository locally.
|
| 73 |
+
- Open the `extension_PatchitPy` directory in VS Code (**⚠️only this directory⚠️**).
|
| 74 |
+
- To run the extension, click on the **Debug** section in the editor.
|
| 75 |
+
|
| 76 |
+

|
| 77 |
+
- Now, click on **Run Extension**.
|
| 78 |
+
|
| 79 |
+

|
| 80 |
+
- VS Code will automatically open a new VS Code window.
|
| 81 |
+
|
| 82 |
+

|
| 83 |
+
- Now, open a directory containing the files with Python code to analyze.
|
| 84 |
+
- Open the file you are interested in and select the code you want to analyze (e.g, a specific part or the entire program).
|
| 85 |
+
- Right-click on the selected code and choose **PatchitPy: Run analysis**.
|
| 86 |
+
|
| 87 |
+

|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
- Once finished the analysis, other popups will appear.
|
| 91 |
+
- Open the full list of popups, **clicking on the bell icon** 🔔 in the bottom left corner, and you should see a similar screen:
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
- You will see a list of detected vulnerabilities categories and comments on the remediation performed by the extension.
|
| 95 |
+
- If you want to fix the code, you can click the **Yes** button; otherwise, click **No**.
|
| 96 |
+
|
| 97 |
+
> **🚨 Warning:**
|
| 98 |
+
> If you open a directory where the path contains spaces, the extension may not work correctly.
|
| 99 |
+
|
| 100 |
+
## ⚡Test the tool
|
| 101 |
+
Use the code in `code_test` folder to test the plugin. Enjoy it!😎
|
| 102 |
+
|
| 103 |
+
## 🐍 Troubleshooting
|
| 104 |
+
> #### **🚨 Problem: `/bin/bash: bad interpreter`**
|
| 105 |
+
> In the **main** folder, run the following script to fix `.sh` file format issues:
|
| 106 |
+
> ```python
|
| 107 |
+
> python convert_to_LF.sh
|
| 108 |
+
> ```
|
| 109 |
+
> Then, open again the `extension_PatchitPy` folder in VS Code, and follow the same steps listed above 😎.
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
## Citation
|
| 113 |
+
|
| 114 |
+
If you use PatchitPy in academic context, please cite it as follows:
|
| 115 |
+
|
| 116 |
+
```bibtex
|
| 117 |
+
@INPROCEEDINGS{11071611,
|
| 118 |
+
author={Altiero, Francesco and Cotroneo, Domenico and De Luca, Roberta and Liguori, Pietro},
|
| 119 |
+
booktitle={2025 55th Annual IEEE/IFIP International Conference on Dependable Systems and Networks Workshops (DSN-W)},
|
| 120 |
+
title={Securing AI Code Generation Through Automated Pattern-Based Patching},
|
| 121 |
+
year={2025},
|
| 122 |
+
volume={},
|
| 123 |
+
number={},
|
| 124 |
+
pages={282-289},
|
| 125 |
+
keywords={Codes;Accuracy;Static analysis;Maintenance engineering;Generators;Complexity theory;Security;Artificial intelligence;Python;Software development management;Vulnerability Patching;Static Analysis;Vulnerability Detection;AI -generated Code},
|
| 126 |
+
doi={10.1109/DSN-W65791.2025.00077}}
|