Skip to main content

A CLI tool for GCP Security Analysis powered by Gemini.

Project description

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.

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

gcpsight-0.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

gcpsight-0.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file gcpsight-0.1.0.tar.gz.

File metadata

  • Download URL: gcpsight-0.1.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for gcpsight-0.1.0.tar.gz
Algorithm Hash digest
SHA256 77abd8c8b0459a2bf2126b81e40a515a60098fa6e0af1f7722e4c067a48c58a1
MD5 40055b184015885b7c42c4a2af693d72
BLAKE2b-256 0c51270218849ad70c0a6e99a10c7d661cde607346270fd950c51b7b8c625f42

See more details on using hashes here.

File details

Details for the file gcpsight-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gcpsight-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for gcpsight-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 651a146e9f0f6839b44b858d2a707449a6f99310f4c65119ec9500f06576aa31
MD5 be59ceef2f95802d93305861cb3e88fd
BLAKE2b-256 0cc146a8877ba4c2a4baf4b6ee526948248d306858afd31a18e77ddd624e3bc1

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