AI-Powered Multi-Agent Security System for Supply Chain Code Security
Aegis Chain is a production-ready multi-agent security system deployed on Google Cloud Run that detects semantic security flaws introduced by new code dependencies. It runs GPU-backed Code LLM scans, correlates results with OSV/NVD vulnerability databases, and posts comprehensive triage reports to GitHub.
Aegis Chain provides automated security scanning for pull requests and code archives by:
- Scanning code archives for dependencies and semantic security patterns
- Correlating dependencies with known vulnerabilities (OSV/NVD)
- Triaging findings with risk scoring and automated GitHub integration
- Semantic Security Analysis - Detects dangerous code patterns (unsafe yaml.load, subprocess shell=True, eval(), etc.)
- SBOM Generation - Automatic Software Bill of Materials from package.json and requirements.txt
- Vulnerability Correlation - Real-time correlation with OSV.dev API
- Risk Scoring - Configurable risk assessment with weighted scoring
- GitHub Integration - Automated PR comments and check run status
- Dashboard - Web dashboard for viewing scan results and findings
Aegis Chain consists of four main components:
graph TB
subgraph "Input"
PR[GitHub Pull Request]
Archive[Code Archive URL]
end
subgraph "Scanner Agent<br/>(Cloud Run Job - GPU)"
Fetch[Fetch & Extract Archive]
SBOM[Generate SBOM]
Analyze[Semantic Analysis]
end
subgraph "Vulnerability Agent<br/>(Cloud Run Service)"
Webhook[GitHub Webhook]
Correlate[OSV Correlation]
end
subgraph "Triage Agent<br/>(Cloud Run Service)"
Aggregate[Aggregate Findings]
Score[Risk Scoring]
Comment[PR Comment]
Check[Check Run]
end
subgraph "Dashboard<br/>(Cloud Run Service - Next.js)"
UI[Dashboard UI]
end
subgraph "Storage & Services"
FS[(Firestore)]
PS[Pub/Sub]
OSV[OSV.dev API]
end
PR -->|Webhook| Webhook
Archive --> Fetch
Fetch --> SBOM
SBOM --> Analyze
Analyze -->|Persist| FS
Analyze -->|Publish| PS
PS -->|Trigger| Correlate
Webhook -->|Fetch SBOM| FS
Webhook --> Correlate
Correlate -->|Query| OSV
Correlate -->|Persist| FS
FS -->|Read| Aggregate
Aggregate --> Score
Score --> Comment
Score --> Check
Comment -->|Post| PR
Check -->|Update| PR
FS -->|Read| UI
- Downloads and extracts code archives
- Generates SBOM from package manifests
- Performs semantic security analysis
- Persists results to Firestore
- Publishes scan summaries to Pub/Sub
- Receives GitHub webhooks for PR events
- Correlates SBOM components with OSV.dev
- Handles rate limiting with exponential backoff
- Persists enriched vulnerability data
- Aggregates scan and correlation data
- Calculates risk scores
- Posts formatted PR comments
- Creates GitHub check runs
- Reads from Firestore
- Displays recent scans and findings
- Shows PR details with CVEs and SBOM components
- Scan Trigger: Code archive URL is provided (via PR or manual trigger)
- SBOM Generation: Scanner extracts dependencies from package.json/requirements.txt
- Security Analysis: Semantic patterns are detected (unsafe yaml.load, eval(), etc.)
- Persistence: Results stored in Firestore, summary published to Pub/Sub
- Correlation: Vulnerability agent queries OSV.dev for known CVEs
- Triage: Risk score calculated, PR comment and check run posted
- Dashboard: Users view results via web interface
- Google Cloud Platform account with billing enabled
- GCP Project with the following APIs enabled:
- Cloud Run
- Cloud Firestore
- Cloud Pub/Sub
- Cloud Build (for deployment)
- Python 3.11+
- Node.js 18+ (for dashboard)
- GitHub App (for PR integration - optional)
git clone https://github.com/Manan23-dev/AegisChain.git
cd AegisChainCreate a .env file in the project root:
# GCP Configuration
GCP_PROJECT_ID=your-project-id
GCP_REGION=europe-west4
# Firestore
FIRESTORE_COLLECTION=aegis_findings
# Pub/Sub
PUBSUB_TOPIC=aegis-scan-requests
# OSV API
OSV_API_URL=https://api.osv.dev/v1/query
# GitHub Integration (Optional)
GITHUB_APP_ID=your-app-id
GITHUB_INSTALLATION_ID=your-installation-id
GITHUB_PRIVATE_KEY_BASE64=base64-encoded-private-key
GITHUB_OWNER=your-org
GITHUB_REPO=your-repo
WEBHOOK_SECRET=your-webhook-secret
# Dashboard
PORT=8080cd src/agents/scanner_agent/app
pip install -r requirements.txtcd src/agents/vulnerability_agent/app
pip install -r requirements.txtcd src/agents/triage_agent/app
pip install -r requirements.txtcd src/dashboard/app
npm installcd src/agents/scanner_agent/app
export SCAN_PAYLOAD='{"archive_url":"https://example.com/archive.zip","pr_number":"123","commit_sha":"abc123"}'
python main.pycd src/agents/vulnerability_agent/app
uvicorn main:app --host 0.0.0.0 --port 8080cd src/agents/triage_agent/app
uvicorn main:app --host 0.0.0.0 --port 8080cd src/dashboard/app
npm run dev| Variable | Description | Required | Default |
|---|---|---|---|
GCP_PROJECT_ID |
GCP Project ID | Yes | - |
GCP_REGION |
GCP Region | No | europe-west4 |
FIRESTORE_COLLECTION |
Firestore collection name | No | aegis_findings |
PUBSUB_TOPIC |
Pub/Sub topic name | No | aegis-scan-requests |
OSV_API_URL |
OSV API endpoint | No | https://api.osv.dev/v1/query |
GITHUB_APP_ID |
GitHub App ID | No | - |
GITHUB_INSTALLATION_ID |
GitHub Installation ID | No | - |
GITHUB_PRIVATE_KEY_BASE64 |
Base64-encoded private key | No | - |
GITHUB_OWNER |
GitHub repository owner | No | - |
GITHUB_REPO |
GitHub repository name | No | - |
WEBHOOK_SECRET |
GitHub webhook secret | No | - |
RISK_HIGH_THRESHOLD |
High risk score threshold | No | 8.0 |
RISK_MEDIUM_THRESHOLD |
Medium risk score threshold | No | 4.0 |
SAMPLE_MODE |
Enable sample mode for testing | No | false |
Risk scores are calculated using weighted factors:
-
CVE Severity Weights:
- CRITICAL: 3.0
- HIGH: 2.0
- MEDIUM: 1.0
- LOW: 0.5
-
Dangerous Primitives: 2.0 per finding
-
Affected Files: 0.5 per file (capped at 10)
Risk Levels:
- High: Score ≥ 8.0
- Medium: Score 4.0 - 7.9
- Low: Score < 4.0
Health check endpoint.
Response:
{
"status": "healthy"
}GitHub webhook endpoint for PR events.
Headers:
X-Hub-Signature-256: HMAC signatureX-GitHub-Event: Event type (must bepull_request)
Response:
{
"status": "accepted",
"pr_number": "123",
"commit_sha": "abc123"
}Manual correlation endpoint.
Request Body:
{
"pr_number": "123",
"commit_sha": "abc123",
"components": [
{
"name": "requests",
"version": "2.28.0",
"ecosystem": "pypi"
}
],
"persist": true
}Health check endpoint.
Triage endpoint for risk scoring and GitHub integration.
Request Body:
{
"pr_number": "123",
"commit_sha": "abc123",
"owner": "your-org",
"repo": "your-repo"
}Response:
{
"pr_number": "123",
"commit_sha": "abc123",
"risk_score": 6.5,
"risk_level": "medium",
"cve_count": 3,
"findings_count": 5,
"github_comment_posted": true,
"github_check_run_created": true
}Returns latest 50 scan records grouped by PR.
Response:
{
"findings": [
{
"pr_number": "123",
"commit_sha": "abc123",
"scan": { ... },
"correlation": { ... },
"triage": { ... }
}
]
}Returns detailed PR information.
Response:
{
"pr_number": "123",
"commit_sha": "abc123",
"scan": { ... },
"correlation": { ... },
"triage": { ... },
"sbom_components": [ ... ],
"cves": [ ... ]
}Enable sample mode for testing without actual code analysis:
export SAMPLE_MODE=trueThis returns deterministic sample findings for smoke tests.
Run unit tests (when implemented):
# Scanner Agent
cd src/agents/scanner_agent/app
pytest tests/
# Vulnerability Agent
cd src/agents/vulnerability_agent/app
pytest tests/
# Triage Agent
cd src/agents/triage_agent/app
pytest tests/- Install Google Cloud SDK
- Authenticate:
gcloud auth login - Set project:
gcloud config set project YOUR_PROJECT_ID
gcloud run jobs create scanner-agent \
--image gcr.io/YOUR_PROJECT_ID/scanner-agent:latest \
--region europe-west4 \
--set-env-vars GCP_PROJECT_ID=YOUR_PROJECT_ID \
--set-env-vars FIRESTORE_COLLECTION=aegis_findings \
--set-env-vars PUBSUB_TOPIC=aegis-scan-requests \
--memory 8Gi \
--cpu 4 \
--task-timeout 3600 \
--max-retries 1gcloud run deploy vulnerability-agent \
--image gcr.io/YOUR_PROJECT_ID/vulnerability-agent:latest \
--region europe-west4 \
--platform managed \
--allow-unauthenticated \
--set-env-vars GCP_PROJECT_ID=YOUR_PROJECT_ID \
--set-env-vars FIRESTORE_COLLECTION=aegis_findings \
--set-env-vars WEBHOOK_SECRET=YOUR_SECRET \
--min-instances 0 \
--max-instances 10gcloud run deploy triage-agent \
--image gcr.io/YOUR_PROJECT_ID/triage-agent:latest \
--region europe-west4 \
--platform managed \
--allow-unauthenticated \
--set-env-vars GCP_PROJECT_ID=YOUR_PROJECT_ID \
--set-env-vars FIRESTORE_COLLECTION=aegis_findings \
--set-env-vars GITHUB_APP_ID=YOUR_APP_ID \
--set-env-vars GITHUB_INSTALLATION_ID=YOUR_INSTALLATION_ID \
--set-secrets GITHUB_PRIVATE_KEY_BASE64=github-key:latest \
--min-instances 0 \
--max-instances 10gcloud run deploy aegis-dashboard \
--image gcr.io/YOUR_PROJECT_ID/aegis-dashboard:latest \
--region europe-west4 \
--platform managed \
--allow-unauthenticated \
--set-env-vars GCP_PROJECT_ID=YOUR_PROJECT_ID \
--set-env-vars FIRESTORE_COLLECTION=aegis_findings \
--min-instances 0 \
--max-instances 5# Using gcloud
gcloud run jobs execute scanner-agent \
--region europe-west4 \
--args '{"archive_url":"https://github.com/user/repo/archive/main.zip","pr_number":"123","commit_sha":"abc123"}'curl -X POST https://vulnerability-agent-xxx.run.app/correlate \
-H "Content-Type: application/json" \
-d '{
"pr_number": "123",
"commit_sha": "abc123",
"components": [
{
"name": "requests",
"version": "2.28.0",
"ecosystem": "pypi"
}
]
}'curl -X POST https://triage-agent-xxx.run.app/triage \
-H "Content-Type: application/json" \
-d '{
"pr_number": "123",
"commit_sha": "abc123"
}'- All secrets should be stored in Google Secret Manager
- GitHub webhook signatures are verified using HMAC
- Private keys are base64-encoded and stored as environment variables
- No secrets are logged or exposed in error messages
AegisChain/
├── src/
│ ├── agents/
│ │ ├── scanner_agent/
│ │ │ └── app/
│ │ │ ├── main.py # Main entry point
│ │ │ ├── analyzer.py # Semantic analysis
│ │ │ ├── sbom.py # SBOM generation
│ │ │ └── io_utils.py # Archive I/O
│ │ ├── vulnerability_agent/
│ │ │ └── app/
│ │ │ ├── main.py # FastAPI service
│ │ │ ├── osv.py # OSV API client
│ │ │ └── models.py # Data models
│ │ └── triage_agent/
│ │ └── app/
│ │ ├── main.py # FastAPI service
│ │ ├── risk.py # Risk scoring
│ │ └── github_app.py # GitHub integration
│ └── dashboard/
│ └── app/
│ ├── package.json
│ └── src/
│ └── pages/
│ ├── index.tsx
│ ├── pr/[id].tsx
│ └── api/
│ ├── findings.ts
│ └── pr/[id].ts
├── README.md
├── STATUS.md
└── FILE_CHECK_REPORT.md
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See LICENSE file for details.
For issues, questions, or contributions, please open an issue on GitHub.
- OSV.dev for vulnerability data
- Google Cloud Platform for infrastructure
- FastAPI and Next.js communities
Built for secure software supply chains