|
| 1 | +# Architecture Overview |
| 2 | + |
| 3 | +This document provides a quick reference for understanding the WrongSecrets project structure, testing patterns, build process, and key configuration files. |
| 4 | + |
| 5 | +## Project Structure |
| 6 | + |
| 7 | +### Core Package Organization |
| 8 | + |
| 9 | +``` |
| 10 | +src/main/java/org/owasp/wrongsecrets/ |
| 11 | +├── challenges/ # Challenge implementations and controllers |
| 12 | +│ ├── cloud/ # Cloud provider specific challenges (AWS, GCP, Azure) |
| 13 | +│ ├── docker/ # Docker-based challenges |
| 14 | +│ ├── kubernetes/ # Kubernetes and Vault challenges |
| 15 | +│ ├── Challenge.java # Core challenge interface |
| 16 | +│ ├── FixedAnswerChallenge.java # Abstract class for static answer challenges |
| 17 | +│ └── ChallengesController.java # REST API endpoints for challenges |
| 18 | +├── oauth/ # OAuth authentication components |
| 19 | +├── asciidoc/ # Documentation generation utilities |
| 20 | +├── canaries/ # Security canary implementations |
| 21 | +├── definitions/ # Challenge definitions and metadata |
| 22 | +└── [Core Application Files] # Main application, security config, etc. |
| 23 | +``` |
| 24 | + |
| 25 | +### Key Responsibilities by Package |
| 26 | + |
| 27 | +- **`challenges/`** - All challenge logic, grouped by deployment technology |
| 28 | +- **`oauth/`** - GitHub OAuth integration for user authentication |
| 29 | +- **`asciidoc/`** - AsciiDoc documentation generation and processing |
| 30 | +- **`canaries/`** - Security monitoring and detection mechanisms |
| 31 | +- **`definitions/`** - Challenge metadata, descriptions, and configuration |
| 32 | + |
| 33 | +## Testing Patterns |
| 34 | + |
| 35 | +### Test Organization |
| 36 | + |
| 37 | +``` |
| 38 | +src/test/java/org/owasp/wrongsecrets/ |
| 39 | +├── challenges/ # Challenge-specific unit tests |
| 40 | +│ ├── cloud/ # Cloud challenge tests |
| 41 | +│ ├── docker/ # Docker challenge tests |
| 42 | +│ └── kubernetes/ # Kubernetes challenge tests |
| 43 | +├── ChallengesControllerTest.java # API endpoint tests |
| 44 | +├── SecurityConfigTest.java # Security configuration tests |
| 45 | +└── [Other Component Tests] # Individual component unit tests |
| 46 | +``` |
| 47 | + |
| 48 | +### Test Types |
| 49 | + |
| 50 | +1. **Unit Tests** - Individual challenge logic testing (74+ test files) |
| 51 | +2. **Integration Tests** - Controller and API endpoint testing |
| 52 | +3. **E2E Tests** - Cypress tests in `src/test/e2e/cypress/` |
| 53 | +4. **Container Tests** - Docker and Kubernetes deployment validation |
| 54 | + |
| 55 | +### Test Naming Convention |
| 56 | + |
| 57 | +- Challenge tests: `Challenge[Number]Test.java` (e.g., `Challenge44Test.java`) |
| 58 | +- Controller tests: `[Controller]Test.java` (e.g., `ChallengesControllerTest.java`) |
| 59 | +- Component tests: `[Component]Test.java` |
| 60 | + |
| 61 | +## Build Process Overview |
| 62 | + |
| 63 | +### Maven → Docker Workflow |
| 64 | + |
| 65 | +1. **Maven Build** (`pom.xml`) |
| 66 | + - Spring Boot 3.x application |
| 67 | + - Dependencies managed through Spring Boot parent POM |
| 68 | + - Plugins: AsciiDoctor, Checkstyle, PMD, SpotBugs |
| 69 | + |
| 70 | +2. **Docker Images** |
| 71 | + - `Dockerfile` - Main application container |
| 72 | + - `Dockerfile.web` - Web-only variant (no vault dependencies) |
| 73 | + - `Dockerfile_webdesktop` - Desktop application variant |
| 74 | + - `Dockerfile_webdesktopk8s` - Kubernetes desktop variant |
| 75 | + |
| 76 | +3. **Build Commands** |
| 77 | + ```bash |
| 78 | + ./mvnw clean compile # Compile sources |
| 79 | + ./mvnw test # Run unit tests |
| 80 | + ./mvnw package # Create JAR |
| 81 | + docker build -t wrongsecrets . # Build container |
| 82 | + ``` |
| 83 | + |
| 84 | +### Version Management |
| 85 | + |
| 86 | +- Version defined in `pom.xml` and synchronized across Dockerfiles |
| 87 | +- Automated version extraction in GitHub Actions |
| 88 | +- Snapshot versions for development, release versions for production |
| 89 | + |
| 90 | +## Key Configuration Files |
| 91 | + |
| 92 | +### Application Configuration |
| 93 | + |
| 94 | +| File | Purpose | |
| 95 | +|------|---------| |
| 96 | +| `pom.xml` | Maven build configuration, dependencies, plugins | |
| 97 | +| `src/main/resources/application.properties` | Spring Boot application configuration | |
| 98 | +| `config/fbctf.yml` | Facebook CTF integration configuration | |
| 99 | + |
| 100 | +### Code Quality & Standards |
| 101 | + |
| 102 | +| File | Purpose | |
| 103 | +|------|---------| |
| 104 | +| `config/checkstyle/` | Java code style rules and enforcement | |
| 105 | +| `config/zap/` | OWASP ZAP security scanning configuration | |
| 106 | +| `.pre-commit-config.yaml` | Pre-commit hooks for code quality | |
| 107 | +| `eslint.config.mjs` | JavaScript/TypeScript linting rules | |
| 108 | + |
| 109 | +### CI/CD Configuration |
| 110 | + |
| 111 | +| File | Purpose | |
| 112 | +|------|---------| |
| 113 | +| `.github/workflows/` | GitHub Actions workflow definitions | |
| 114 | +| `renovate.json` | Automated dependency updates | |
| 115 | +| `commitlint.config.js` | Commit message format enforcement | |
| 116 | + |
| 117 | +### Deployment Configuration |
| 118 | + |
| 119 | +| File | Purpose | |
| 120 | +|------|---------| |
| 121 | +| `heroku.yml` | Heroku deployment configuration | |
| 122 | +| `fly.toml` | Fly.io deployment configuration | |
| 123 | +| `render.yaml` | Render.com deployment configuration | |
| 124 | +| `app.json` | Heroku app configuration | |
| 125 | +| `k8s/` | Kubernetes deployment manifests | |
| 126 | + |
| 127 | +### Platform-Specific |
| 128 | + |
| 129 | +| Directory | Purpose | |
| 130 | +|-----------|---------| |
| 131 | +| `aws/` | AWS-specific deployment files and documentation | |
| 132 | +| `gcp/` | Google Cloud Platform deployment configuration | |
| 133 | +| `azure/` | Microsoft Azure deployment setup | |
| 134 | +| `okteto/` | Okteto Kubernetes platform configuration | |
| 135 | + |
| 136 | +## Development Environment Setup |
| 137 | + |
| 138 | +### Prerequisites |
| 139 | + |
| 140 | +- Java 21+ |
| 141 | +- Maven 3.8+ |
| 142 | +- Docker |
| 143 | +- Node.js (for frontend dependencies) |
| 144 | + |
| 145 | +### Quick Setup |
| 146 | + |
| 147 | +```bash |
| 148 | +# Clone and build |
| 149 | +git clone <repository> |
| 150 | +cd wrongsecrets |
| 151 | +./mvnw clean compile |
| 152 | + |
| 153 | +# Run locally |
| 154 | +./mvnw spring-boot:run |
| 155 | + |
| 156 | +# Run tests |
| 157 | +./mvnw test |
| 158 | +``` |
| 159 | + |
| 160 | +For detailed setup instructions, see [CONTRIBUTING.md](../CONTRIBUTING.md). |
0 commit comments