AI-powered security scanner for modern development workflows
Project description
๐ก๏ธ GuardRails Security Scanner (Python)
AI-powered security scanner for modern development workflows
GuardRails uses advanced AI (Gemini) to detect security vulnerabilities in your code, providing detailed explanations and fix suggestions.
๐ Quick Start
# Install from PyPI
pip install guardrails-security
# Or install from source
pip install git+https://github.com/guardrails/guardrails-security.git
# Scan your code
guardrails scan .
# Initialize in your project
guardrails init
๐ Features
- โ AI-Powered Analysis - Uses Gemini AI for intelligent vulnerability detection
- โ Multi-Language Support - Python, JavaScript, TypeScript, Java, Go, PHP, Ruby, C#
- โ Detailed Fix Suggestions - Get specific code fixes for each vulnerability
- โ CI/CD Integration - Easy integration with GitHub Actions, GitLab CI, etc.
- โ Git Hooks - Automatic scanning before commits
- โ Multiple Output Formats - Text, JSON, table formats
- โ Configurable - Customize scan rules and ignore patterns
๐ง Installation
From PyPI (Recommended)
pip install guardrails-security
From Source
git clone https://github.com/guardrails/guardrails-security.git
cd guardrails-security
pip install -e .
Development Installation
git clone https://github.com/guardrails/guardrails-security.git
cd guardrails-security
pip install -e ".[dev]"
๐ Usage
Basic Scanning
# Scan current directory
guardrails scan .
# Scan specific file
guardrails scan app.py
# Scan with JSON output
guardrails scan . --format json
# Save report to file
guardrails scan . --output security-report.json
CI/CD Integration
# Fail build on critical issues
guardrails scan . --fail-on-critical
# Generate JSON report for CI
guardrails scan . --format json --output guardrails-report.json
Git Hooks
# Install pre-commit hook
guardrails install-hook
# Install hook that blocks commits on critical issues
guardrails install-hook --fail-on-critical
Project Initialization
# Initialize GuardRails in your project
guardrails init
This creates:
guardrails.config.json- Configuration file.guardrailsignore- Ignore patterns- Updates
requirements.txtif it exists
โ๏ธ Configuration
Create a guardrails.config.json file:
{
"version": "1.0.0",
"scan": {
"extensions": [".py", ".js", ".ts", ".jsx", ".tsx", ".java", ".go"],
"ignore": ["node_modules/**", ".git/**", "dist/**", "build/**"],
"failOnCritical": true
},
"ci": {
"enabled": true,
"output": "guardrails-report.json"
}
}
๐ CI/CD Integration
GitHub Actions
name: Security Scan
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install GuardRails
run: pip install guardrails-security
- name: Run Security Scan
run: guardrails scan . --fail-on-critical
GitLab CI
security_scan:
stage: test
image: python:3.9
script:
- pip install guardrails-security
- guardrails scan . --format json --output guardrails-report.json
artifacts:
reports:
junit: guardrails-report.json
Makefile Integration
.PHONY: security-scan
security-scan:
guardrails scan . --fail-on-critical
.PHONY: security-report
security-report:
guardrails scan . --format json --output security-report.json
๐ฏ Supported Languages
- Python -
.py - JavaScript/TypeScript -
.js,.ts,.jsx,.tsx - Java -
.java - Go -
.go - PHP -
.php - Ruby -
.rb - C# -
.cs
๐ Vulnerability Types
GuardRails detects:
- SQL Injection - Database query vulnerabilities
- XSS (Cross-Site Scripting) - Web application vulnerabilities
- Hardcoded Credentials - Exposed passwords and API keys
- Insecure Dependencies - Vulnerable third-party packages
- Authentication Issues - Weak authentication mechanisms
- Authorization Flaws - Access control problems
- Data Exposure - Sensitive data leaks
- Cryptographic Issues - Weak encryption and hashing
๐ Output Formats
Text Format (Default)
๐ก๏ธ GuardRails Security Report
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Security Score: 75/100
๐ Files Scanned: 15
๐จ Total Issues: 3
๐ Issues by Severity:
๐ด Critical: 1
๐ก High: 1
๐ต Medium: 1
๐ข Low: 0
๐ Detailed Findings:
1. SQL INJECTION
๐ File: src/database.py:25
โ ๏ธ Potential SQL injection detected
๐ก Fix: Use parameterized queries to prevent SQL injection...
JSON Format
{
"securityScore": 75,
"summary": {
"totalFiles": 15,
"vulnerabilities": 3,
"critical": 1,
"high": 1,
"medium": 1,
"low": 0
},
"findings": [
{
"id": "sql-injection-123",
"type": "SQL_INJECTION",
"severity": "CRITICAL",
"file": "src/database.py",
"line": 25,
"message": "Potential SQL injection detected",
"fix": "Use parameterized queries...",
"analysis": "Detailed AI analysis..."
}
]
}
๐ ๏ธ API Usage
from guardrails import GuardRailsScanner
# Initialize scanner
scanner = GuardRailsScanner(
api_key="your-api-key", # Optional for local server
base_url="https://api.guardrails.dev" # Or local server
)
# Scan directory
results = scanner.scan("./src")
# Check for critical issues
if scanner.has_critical_issues(results):
print("Critical security issues found!")
exit(1)
# Get formatted report
report = scanner.format_report(results, "text")
print(report)
# Check server status
status = scanner.check_server_status()
print(f"Server status: {status['status']}")
๐ง Command Line Options
guardrails scan <target> [options]
Options:
-f, --format <format> Output format (text, json, table)
-o, --output <file> Output file path
--fail-on-critical Exit with error code if critical issues found
--ignore <patterns> Ignore patterns (comma-separated)
--extensions <exts> File extensions to scan (comma-separated)
--api-key <key> GuardRails API key
--server <url> GuardRails server URL
--timeout <seconds> Request timeout
-h, --help Display help
-V, --version Display version
๐ Server Setup
GuardRails requires a backend server for AI analysis:
# Clone the repository
git clone https://github.com/guardrails/guardrails.git
cd guardrails
# Install dependencies
pip install -r requirements.txt
# Set up environment
cp env.example .env
# Edit .env with your Gemini API key
# Start the server
python -m guardrails.server
๐ Business Model
GuardRails offers multiple pricing tiers:
๐ Free Tier
- Individual developers
- Public repositories
- 100 scans/month
- Basic vulnerability detection
๐ผ Team ($49/month)
- Up to 5 developers
- Private repositories
- 1,000 scans/month
- AI-powered fix suggestions
- CI/CD integration
๐ข Enterprise ($299/month)
- Unlimited developers
- Unlimited scans
- Advanced reporting
- Priority support
- Custom rules
๐๏ธ Enterprise+ ($999/month)
- On-premise deployment
- SLA guarantee
- Dedicated support
- Custom integrations
๐ค Contributing
We welcome contributions! Please see our Contributing Guide.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
๐ License
MIT License - see LICENSE file.
๐ Links
- Website: https://guardrails.dev
- Documentation: https://docs.guardrails.dev
- GitHub: https://github.com/guardrails/guardrails-security
- PyPI: https://pypi.org/project/guardrails-security/
- Support: support@guardrails.dev
๐ Support
- Documentation: https://docs.guardrails.dev
- Issues: https://github.com/guardrails/guardrails-security/issues
- Email: support@guardrails.dev
- Discord: https://discord.gg/guardrails
Made with โค๏ธ by the GuardRails team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guardrails_security-1.0.0.tar.gz.
File metadata
- Download URL: guardrails_security-1.0.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef772099171a246c8141d5b42dca99334cf9941bf305af7eb66b9814dc395cb8
|
|
| MD5 |
fef1a65bb47f42c8d8a78f61647b9c1f
|
|
| BLAKE2b-256 |
9ced4a98206e12c3d09952b51873921dc401fd23cf4a1d88ae1b304ba53598a1
|
File details
Details for the file guardrails_security-1.0.0-py3-none-any.whl.
File metadata
- Download URL: guardrails_security-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5cd30ce1dce90212ac802943ce71d7e20a0624a5966e9effd4b3d2b24cdfa65
|
|
| MD5 |
06ed98687e0e17a1092f3318883a00fc
|
|
| BLAKE2b-256 |
121b7215b9911cebe05061e648a9e1513d0a746fcb336fa610fafc13a9bc083b
|