Skip to content

About

CodeGuard AI is a Python-based code reviewer that uses Bandit, Ruff, and Google Gemini to detect potential security vulnerabilities, identify code quality issues, and suggest improvements through a modern Streamlit interface.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ CodeGuard AI

Python Streamlit AI Security Linting Status

A Python-based AI code review application designed to help developers identify potential security vulnerabilities, code quality issues, and possible improvements in their Python programs.

CodeGuard AI combines local static analysis with AI-powered code review through Google Gemini, providing developers with a convenient way to inspect code, understand findings, and improve their programming practices.


๐Ÿ–ฅ๏ธ Application Preview

CodeGuard AI Dashboard
Dashboard
Code scan results
Code Scan Results
AI code review
AI Code Review
About CodeGuard AI
About

๐Ÿ“Œ Overview

CodeGuard AI is a Python application that helps developers review their source code through automated analysis and AI-generated recommendations.

The application uses local analysis tools to detect selected code quality and security issues. It can also use Google Gemini to provide additional explanations, suggestions, and code improvement recommendations.

Its interface is built with Streamlit and features a cybersecurity-inspired design with dark backgrounds and neon blue and purple accents.

CodeGuard AI is intended as a development aid for students, beginners, and programmers who want to improve their understanding of secure coding practices.


โœจ Features

  • ๐Ÿ” Static Code Analysis using local analysis tools
  • ๐Ÿ” Security Checks with Bandit
  • ๐Ÿงน Code Quality Checks with Ruff
  • ๐Ÿค– AI-Powered Code Review using Google Gemini
  • ๐Ÿšจ Finding Severity Categories
  • ๐Ÿ“‹ Detailed Scan Results
  • ๐Ÿง  AI-Generated Explanations and Suggestions
  • ๐ŸŽฏ Finding Filters for easier navigation
  • ๐Ÿ“Š Summary Cards for scan results
  • ๐Ÿ“ฅ CSV Export for supported scan findings
  • ๐Ÿ–ฅ๏ธ Streamlit Web Interface
  • ๐ŸŒŒ Dark Cybersecurity-Inspired Design
  • ๐Ÿงช Automated Tests for supported analyzer functionality

Note: AI review requires a valid Gemini API key. AI suggestions and static-analysis findings should be reviewed before making changes to production code.


๐Ÿ› ๏ธ Technologies Used

Programming Language

  • Python 3.13+

User Interface

  • Streamlit

Static Analysis and Security

  • Bandit
  • Ruff
  • Python pattern-based checks

Artificial Intelligence

  • Google Gemini API
  • Google Gen AI Python SDK

Configuration and Environment

  • python-dotenv
  • Environment variables

Testing

  • pytest

Development Tools

  • Visual Studio Code
  • Git
  • GitHub
  • Python virtual environments

๐Ÿš€ Installation

1. Clone the Repository

Replace the repository URL with your actual GitHub repository if necessary.

git clone https://github.com/your-username/CodeGuardAI.git

2. Navigate to the Project Folder

cd CodeGuardAI

3. Create a Virtual Environment

For Python 3.13:

py -3.13 -m venv .venv

4. Activate the Virtual Environment

For Windows PowerShell:

.\.venv\Scripts\Activate.ps1

If PowerShell blocks activation, allow scripts for the current terminal session:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\.venv\Scripts\Activate.ps1

5. Install Dependencies

python -m pip install --upgrade pip
python -m pip install -r requirements.txt

6. Configure the Gemini API Key

Create a .env file in the project root directory.

GEMINI_API_KEY=your_gemini_api_key_here

If the project uses a configurable Gemini model, you may also set:

GEMINI_MODEL=your_supported_gemini_model

Use a model supported by your Google AI Studio account and the installed SDK.

Important: Never upload your actual .env file or API key to GitHub. Keep .env in .gitignore and use .env.example to document the required configuration.

7. Run the Application

streamlit run app.py

Streamlit will display a local URL in the terminal. Open that URL in your browser to use CodeGuard AI.


๐Ÿ“– How It Works

  1. Open CodeGuard AI in your browser.
  2. Provide the Python code you want to review using the available interface.
  3. Run the local code analysis.
  4. Review the detected findings and their severity categories.
  5. Use the AI review feature for additional explanations and recommendations.
  6. Filter findings to focus on specific issues.
  7. Export supported scan results to CSV when needed.
  8. Review the suggested improvements and verify them before applying changes.

๐Ÿ”Ž Core Modules

  • ๐Ÿ–ฅ๏ธ Dashboard: Main application interface and scan overview.
  • ๐Ÿ” Code Analyzer: Runs local checks and collects findings.
  • ๐Ÿ” Security Analysis: Uses Bandit to identify supported Python security issues.
  • ๐Ÿงน Code Quality Analysis: Uses Ruff to report supported linting findings.
  • ๐Ÿค– AI Reviewer: Requests additional code-review insights from Google Gemini.
  • ๐Ÿ“Š Results Interface: Displays findings, severity information, and filters.
  • ๐Ÿ“ฅ CSV Export: Exports supported scan findings.
  • ๐Ÿงช Tests: Checks supported analyzer functionality.

๐Ÿ“‚ Project Structure

CodeGuardAI/
โ”‚
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ analyzer.py
โ”œโ”€โ”€ ai_reviewer.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”‚
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_analyzer.py
โ”‚
โ””โ”€โ”€ images/
    โ”œโ”€โ”€ Dashboard.png
    โ”œโ”€โ”€ Scan Results.png
    โ”œโ”€โ”€ AI Review.png
    โ””โ”€โ”€ About.png

The images/ directory is optional until screenshots are added. Keep the structure consistent with the actual files in your repository.


๐Ÿ” Security and Responsible Use

CodeGuard AI is a supporting tool, not a replacement for professional security testing or manual code review.

  • Do not assume that a clean scan means code is completely secure.
  • Review all findings before changing your code.
  • Verify AI-generated recommendations before using them.
  • Avoid submitting API keys, passwords, tokens, personal information, or confidential source code to an external AI service.
  • Understand that code submitted for AI review may be sent to the configured provider for processing.
  • Keep your dependencies and development tools updated.

๐Ÿ”ฎ Future Improvements

Potential improvements include:

  • Support for additional programming languages
  • More static-analysis integrations
  • Improved finding explanations
  • Before-and-after code comparisons
  • Severity-based sorting and advanced filters
  • Downloadable PDF reports
  • Scan history and report management
  • Custom security rules
  • GitHub repository integration
  • Continuous integration support
  • Unit-test generation suggestions
  • Improved AI model configuration

These are possible future additions, not necessarily features available in the current version.


๐Ÿ‘จโ€๐Ÿ’ป Developer

Rheil Evans T. Lunio

Computer Science Student

University of Science and Technology of Southern Philippines (USTP)


๐Ÿค Contributing

Contributions, suggestions, bug reports, and feature improvements are welcome.

Please read CONTRIBUTING.md for instructions on contributing to the project.


๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

CodeGuard AI is a Python-based code reviewer that uses Bandit, Ruff, and Google Gemini to detect potential security vulnerabilities, identify code quality issues, and suggest improvements through a modern Streamlit interface.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages