Production Deploy#72
Conversation
Syncing main to development
Feat/infra housekeeping
Feat/middleware-wiring-webhook-setup
* added user calibration endpoints and schema"
- Added user_calibration migration
- Added sqlc queries for calibration CRUD operations
- added /api/users/me/calibration endpoints: GET, POST, DELETE
- me endpoint now fetches user from clerk id using middleware, enhancing security
- removed GET methods for user (GET /{id}, GET /)
* Fixed line endings
* Fixed time formatting in handler
* Added NOT NULL constrain to updated_at, created_at in db table
switch go dev container port to correct mapping (8080)
fixed variable typo in middleware_auth.go
---------
Co-authored-by: NicolaSavino <nick.savino@arcurve.com>
Co-authored-by: NicolaSavino <nick.savino@arcurve.com>
* Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com>
* fix: added clerk webhook secret * updated CRLF line endings to LF
* fix: added clerk webhook secret * updated CRLF line endings to LF * fix
…pment # Conflicts: # scripts/ci/deploy_via_ssm.sh
* Prod fix (#67) * Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: wipe data on seed --------- Co-authored-by: Nicola Savino <77707655+NickSavino@users.noreply.github.com> Co-authored-by: NicolaSavino <nick.savino@arcurve.com>
Review Summary by QodoAdd user deletion webhook and refactor workout session history query
WalkthroughsDescription• Added user deletion webhook handler for Clerk integration • Refactored workout session history query to include aggregated sets/reps counts • Removed calibration angle fields from workout session updates • Added database reset workflow and improved deployment scripts • Fixed line endings and added database seeding truncation Diagramflowchart LR
A["Clerk Webhook Events"] -->|user.created| B["HandleCreateUserFromClerk"]
A -->|user.deleted| C["HandleDeleteUserFromClerk"]
B --> D["Store User in DB"]
C --> E["Delete User by ClerkID"]
F["GetUserWorkoutSessionHistory"] -->|Enhanced Query| G["Aggregate Sets/Reps"]
G --> H["WorkoutSessionHistoryItemDTO"]
I["CI/CD Pipeline"] -->|New Workflow| J["Reset Database Script"]
File Changes1. internal/core/service/user.service.go
|
Code Review by Qodo
1. Unprotected prod DB reset
|
| jobs: | ||
| reset-database: | ||
| if: ${{ inputs.confirm_reset == 'RESET' && github.ref == 'refs/heads/main'}} | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Configure AWS credentials with OIDC | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE_ARN }} | ||
| aws-region: ${{ secrets.AWS_REGION }} | ||
|
|
||
| - name: Run database reset | ||
| env: | ||
| AWS_REGION: ${{ secrets.AWS_REGION }} | ||
| ECR_REPO: ${{ secrets.ECR_REPO }} | ||
| EC2_INSTANCE_ID: ${{ secrets.EC2_INSTANCE_ID }} | ||
| GITHUB_SHA: ${{ github.sha }} | ||
| run: | | ||
| bash ./scripts/ci/reset_database.sh No newline at end of file |
There was a problem hiding this comment.
1. Unprotected prod db reset 🐞 Bug ⛨ Security
A new workflow_dispatch job can execute goose reset + goose up against the production database URL, which will irreversibly destroy all prod data. The only guard is a string input and being on main, with no environment protection/approval gate or stronger access controls.
Agent Prompt
### Issue description
The new GitHub Action can hard-reset the production database with minimal safeguards (typed string + main branch). This is effectively a production “big red button” that can be triggered via `workflow_dispatch`, causing irreversible data loss.
### Issue Context
- Workflow runs on `workflow_dispatch` and calls `scripts/ci/reset_database.sh`.
- `reset_database.sh` retrieves `/cgc-2026-prod/api/database_url` and runs `goose reset`.
### Fix approach
- Add GitHub **environment protection** (e.g., `environment: production`) with required reviewers/approvals.
- Add **concurrency** to prevent parallel destructive runs.
- Add stricter checks (e.g., allowlist actors, require a second explicit confirmation input like the full DB name/account, and/or require a manual approval step).
- Consider making the script require an explicit `TARGET_ENV=prod` (and hard-fail otherwise) so accidental runs are harder.
### Fix Focus Areas
- .github/workflows/reset-database.yml[1-37]
- scripts/ci/reset_database.sh[1-28]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.