Skip to content

rishabkumar7/gcpsight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

gcpsight - GCP Security Scanner with Gemini-Powered Queries

A powerful command-line tool for scanning Google Cloud Platform (GCP) projects for security misconfigurations. Features an AI-powered natural language interface using Google's Gemini model, comprehensive security scoring, and beautiful terminal reports.

πŸš€ Quick Install

pip install gcpsight

Or using uv

uv pip install gcpsight

✨ Features

  • πŸ”₯ Firewall Scanning: Detects VPC firewall rules open to the internet (0.0.0.0/0)
  • πŸͺ£ Public Storage Detection: Finds publicly accessible GCS buckets
  • πŸ‘₯ IAM Analysis: Identifies overly permissive roles (Owner, Editor) with broad access
  • πŸ“Š BigQuery Security: Checks for publicly accessible datasets
  • ⚑ Cloud Functions: Scans for insecure functions with public access or outdated runtimes
  • πŸ›‘οΈ Security Scoring: Risk-based scoring with detailed remediation guidance
  • πŸ€– AI-Powered Queries: Natural language security questions via Gemini
  • 🎨 Beautiful Reports: Colorful terminal output with emojis and structured tables

πŸ“‹ Quick Start Examples

Basic Security Scan

# Run comprehensive security assessment
gcpsight security-assessment --project-id my-gcp-project

# Check specific security issues
gcpsight list-open-firewalls --project-id my-gcp-project
gcpsight check-public-buckets --project-id my-gcp-project

AI-Powered Natural Language Queries

# Ask questions in plain English
gcpsight ask --project-id my-gcp-project "are there any firewalls open to the world?"
gcpsight ask --project-id my-gcp-project "show me my security score"
gcpsight ask --project-id my-gcp-project "check my cloud functions for issues"

Sample Output

Security Assessment Report:

πŸ›‘οΈ  GCP SECURITY ASSESSMENT REPORT  πŸ›‘οΈ

πŸ“Š Overall Assessment
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 🎯 Security Score β”‚ 75/100 (75.0%)               β”‚
β”‚ ⚠️  Risk Level     β”‚ HIGH                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Security Score Progress β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 75.0%

πŸ“‹ Findings Summary
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Risk Level  β”‚ Count β”‚ Visual   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 🚨 CRITICAL β”‚ 1     β”‚ ●        β”‚
β”‚ ⚠️ HIGH      β”‚ 2     β”‚ ●●       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Detailed Findings

🚨 Open Firewall [CRITICAL]
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 🏷️  Resource: allow-ssh-from-anywhere                      β”‚
β”‚ πŸ“ Issue: Firewall rule allows unrestricted SSH access     β”‚
β”‚ πŸ“‰ Impact: -25 points                                      β”‚
β”‚ πŸ”§ Fix: Restrict source ranges to specific IP addresses    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

  • src/gcpsight/main.py: The main entry point for the CLI application, built using click.
  • src/gcpsight/gcp_scanner.py: Contains the core logic for interacting with GCP APIs.
  • src/gcpsight/gemini_processor.py: Handles interaction with the Gemini API.
  • src/gcpsight/security_scorer.py: Implements security scoring, risk assessment, and reporting functionality.
  • pyproject.toml: Defines project metadata, dependencies, and the CLI entry point for packaging.
  • requirements.txt: Lists project dependencies (primarily for reference).
  • README.md: This file.
  • .env (not included, but necessary for local development): Used for environment variables.

πŸ”§ Setup & Configuration

Prerequisites

  • Python 3.9+
  • Google Cloud SDK installed and configured
  • Valid GCP project with appropriate permissions

1. Install gcpsight

pip install gcpsight

2. GCP Authentication

# Authenticate with your GCP account
gcloud auth application-default login

# Or set service account credentials
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"

3. Required GCP Permissions

Your authenticated user/service account needs these IAM permissions:

  • compute.firewalls.list
  • storage.buckets.list & storage.buckets.getIamPolicy
  • resourcemanager.projects.getIamPolicy
  • bigquery.datasets.list & bigquery.datasets.get
  • cloudfunctions.functions.list & cloudfunctions.functions.getIamPolicy

4. Gemini API Key (for AI features)

# Set your Gemini API key as environment variable
export GEMINI_API_KEY="your-gemini-api-key-here"

# Or create a .env file in your working directory
echo "GEMINI_API_KEY=your-gemini-api-key-here" > .env

πŸ“– All Available Commands

Security Assessment (Recommended)

# Comprehensive security report with scoring
gcpsight security-assessment --project-id my-project

# JSON output for automation
gcpsight security-assessment --project-id my-project --output-format json

# Table format for quick overview
gcpsight security-assessment --project-id my-project --output-format table

Individual Security Checks

# Check firewall rules
gcpsight list-open-firewalls --project-id my-project

# Check storage buckets
gcpsight check-public-buckets --project-id my-project

# Check IAM roles  
gcpsight check-overly-permissive-iam-roles --project-id my-project

# Check BigQuery datasets
gcpsight check-public-bigquery-datasets --project-id my-project

# Check Cloud Functions
gcpsight check-insecure-cloud-functions --project-id my-project

# Run all individual checks
gcpsight run-all-checks --project-id my-project

AI-Powered Natural Language Queries

# Ask security questions in plain English
gcpsight ask --project-id my-project "are there any firewalls open to the world?"
gcpsight ask --project-id my-project "show me public buckets"
gcpsight ask --project-id my-project "check for overly permissive IAM roles"
gcpsight ask --project-id my-project "are there any public BigQuery datasets?"
gcpsight ask --project-id my-project "check my cloud functions for issues"
gcpsight ask --project-id my-project "run all checks"
gcpsight ask --project-id my-project "give me a security assessment"
gcpsight ask --project-id my-project "what's my security score?"

Example Command Outputs

Firewall Check:

πŸ” Checking open firewall rules for project my-project...

πŸ”₯ Open Firewall Rules
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name                β”‚ Network β”‚ Source Range β”‚ Allowed Ports   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ allow-ssh-anywhere  β”‚ default β”‚ 0.0.0.0/0    β”‚ tcp:22          β”‚
β”‚ allow-http-https    β”‚ default β”‚ 0.0.0.0/0    β”‚ tcp:80,tcp:443  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Security Assessment Table Format:

πŸ›‘οΈ  Security Assessment Summary
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 🎯 Security Score β”‚ 75/100 (75.0%)       β”‚
β”‚ ⚠️  Risk Level     β”‚ HIGH                  β”‚
β”‚ πŸ“Š Total Findings β”‚ 3                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Detailed Security Findings
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Check Type           β”‚ Resource            β”‚ Risk Level  β”‚ Score Impact β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Open Firewall        β”‚ allow-ssh-anywhere  β”‚ 🚨 CRITICAL β”‚ -25          β”‚
β”‚ Public Bucket        β”‚ my-public-bucket    β”‚ ⚠️ HIGH      β”‚ -15          β”‚
β”‚ Insecure Function    β”‚ my-function         β”‚ ⚑ MEDIUM    β”‚ -10          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Development Installation

For contributors and developers who want to work on gcpsight:

# Clone the repository
git clone https://github.com/rishabkumar7/gcpsight
cd gcpsight

# Install in development mode
pip install -e .

# Or build and install locally
python -m pip install build
python -m build
pip install dist/gcpsight-*.whl

πŸš€ How it Works

  1. CLI Interface: Built with click library for intuitive command-line interaction
  2. GCP API Integration: Uses official Google Cloud client libraries for secure API access
  3. Security Analysis: Comprehensive checks across compute, storage, IAM, and serverless resources
  4. Risk Scoring: Intelligent scoring system with weighted impact based on security severity
  5. AI Integration: Gemini AI translates natural language queries into specific security checks
  6. Rich Output: Beautiful terminal reports with colors, emojis, and structured tables

Future Enhancements

  • Add more GCP security checks.
  • Improve output formatting.
  • More sophisticated error handling and logging.
  • Scan multiple projects or an entire GCP organization.
  • Automated remediation suggestions/actions (with caution!).

Contributing

Contributions are welcome! Please open an issue.

License

This is under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published