An AI-powered, serverless security and quality analysis platform for GitHub Pull Requests
DevSecOps Sentinel is a production-ready serverless application that automatically analyzes GitHub pull requests for security vulnerabilities, code quality issues, and best practice violations. Built for the AWS Lambda Hackathon, it demonstrates the power of serverless architecture in DevSecOps workflows.
- π Multi-Layer Secret Detection: Advanced 5-layer detection system using ML, pattern matching, entropy analysis, and semantic context
- π‘οΈ Real-Time Vulnerability Scanning: Analyzes Python and Node.js dependencies against the OSV database
- π€ AI-Powered Code Review: Leverages Amazon Bedrock with Claude Sonnet 4 for intelligent code analysis
- β±οΈ Instant Progress Feedback: Shows analysis progress immediately when PRs are opened
- β‘ Serverless Architecture: Scales automatically, costs nothing when idle
- π Comprehensive Reporting: Posts detailed, actionable comments directly on PRs
- π Enterprise Security: Webhook validation, Secrets Manager integration, least-privilege IAM
- Sub-minute Analysis: Complete PR analysis in < 60 seconds
- High Detection Rates: Detects 13+ types of secrets, 200+ vulnerabilities
- Smart Classification: Automatically categorizes findings by type and severity
- Zero Idle Cost: Pay only for what you use with serverless architecture
graph TD
subgraph GitHub
A[Pull Request Event]
end
subgraph AWS
A -- Webhook --> B[API Gateway]
B --> C[WebhookHandler Lambda]
C -- Posts Progress Comment --> I
C -- Validates & Triggers --> D[Step Functions]
subgraph D[Parallel Analysis]
E[Secret Scanner]
F[Vulnerability Scanner]
G[AI Code Reviewer]
end
E --> H[Aggregator Lambda]
F --> H
G --> H
H -- Updates Comment --> I[GitHub PR Comment]
H --> J[DynamoDB Audit Log]
end
style D fill:#f9f,stroke:#333,stroke-width:2px
- Compute: AWS Lambda (Python 3.11)
- Orchestration: AWS Step Functions
- API: Amazon API Gateway
- AI/ML: Amazon Bedrock (Claude Sonnet 4)
- Storage: DynamoDB, AWS Secrets Manager
- Security Tools: TruffleHog, OSV API, Custom Detection Algorithms
- IaC: AWS SAM (Serverless Application Model)
- AWS Account with appropriate permissions
- AWS CLI configured
- AWS SAM CLI installed
- Python 3.11+
- GitHub account with a repository for testing
- GitHub Personal Access Token (PAT) with repo permissions
git clone https://github.com/belumume/devsecops-sentinel.git
cd devsecops-sentinel
Create two secrets in AWS Secrets Manager:
-
GitHub Webhook Secret (e.g.,
DevSecOpsSentinel/WebhookSecret
):your-webhook-secret-string
-
GitHub Token (e.g.,
DevSecOpsSentinel/GitHubToken
):{ "GITHUB_TOKEN": "ghp_your_github_personal_access_token" }
# Build the SAM application
sam build
# Deploy (first time - will prompt for parameters)
sam deploy --guided
# Subsequent deployments
sam deploy
During the guided deployment, you'll be asked for:
- Stack Name:
devsecops-sentinel
- AWS Region: Your preferred region
- GitHubWebhookSecretName: Name of your webhook secret in Secrets Manager
- Copy the API Gateway URL from the deployment outputs
- In your GitHub repository, go to Settings β Webhooks
- Add a new webhook:
- Payload URL: The API Gateway URL from the outputs
- Content type:
application/json
- Secret: Your webhook secret (same as stored in Secrets Manager)
- Events: Select "Pull requests"
Create a pull request in your configured repository and watch DevSecOps Sentinel automatically analyze your code!
When a PR is created/updated, GitHub sends a webhook to our API Gateway endpoint. The WebhookHandler immediately posts a progress comment to let users know analysis has started.
The WebhookHandler Lambda validates the webhook signature using HMAC-SHA256 to ensure authenticity.
Step Functions initiates parallel execution of three analysis modules:
- Secret Scanner: Uses 5-layer detection approach for comprehensive secret detection
- Vulnerability Scanner: Analyzes dependencies against the OSV database with smart version handling
- AI Reviewer: Uses Claude Sonnet 4 to identify bugs, security issues, and suggest improvements
The Aggregator Lambda:
- Consolidates findings from all scanners
- Formats a comprehensive Markdown report
- Updates the progress comment with final results
- Logs the analysis summary to DynamoDB
When DevSecOps Sentinel analyzes a PR, it posts a comment that updates from progress to results:
Initial Progress Comment:
## π DevSecOps Sentinel Analysis In Progress...
β³ **Status**: Analyzing your pull request
π **Started**: Just now
β±οΈ **Estimated time**: ~30-60 seconds
Please wait while we scan for:
- π Hardcoded secrets
- π‘οΈ Vulnerable dependencies
- π‘ Code quality issues
_This comment will update automatically when analysis completes._
Final Analysis Report:
## π DevSecOps Sentinel Analysis Report
### π Summary
| Scanner | Status | Findings |
|:---|:---:|:---|
| π΄ Secret Scanner | **Action Required** | 13 secrets found |
| π‘ Vulnerability Scanner | **Review Needed** | 206 vulnerabilities in 20 packages |
| π‘ AI Code Review | **Improvements Available** | 18 suggestions |
### π΄ Critical: Hardcoded Secrets Detected
**Immediate action required:** Remove these secrets and rotate them.
1. **API Key** found in `config/database.py` at line `19`
STRIPE_API_KEY = "sk_test_51KqUi..."
2. **Password** found in `config/database.py` at line `10`
password='SuperSecret123!'
### π‘ Dependency Vulnerabilities Detected
**Action needed:** Update the following 20 packages to their secure versions.
1. π΄ **Django** `2.0.1` β `check PyPI for latest`
- GHSA-h2g4-...: SQL Injection vulnerability
- 47 vulnerabilities found
2. π΄ **requests** `2.9.0` β `check PyPI for latest`
- PYSEC-2023-74: Security bypass vulnerability
- 5 vulnerabilities found
[... additional details ...]
Configure these in your SAM template or Lambda environment:
STATE_MACHINE_ARN
: ARN of the Step Functions state machineGITHUB_WEBHOOK_SECRET_NAME
: Name of webhook secret in Secrets ManagerGITHUB_TOKEN_SECRET_NAME
: Name of GitHub token secret in Secrets ManagerSCANS_TABLE_NAME
: DynamoDB table name for audit logs
The solution follows least-privilege principles. Each Lambda has only the permissions it needs:
- WebhookHandler: Can start Step Functions executions, read secrets, and post to GitHub
- Scanners: Read-only access to analyze code
- AI Reviewer: Can invoke Bedrock models
- Aggregator: Can write to DynamoDB and read GitHub token
# Test a Lambda function locally
sam local invoke SecretScannerFunction -e events/test-event.json
# Start local API Gateway
sam local start-api
# Install test dependencies
pip install -r tests/requirements.txt
# Run unit tests
pytest tests/unit/
# Run integration tests
pytest tests/integration/
A test repository with intentionally vulnerable code is available at: https://github.com/belumume/sentinel-testbed
- Create a new Lambda function in
src/lambdas/your_scanner/
- Implement the standardized response format:
{ "statusCode": 200, "scanner_type": "your_scanner", "findings": [...], "repo_details": {...} }
- Add the function to
template.yaml
- Update the Step Functions state machine to include your scanner
Modify the prompt construction in src/lambdas/ai_reviewer/app.py
to focus on specific coding standards or security policies for your organization.
- Concurrent Execution: Step Functions Map state enables parallel processing
- Auto-scaling: Lambda automatically scales to handle multiple PRs simultaneously
- Cost-effective: Pay only for actual usage, near-zero cost when idle
- Production Metrics: Processes PRs in under 60 seconds with comprehensive analysis
- Webhook Validation: All incoming webhooks are cryptographically verified
- Secrets Management: All credentials stored in AWS Secrets Manager
- Least Privilege: IAM roles follow principle of least privilege
- No Code Storage: Code is analyzed in-memory and never persisted
- Lambda Layers: Security tools packaged in Lambda layers for consistent execution
We welcome contributions! Please see our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
Built for the AWS Lambda Serverless Hackathon 2025. Special thanks to:
- AWS Lambda team for the amazing serverless platform
- Amazon Bedrock team for accessible AI capabilities
- The open-source community for inspiration and tools
Built with β€οΈ using AWS Lambda | Documentation | Architecture | API Reference