Spectra is a comprehensive Go-based application that automatically analyzes large, complex applications to detect, prevent, and report any form of secrets exposure, hardcoded data, or configuration leaks that should never be shipped to production.
- Secrets & Credentials: AWS keys, API keys, passwords, tokens, certificates
- PII Detection: Email addresses, credit card numbers, SSNs, phone numbers
- Hardcoded Values: URLs, endpoints, configuration values
- Encoded Secrets: Base64, hex, URL-encoded, and custom encodings
- Context-Aware: Understands code context to reduce false positives
- OWASP Compliance: Enforces OWASP top risks and CWE leak categories
- Regulatory Support: GDPR, HIPAA, PCI-DSS compliance checks
- CIS Benchmarks: Follows CIS security benchmark practices
- Zero False Negatives: Prioritizes catching all real secrets
- High Performance: Scans thousands of files efficiently
- Parallel Processing: Multi-threaded scanning with configurable workers
- Incremental Scanning: Fast checks during commits
- Memory Efficient: Handles large repositories without memory issues
- CI/CD Integration: GitHub Actions, GitLab CI, Jenkins, CircleCI
- Git Hooks: Pre-commit, pre-push, and post-commit hooks
- Multiple Formats: JSON, YAML, HTML, Markdown, CSV reports
- Real-time Alerts: Slack, Teams, email notifications
- Configurable Rules: Custom patterns and allowlists
- Go 1.21 or later
- Git (for repository scanning)
# Clone the repository
git clone https://github.com/spectra/spectra.git
cd spectra
# Build the application
go build -o spectra cmd/spectra/main.go
# Install globally (optional)
sudo mv spectra /usr/local/bin/go install github.com/spectra/spectra@latest# Scan current directory
spectra scan .
# Scan specific files
spectra scan file1.go file2.py
# Scan with custom output directory
spectra scan . --output ./security-reports
# Scan with specific severity threshold
spectra scan . --min-severity high
# Verbose output
spectra scan . --verbose# Initialize configuration file
spectra config init
# Validate configuration
spectra config validate
# Show current configuration
spectra config show# Install Git hooks
spectra install git-hooks
# Install GitHub Actions workflow
spectra install cicd --platform github-actions
# Install all CI/CD integrations
spectra install cicd --platform allSpectra uses YAML configuration files. Create a .spectra.yaml file in your project root:
# General settings
log_level: info
log_format: json
# Scanning configuration
scan:
paths: ["."]
exclude_patterns:
- "**/.git/**"
- "**/node_modules/**"
- "**/vendor/**"
- "**/target/**"
- "**/build/**"
include_extensions:
- ".go"
- ".py"
- ".js"
- ".ts"
- ".java"
- ".yaml"
- ".json"
- ".env"
max_file_size: 10485760 # 10MB
max_depth: 100
static_analysis: true
dynamic_analysis: true
dependency_scan: true
# Detection rules
rules:
enable_secrets: true
enable_credentials: true
enable_api_keys: true
enable_tokens: true
enable_pii: true
enable_hardcoded: true
min_severity: low
min_confidence: 0.7
# Output configuration
output:
formats: ["json", "yaml", "html"]
directory: "./spectra-reports"
alerts:
enabled: true
critical_only: false
slack:
enabled: false
webhook: ""
channel: "#security"
email:
enabled: false
to: ["security@company.com"]
from: "spectra@company.com"
# Performance settings
performance:
max_workers: 0 # 0 = auto-detect
max_memory_mb: 1024
scan_timeout: 30m
file_timeout: 30s
enable_cache: true
cache_ttl: 1hSpectra includes built-in patterns for common secret types:
- Access Key IDs (AKIA...)
- Secret Access Keys
- Session Tokens
- Google API Keys
- GitHub Tokens
- Slack Tokens
- Stripe Keys
- Generic API Keys
- Connection Strings
- DSNs
- Driver Credentials
- Email Addresses
- Credit Card Numbers
- Phone Numbers
- SSNs
Add your own detection patterns:
rules:
custom_patterns:
- name: "Company API Key"
pattern: "company_api_[A-Za-z0-9]{32}"
description: "Company-specific API key pattern"
severity: high
confidence: 0.9Spectra generates comprehensive reports in multiple formats:
Interactive web-based report with:
- Executive summary
- Detailed findings
- Risk scoring
- Remediation guidance
Machine-readable formats for integration:
{
"scan_id": "scan_1234567890",
"start_time": "2024-01-01T00:00:00Z",
"end_time": "2024-01-01T00:05:00Z",
"duration": "5m0s",
"files_scanned": 150,
"findings": [...],
"summary": {
"total_findings": 5,
"critical_findings": 1,
"high_findings": 2,
"medium_findings": 1,
"low_findings": 1,
"risk_score": 75.5
}
}Human-readable report for documentation and sharing.
Spreadsheet-compatible format for data analysis.
Create custom detection rules:
rules:
custom_patterns:
- name: "Database Password"
pattern: "db_password\\s*[:=]\\s*['\"]([^'\"]+)['\"]"
description: "Database password in configuration"
severity: critical
confidence: 0.95
tags: ["database", "password"]Ignore false positives:
rules:
allowlist:
- pattern: "example\\.com"
reason: "Example domain for testing"
- pattern: "test_.*_key"
reason: "Test keys in test files"Use different configurations for different environments:
# Development
spectra scan . --config .spectra.dev.yaml
# Production
spectra scan . --config .spectra.prod.yamlname: Security Scan
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Spectra
run: |
spectra scan . --min-severity mediumsecurity_scan:
stage: test
script:
- spectra scan . --min-severity medium
artifacts:
reports:
junit: spectra-reports/spectra-report.xml# Install pre-commit hook
spectra install git-hooks --type pre-commit
# The hook will automatically run on every commit
git commit -m "Add new feature"
# Spectra will scan staged files before commit# Clone repository
git clone https://github.com/spectra/spectra.git
cd spectra
# Install dependencies
go mod download
# Build
go build -o spectra cmd/spectra/main.go
# Run tests
go test ./...
# Run with race detection
go test -race ./...- Add pattern to
internal/detector/patterns.go - Update tests in
internal/detector/patterns_test.go - Run tests to ensure pattern works correctly
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Spectra is designed for high performance:
- Parallel Processing: Configurable worker threads
- Memory Efficient: Streams large files instead of loading entirely
- Caching: Intelligent caching of scan results
- Incremental: Only scans changed files when possible
- Small Project (100 files): ~2 seconds
- Medium Project (1,000 files): ~15 seconds
- Large Project (10,000 files): ~2 minutes
- Enterprise Project (100,000 files): ~20 minutes
Spectra itself is designed with security in mind:
- No Network Calls: Scans are performed locally
- Minimal Permissions: Only reads files, never modifies
- Secure Defaults: Conservative detection to avoid false negatives
- Audit Trail: Comprehensive logging of all activities
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Security: Security Policy
This project is licensed under the MIT License - see the LICENSE file for details.
- OWASP for security guidelines
- The Go community for excellent tooling
- All contributors who help make Spectra better