Draft
Conversation
- Express REST API with POST, GET, GET/:id, DELETE/:id endpoints - In-memory data store with reset function for testing - Comprehensive Jest + supertest test suite (15 tests) - Health check endpoint at GET / - Input validation on POST with proper error responses Co-authored-by: mickeygousset <20031479+mickeygousset@users.noreply.github.com>
RSE-1: Add error-handling middleware to prevent stack trace exposure RSE-2: Reject empty string fields (name, location, dateFound) RSE-3: Reject negative treasure values RSE-4: Reject Infinity/NaN values with Number.isFinite check RSE-5: Strip HTML tags from string inputs to prevent stored XSS BRN-6: Simplify redundant validation (typeof handles null/undefined) Added 5 new tests covering all fixes. All 20 tests pass. Co-authored-by: mickeygousset <20031479+mickeygousset@users.noreply.github.com>
Addresses CodeQL alerts: - js/incomplete-multi-character-sanitization: nested tags like <scr<script>ipt> are now properly handled - js/polynomial-redos: no regex means no backtracking risk Co-authored-by: mickeygousset <20031479+mickeygousset@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
mickeygousset
April 14, 2026 19:18
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Node.js Express API for CRUD operations on pirate treasure, backed by an in-memory store.
API
POST /api/treasures— create treasure (201)GET /api/treasures— list all (200)GET /api/treasures/:id— get by ID (200 / 404)DELETE /api/treasures/:id— delete by ID (204 / 404)GET /— health checkData model
{ "id": "uuid", "name": "string", "value": 0, "location": "string", "dateFound": "string" }IDs generated via
crypto.randomUUID()(nouuidpackage — v13 is ESM-only, incompatible with Jest/CJS).Validation & security hardening
Number.isFinite()guard rejectsNaN/Infinity/negative valuesProject structure
App/server split so supertest can exercise routes without binding a port. Store reset uses
treasures.length = 0to preserve module-level references across test isolation.