Configure Python IDE Environment - SVF-tools/Software-Security-Analysis GitHub Wiki

1. Prerequisite:

2. Run with VSCode

If you encounter some problem, please check this document Trouble-Shooting-for-IDE.

2.1 Working with VSCode in Docker containers

Install extensions in VSCode

*To install the extension, open the Extensions view (MAC: โ‡งโŒ˜X, Windows: Ctrl+Shift+X, Linux: Ctrl+Shift+X)
  • Extension(1): Docker extension
    • Search for docker to filter results and select Docker extension authored by Microsoft.

width=600px

  • Extension(2): Remote Containers extension
    • Search for dev container to filter results and select extension authored by Microsoft.

width=600px


Load Docker container in VSCode

Right click the container item and select 'Attach Visual Studio Code'

width=600px

If you can't see the working directory, please select file -> open (folder)... then enter the /home/SVF-tools/Software-Security-Analysis

width=600px


Install/Enable Python Debugger extension in container

*To install the extension, open the Extensions view (MAC: โ‡งโŒ˜X, Windows: Ctrl+Shift+X, Linux: Ctrl+Shift+X)

Search for Python Debugger and select Docker extension authored by Microsoft.

width=600px

The labs use Jupyter Notebook, which displays code and output together. First, install the ipykernel package from pip, using your command line of choice (this is required for the VS Code Jupyter extension to work properly):

pip install ipykernel

Search for Jupyter and install the extension pack authored by Microsoft:

width=600px


2.2 Run and debug your program

  • VSCode's built-in debugger helps your editing, compilation and debugging.

  • Check that the Python interpreter should be /usr/bin/python3 or the virtual environment where you installed pysvf. Click Search - Show and Run Commands - Python: Select Interpreter, and choose a Python 3.8-3.12 interpreter.

width=600px width=600px

  • Software-Security-Analysis has prepared configurations in launch.json in .vscode folder to debug test.py in ${workspaceFolder}/Assignment-1/Python folder.

width=600px

Switching programs

When working on different labs/assignments, change the "program" and "args" fields in launch.json

Lab/Assignment "program" "args"
Assignment-1 "${workspaceFolder}/Assignment-1/Python/test.py" "-icfg", "Assignment-1/Tests/testcases/icfg/test1.ll" "-pta", "Assignment-1/Tests/testcases/pta/test1.ll" "-taint", "Assignment-1/Tests/testcases/taint/test1.ll"
Assignment-2 "${workspaceFolder}/Assignment-2/Python/test-sse.py" "Assignment-2/Tests/testcases/sse/test1.ll"
Assignment-3 "${workspaceFolder}/Assignment-3/Python/test-ae.py" "Assignment-3/Tests/stmt.ll" "Assignment-3/Tests/buf_overflow.ll" "Assignment-3/Tests/null_deref.ll"

3. Run with PyCharm

PyCharm is a powerful Python IDE. This section explains how to set up your project and work with pysvf using PyCharm on Linux/macOS and Windows (via Docker).


3.1 Install PyCharm


3.2 Install Required Python Packages

If you're using Linux or macOS, you can install pysvf directly in PyCharm terminal:

python3 -m pip install pysvf

For Windows users, follow these steps to configure PyCharm with Docker:

  1. Navigate to File > Settings > Project > Python Interpreter

  2. Click Add Interpreter and select On Docker width=800px

  3. Select Pull or use existing, enter svf-tools/software-security-analysis in the Image tag field, then click Next width=800px

  4. If no errors appear in the output field, click Next width=800px

  5. Click Create to finish the setup width=800px

  6. Return to the Python Interpreter settings. If you see a remote Python interpreter from svf-tools/software-security-analysis, the configuration was successful width=800px