This document outlines the security measures implemented to ensure safe sharing on GitHub.
The following files/directories contain sensitive data and are excluded from version control:
- β
.env - β
.env.local - β
.env.development.local - β
.env.test.local - β
.env.production.local
- β
cdk.out/- Contains CloudFormation templates with AWS account IDs - β
cdk-outputs.json- Contains sensitive resource IDs:- User Pool IDs
- Identity Pool IDs
- API Gateway URLs
- S3 Bucket Names
- AWS Account Numbers
- β
node_modules/ - β
dist/ - β
.next/ - β
Lambda build artifacts (
lambda/*/dist/,lambda/*/node_modules/)
All source code uses environment variables instead of hardcoded values:
Frontend (frontend/src/config/aws-config.ts):
userPoolId: process.env.NEXT_PUBLIC_USER_POOL_ID || ''Lambda Functions:
const DATA_TABLE_NAME = process.env.DATA_TABLE_NAME!
const DATA_BUCKET_NAME = process.env.DATA_BUCKET_NAME!- β
CDK stack definitions (
infra/lib/cortex-ai.ts) - β Lambda function source code
- β Deployment scripts
- β All TypeScript/JavaScript source files
-
Delete or ensure .gitignore excludes:
rm -rf infra/cdk.out/ rm -f infra/cdk-outputs.json rm -f frontend/.env.local rm -f query.js # Temporary test file -
Verify .gitignore is working:
git status # Should NOT show any files from cdk.out/ or .env files
- AWS Account ID:
467793901514 - User Pool ID:
us-east-1_Hl3Erc3Ls - Identity Pool ID:
us-east-1:32f28230-b710-4360-bed8-f9888a04de81 - API Gateway URL:
https://uvcyk2ruih.execute-api.us-east-1.amazonaws.com/dev/ - User Pool Client ID:
4c1e85lccai5is4uo7umu4n90c
Status: β All protected by .gitignore
Users cloning your repository will need to:
-
Deploy Infrastructure:
cd infra npm install npm run deploy -
Generate Frontend Config:
npm run postdeploy
This creates
frontend/.env.localwith the correct values. -
Start Frontend:
cd ../frontend npm install npm run dev
Before pushing to GitHub:
- Run
git statusto verify no.env*files are staged - Verify
cdk-outputs.jsonis not staged - Verify
cdk.out/is not staged - Check that
.gitignoreincludes all sensitive patterns - Ensure
frontend/.env.localexists locally but is gitignored - Review diff for any accidentally hardcoded credentials
Run these commands before committing:
# Check for accidentally staged sensitive files
git status | grep -E "(\.env|cdk-outputs|cdk\.out)"
# Search for potential hardcoded secrets in staged files
git diff --staged | grep -iE "(password|secret|api_key|token)"
# Verify .gitignore is working
git check-ignore frontend/.env.local # Should return the path
git check-ignore infra/cdk-outputs.json # Should return the path- Add GitHub Secret Scanning: Enable secret scanning in repository settings
- Branch Protection: Require PR reviews before merging to main
- Pre-commit Hooks: Consider using tools like
git-secretsordetect-secrets - Documentation: Keep this SECURITY.md file updated
If sensitive data is accidentally committed:
-
Immediately rotate credentials:
- Delete and recreate Cognito User Pools
- Rotate API keys
- Update S3 bucket policies
-
Remove from Git history:
git filter-branch --force --index-filter \ "git rm --cached --ignore-unmatch path/to/sensitive/file" \ --prune-empty --tag-name-filter cat -- --all -
Force push (only if repository is private or just created):
git push origin --force --all
For security concerns, please open a GitHub issue or contact the maintainer.
Last Updated: $(date) Reviewed By: Security Audit Script Status: β Ready for GitHub