Skip to main content

AI-powered security code reviewer using a fine-tuned Qwen2.5-Coder LLM

Project description

llm-security-reviewer

AI-powered security code reviewer using a fine-tuned Qwen2.5-Coder-7B LLM. Scans code for vulnerabilities, reports CWE identifiers, and integrates directly with GitHub Pull Requests.

Python PyPI License


Requirements

  • Python 3.10+
  • NVIDIA GPU with CUDA (required — the model runs in 4-bit quantization)
  • 8GB+ VRAM recommended

Installation

pip install llm-security-reviewer

Setup

Download the fine-tuned adapter weights and place them in a folder called adapters/:

your-project/
└── adapters/
    ├── adapter_config.json
    └── adapter_model.safetensors

For GitHub PR reviews, set your token as an environment variable:

# Windows
set GITHUB_TOKEN=your_token_here

# Linux / macOS
export GITHUB_TOKEN=your_token_here

Usage

Review a local file:

llm-reviewer --file path/to/main.c --adapters path/to/adapters

Review a code snippet directly:

llm-reviewer --code "void login() { gets(password); }" --adapters path/to/adapters

Review a GitHub Pull Request:

llm-reviewer --pr 42 --repo owner/repo --adapters path/to/adapters

Supported file types: .c, .cpp, .h, .py, .js, .ts, .java, .go, .php, .rb, .rs, .cs


Example Output

============================================================
  SECURITY REVIEW REPORT
============================================================
  Files/Functions reviewed : 4
  Vulnerabilities found    : 2
  Status: REVIEW NEEDED
============================================================

[1] main.c — function 1
    Verdict : VULNERABLE
    CWE     : CWE-120
    Review  :
      Buffer overflow via gets(). No bounds checking on input.
      Attacker can overwrite stack memory.

[2] main.c — function 2
    Verdict : SAFE
    CWE     : N/A
    Review  :
      Uses fgets() with explicit buffer size. No issues found.

RECOMMENDATION: Do not merge. Address the vulnerabilities above before merging.

Running Tests

pip install llm-security-reviewer[dev]
pytest tests/ -v

Project Structure

src/reviewer/
├── __init__.py       # package entry point
└── reviewer.py       # core logic — model loading, review, reporting
tests/
├── conftest.py       # shared stubs and fixtures
├── test_parsing.py   # patch parsing and function extraction
├── test_model.py     # verdict and CWE detection
├── test_github.py    # PR file filtering
├── test_reporting.py # report output
└── test_review_file.py

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_security_reviewer-0.1.1.tar.gz (72.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_security_reviewer-0.1.1-py3-none-any.whl (76.8 MB view details)

Uploaded Python 3

File details

Details for the file llm_security_reviewer-0.1.1.tar.gz.

File metadata

  • Download URL: llm_security_reviewer-0.1.1.tar.gz
  • Upload date:
  • Size: 72.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for llm_security_reviewer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8dfbd8595ae2d0b1a0451ee4b58f60eb6ce400f7d073812fd85086f3d0f636b3
MD5 294b8cc82b92b7937958cfcc837b0177
BLAKE2b-256 d3f15883d19b9dbb642ec49f83c54feede9c9114c09305b3db768bbd0e1cf536

See more details on using hashes here.

File details

Details for the file llm_security_reviewer-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_security_reviewer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee02cd8ca155f35a25078cb5f0996d52c292c7a7a4fba8b6a0e1d563ed86d74c
MD5 002601986bd4ffa91323ddf93be9e6a4
BLAKE2b-256 1892f0c158be62d924d2d5d6440242e6419eb45d681c6616cdd7d678f01977ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page