opena2a protect

Single command to fix all auto-fixable findings. Migrate credentials, fix .gitignore, exclude AI configs from git, sign config files, and show before/after security score.

Usage

opena2a protect [options]

Description

After opena2a init diagnoses your project, run opena2a protect to fix everything fixable in one step: migrate hardcoded credentials to vault, fix .gitignore to exclude .env files, add AI config files (CLAUDE.md, .cursorrules) to .git/info/exclude, sign config files for tamper detection, and display a before/after security score.

Options

FlagDescription
--dir <path>Target directory.
--dry-runPreview changes without modifying files.
--report <path>Write interactive HTML report.
--skip-verifySkip verification re-scan after migration.
--skip-livenessSkip drift liveness verification (offline/CI).
--skip-signSkip config signing phase.
--skip-gitSkip git hygiene fixes (.gitignore, .git/info/exclude).
--format <text|json>Output format.
--ciCI mode.
--verboseVerbose output.

Detected Credential Patterns

IDPatternSeverity
CRED-001Anthropic API Key (sk-ant-api*)Critical
CRED-002OpenAI API Key (sk-*, sk-proj-*)Critical
CRED-003GitHub Token (ghp_*, ghs_*)High
CRED-004Generic API Key in assignmentMedium
DRIFT-001Google API Key with Gemini drift (AIza*)High
DRIFT-002AWS Access Key with Bedrock drift (AKIA*)High

Language-Aware Replacements

Credentials are replaced with the appropriate environment variable syntax for each language:

LanguageReplacement Format
JavaScript / TypeScriptprocess.env.VAR_NAME
Pythonos.environ.get('VAR_NAME')
Goos.Getenv("VAR_NAME")
RubyENV['VAR_NAME']
Java / KotlinSystem.getenv("VAR_NAME")
Ruststd::env::var("VAR_NAME").unwrap_or_default()
YAML / TOML / JSON${VAR_NAME}
Shell$VAR_NAME

What Protect Fixes

  1. Credentials -- Scan, vault, replace with env var references, register broker policies
  2. Drift liveness -- Verify if scope drift findings are active (DRIFT-001, DRIFT-002)
  3. .env.example -- Add migrated variable names
  4. AI tool configs -- Update CLAUDE.md with secretless instructions
  5. .gitignore -- Create or update to exclude .env files
  6. AI config exclusion -- Add CLAUDE.md, .cursorrules, etc. to .git/info/exclude
  7. Config signing -- Sign config files for tamper detection
  8. Verification -- Re-scan and display before/after security score

Examples

# Scan and migrate credentials
opena2a protect
# Preview changes without modifying files
opena2a protect --dry-run
# Generate interactive HTML report
opena2a protect --report security-report.html
# CI pipeline usage
opena2a protect --dry-run --ci --format json

Interactive HTML Report

The --report flag generates a self-contained HTML file with an interactive dashboard, severity filtering, text search, audience toggle (Executive / Engineering views), and SVG donut chart. No external dependencies -- open it directly in any browser.

Sample Report PreviewView Full Report
OpenA2A|Security Report
6
Total Findings
2
Critical
2
High
1
Medium
1
Low
CRITICALAnthropic API Key ExposedCRED-001
CRITICALOpenAI API Key ExposedCRED-002
HIGHGoogle API Key with Gemini Scope DriftDRIFT-001
Score: 42/100 -- click "View Full Report" for the interactive version

Related Commands