|
| 1 | +# GitHub Copilot Instructions for Unguard |
| 2 | + |
| 3 | +Welcome to Unguard! This guide provides essential information for GitHub Copilot to help you contribute effectively to this project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Unguard is an **intentionally insecure** cloud-native microservices demo application built with multiple languages and technologies. The application demonstrates various security vulnerabilities for educational and testing purposes. |
| 8 | + |
| 9 | +**Key Technologies:** |
| 10 | +- Kubernetes-based microservices architecture |
| 11 | +- Languages: Java (Spring), Node.js (Express), .NET, PHP, Python (Flask), Go, Next.js |
| 12 | +- Databases: MariaDB, Redis, H2 |
| 13 | +- Tools: Skaffold, Helm, Docker, Jaeger for tracing |
| 14 | + |
| 15 | +## Critical: Commit Message Format |
| 16 | + |
| 17 | +**ALWAYS follow the commitlint-config-gitmoji format for ALL commits:** |
| 18 | + |
| 19 | +``` |
| 20 | +:gitmoji: type(scope?): subject |
| 21 | +body? |
| 22 | +footer? |
| 23 | +``` |
| 24 | + |
| 25 | +### Required Elements |
| 26 | + |
| 27 | +1. **:gitmoji:** (REQUIRED) - Must be a valid gitmoji code |
| 28 | + - Find the correct emoji: `npx gitmoji-cli --search <keyword>` |
| 29 | + - Examples: `:bug:` for bug fixes, `:sparkles:` for new features, `:memo:` for documentation |
| 30 | + |
| 31 | +2. **type** (REQUIRED) - Must be one of: |
| 32 | + - `feat` - Introducing new features |
| 33 | + - `fix` - Fixing a bug |
| 34 | + - `refactor` - Refactoring code (not introducing features or fixes) |
| 35 | + - `docs` - Add documents |
| 36 | + - `test` - Adding unit tests or e2e tests |
| 37 | + - `perf` - Improving performance |
| 38 | + - `revert` - Reverting changes or commits |
| 39 | + - `style` - Updating the UI and style files |
| 40 | + - `build` - Build artifacts |
| 41 | + - `ci` - Working about CI build system |
| 42 | + - `wip` - Work in progress |
| 43 | + - `chore` - Work with configuration or other stuff |
| 44 | + |
| 45 | +3. **scope** (OPTIONAL) - Examples: |
| 46 | + - Microservice names: `like-service`, `membership-service`, `user-auth-service`, `proxy-service`, etc. |
| 47 | + - General scopes: `docs`, `k8s`, `helm`, `skaffold`, etc. |
| 48 | + |
| 49 | +4. **subject** (REQUIRED) - Must follow proper casing: |
| 50 | + - `Sentence case` for normal sentences |
| 51 | + - `Start Case` for names |
| 52 | + - `PascalCase` for file/class names with that casing style |
| 53 | + - Acronyms are allowed: `HTTP`, `SSL`, `DSL`, `JWT` |
| 54 | + |
| 55 | +### Commit Message Examples |
| 56 | + |
| 57 | +✅ **Good Examples:** |
| 58 | +``` |
| 59 | +:sparkles: feat(like-service): Add new endpoint for like count retrieval |
| 60 | +:bug: fix(user-auth-service): Fix JWT token validation error |
| 61 | +:memo: docs: Update installation instructions in README |
| 62 | +:recycle: refactor(profile-service): Simplify SQL query builder logic |
| 63 | +:wrench: chore: Update commitlint configuration |
| 64 | +``` |
| 65 | + |
| 66 | +❌ **Bad Examples:** |
| 67 | +``` |
| 68 | +Added new feature # Missing gitmoji and type |
| 69 | +:sparkles: add feature # Missing type, wrong subject case |
| 70 | +fix: bug fix # Missing gitmoji |
| 71 | +:bug: fix: fixed the bug # Subject not in proper case |
| 72 | +``` |
| 73 | + |
| 74 | +### Pre-commit Hook |
| 75 | + |
| 76 | +The repository has a pre-commit hook that validates commit messages. Install dependencies to enable it: |
| 77 | +```bash |
| 78 | +npm install |
| 79 | +``` |
| 80 | + |
| 81 | +To bypass validation (not recommended): `git commit -m "message" -n` |
| 82 | + |
| 83 | +## Important Documentation |
| 84 | + |
| 85 | +**Before making changes, review these documents:** |
| 86 | + |
| 87 | +1. **[CONTRIBUTING.md](../CONTRIBUTING.md)** - Full contribution guidelines including: |
| 88 | + - Commit message format details |
| 89 | + - Contributor License Agreement requirements |
| 90 | + - Code review process |
| 91 | + |
| 92 | +2. **[docs/DEV-GUIDE.md](../docs/DEV-GUIDE.md)** - Local development setup: |
| 93 | + - Prerequisites (Docker, Kubectl, Helm, Skaffold, Minikube/Kind) |
| 94 | + - Local Kubernetes cluster setup |
| 95 | + - Building and deploying with Skaffold |
| 96 | + - Troubleshooting common issues |
| 97 | + |
| 98 | +3. **[docs/FAQ.md](../docs/FAQ.md)** - Common issues and solutions: |
| 99 | + - Kustomize errors |
| 100 | + - ImagePullBackOff errors |
| 101 | + - Exposing Unguard on Minikube |
| 102 | + |
| 103 | +4. **[README.md](../README.md)** - Project overview and quickstart |
| 104 | + |
| 105 | +## Development Workflow |
| 106 | + |
| 107 | +### Local Development |
| 108 | + |
| 109 | +1. **Setup:** |
| 110 | + ```bash |
| 111 | + # Start minikube cluster |
| 112 | + minikube start --addons=ingress --profile unguard |
| 113 | + |
| 114 | + # Verify connection |
| 115 | + kubectl get nodes |
| 116 | + ``` |
| 117 | + |
| 118 | +2. **Build and Deploy:** |
| 119 | + ```bash |
| 120 | + # First build takes ~20 minutes |
| 121 | + skaffold run |
| 122 | + |
| 123 | + # For auto-rebuild on changes |
| 124 | + skaffold dev |
| 125 | + ``` |
| 126 | + |
| 127 | +3. **Access Application:** |
| 128 | + - Add to `/etc/hosts`: `<minikube-ip> unguard.kube` |
| 129 | + - Access at: http://unguard.kube/ |
| 130 | + |
| 131 | +4. **Cleanup:** |
| 132 | + ```bash |
| 133 | + skaffold delete |
| 134 | + ``` |
| 135 | + |
| 136 | +### Testing Changes |
| 137 | + |
| 138 | +- Each microservice has its own README with specific testing instructions |
| 139 | +- Run service-specific tests before submitting PRs |
| 140 | +- Ensure changes don't break existing functionality (unless intentionally fixing a vulnerability) |
| 141 | + |
| 142 | +## Architecture Notes |
| 143 | + |
| 144 | +**Microservices Structure:** |
| 145 | +- `src/` contains all microservices, each in their own directory |
| 146 | +- Each service has its own Dockerfile and dependencies |
| 147 | +- Services communicate via REST APIs |
| 148 | +- Most services use Kubernetes DNS for service discovery |
| 149 | + |
| 150 | +**Key Services:** |
| 151 | +- `frontend/` - Next.js application |
| 152 | +- `user-auth-service/` - Node.js Express (JWT authentication) |
| 153 | +- `microblog-service/` - Java Spring (main blog functionality) |
| 154 | +- `proxy-service/` - Java Spring (SSRF vulnerable) |
| 155 | +- `profile-service/` - Java Spring (SQL injection vulnerable) |
| 156 | +- `membership-service/` - .NET 7 (SQL injection vulnerable) |
| 157 | +- `like-service/` - PHP (SQL injection vulnerable) |
| 158 | +- `status-service/` - Go (deployment health) |
| 159 | +- `payment-service/` - Python Flask (payment processing) |
| 160 | +- `ad-service/` - .NET 5 (ad serving) |
| 161 | + |
| 162 | +## Code Style Guidelines |
| 163 | + |
| 164 | +**General:** |
| 165 | +- Follow existing patterns in each service's codebase |
| 166 | +- Match the coding style of the language/framework being used |
| 167 | +- Use meaningful variable and function names |
| 168 | +- Add comments only when necessary to explain complex logic |
| 169 | + |
| 170 | +**Language-Specific:** |
| 171 | +- **Java**: Follow Spring Boot conventions |
| 172 | +- **Node.js**: Use modern ES6+ syntax |
| 173 | +- **Python**: Follow PEP 8 |
| 174 | +- **.NET**: Follow Microsoft C# conventions |
| 175 | +- **Go**: Follow standard Go formatting (use `gofmt`) |
| 176 | +- **PHP**: Follow PSR standards where applicable |
| 177 | + |
| 178 | +## Security Considerations |
| 179 | + |
| 180 | +**Important:** This application is **intentionally vulnerable** for demonstration purposes. |
| 181 | + |
| 182 | +When contributing: |
| 183 | +- Understand that some vulnerabilities are intentional |
| 184 | +- Only fix security issues if explicitly requested |
| 185 | +- Document any security-related changes clearly |
| 186 | +- Don't remove intentional vulnerabilities without discussion |
| 187 | + |
| 188 | +## Pull Request Process |
| 189 | + |
| 190 | +1. Ensure all commits follow the commitlint format |
| 191 | +2. Update relevant documentation if needed |
| 192 | +3. Test changes locally using `skaffold dev` |
| 193 | +4. Reference related issues in PR description |
| 194 | +5. All PRs require review before merging |
| 195 | +6. Sign the Contributor License Agreement (CLA) if first-time contributor |
| 196 | + |
| 197 | +## Quick Reference Commands |
| 198 | + |
| 199 | +```bash |
| 200 | +# Install commit hook dependencies |
| 201 | +npm install |
| 202 | + |
| 203 | +# Search for gitmoji |
| 204 | +npx gitmoji-cli --search <keyword> |
| 205 | + |
| 206 | +# Build and run locally |
| 207 | +skaffold run |
| 208 | + |
| 209 | +# Development mode with auto-rebuild |
| 210 | +skaffold dev |
| 211 | + |
| 212 | +# Delete deployment |
| 213 | +skaffold delete |
| 214 | + |
| 215 | +# Check Kubernetes resources |
| 216 | +kubectl get pods -n unguard |
| 217 | +kubectl logs <pod-name> -n unguard |
| 218 | +``` |
| 219 | + |
| 220 | +## Getting Help |
| 221 | + |
| 222 | +- Check [docs/FAQ.md](../docs/FAQ.md) for common issues |
| 223 | +- Review service-specific READMEs in `src/<service-name>/` |
| 224 | +- Check [docs/DEV-GUIDE.md](../docs/DEV-GUIDE.md) for setup help |
| 225 | +- Refer to [CONTRIBUTING.md](../CONTRIBUTING.md) for contribution guidelines |
| 226 | + |
| 227 | +## Remember |
| 228 | + |
| 229 | +✅ **Always** use proper gitmoji + type + subject format in commits |
| 230 | +✅ **Always** check existing documentation before making changes |
| 231 | +✅ **Always** test changes locally before submitting PR |
| 232 | +✅ **Always** follow language-specific conventions |
| 233 | +✅ **Always** update documentation when changing functionality |
| 234 | + |
| 235 | +❌ **Never** commit without proper gitmoji format |
| 236 | +❌ **Never** remove intentional security vulnerabilities without discussion |
| 237 | +❌ **Never** skip the CLA requirement |
| 238 | +❌ **Never** push breaking changes without proper testing |
0 commit comments