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 details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

llm_security_reviewer-0.1.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llm_security_reviewer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c4a03f8101e063b6df09ebcc924f517e94369a1ac545abd28233bf484372869a
MD5 3cb69ea29ac7f1f6e2224f7f86852f87
BLAKE2b-256 39d5932ef9e5225559b894f8a454cbb653f18cc1968e9a8c21721c2fb447252c

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