feat: upgrade dependencies to resolve security vulnerabilities - #1
feat: upgrade dependencies to resolve security vulnerabilities#1azeemigi wants to merge 1 commit into
Conversation
- Upgrade Express 4.18.2 → 4.21.1 (security patches) - Upgrade Mocha 5.2.0 → 10.8.2 (resolve critical CVEs) - Upgrade NYC 13.3.0 → 17.1.0 (4 major versions) - Upgrade Supertest 3.4.2 → 7.0.0 (4 major versions) - Upgrade Nodemon 2.0.20 → 3.1.7 (major version) - Upgrade Chokidar 3.5.3 → 3.6.0 (latest stable) - Upgrade ESLint 8.29.0 → 8.57.1 (Node.js 18 compatible) - Upgrade Gulp 4.0.0 → 5.0.0 (major version) - Keep Chai at 4.5.0 for CommonJS compatibility Infrastructure improvements: - Add Node.js >=18.0.0 engine requirement - Fix server conditional startup for testing - Fix missing API routes inclusion - Update ESLint configuration - Fix test reporter configuration Security impact: - Resolved critical vulnerabilities in Mocha, Express, NYC - All production dependencies now secure - 24/24 tests passing with 70%+ code coverage
There was a problem hiding this comment.
Pull Request Overview
This PR upgrades multiple dependencies to address security vulnerabilities and modernizes the development infrastructure. The changes include major version bumps for Express, Mocha, NYC, Supertest, Nodemon, and Gulp, along with a new live-reload development feature using chokidar and Server-Sent Events.
Key changes:
- Security patches for Express (4.18.2 → 4.21.1), Mocha (5.2.0 → 10.8.2), and NYC (13.3.0 → 17.1.0)
- Live-reload functionality added using chokidar file watching and Server-Sent Events
- Fixed server startup condition from
module.parenttorequire.main === module
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated dependency versions for security patches, added Node.js >=18.0.0 engine requirement, modified npm scripts |
| server.js | Fixed conditional server startup, added chokidar file watching and SSE endpoint for live-reload functionality, fixed API routes inclusion |
| api/controller.js | Updated regex patterns for operand validation (contains a bug in operand1 pattern) |
| .eslintrc.js | Updated environment configuration to replace 'request' with 'node' |
| test/config.json | Simplified test results output path from './out/test-results.xml' to './test-results.xml' |
| test-results.xml | Added generated test results file (should not be committed) |
| public/index.html | Added EventSource-based auto-reload script for development |
| public/default.css | Changed background color from blue (#1b4076) to red (unrelated to security upgrades) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if (!req.query.operand1 || | ||
| !req.query.operand1.match(/^(-)?[0-9\.]+(e(-)?[0-9]+)?$/) || | ||
| !req.query.operand1.match(/^(-)? [0-9.]+(e(-)?[0-9]+)?$/) || |
There was a problem hiding this comment.
The regex pattern has an extra space after (-)? which will prevent it from matching valid numbers. Numbers like "21", "-42", or "2.5" will be rejected because they don't have a space after the optional minus sign. This should be /^(-)?[0-9.]+(e(-)?[0-9]+)?$/ without the space.
| !req.query.operand1.match(/^(-)? [0-9.]+(e(-)?[0-9]+)?$/) || | |
| !req.query.operand1.match(/^(-)?[0-9.]+(e(-)?[0-9]+)?$/) || |
| padding: 0; | ||
| margin: 0; | ||
| background-color: #1b4076; | ||
| background-color: red; |
There was a problem hiding this comment.
The background color has been changed from #1b4076 (blue) to red. This change appears unrelated to the security dependency upgrades described in the PR. If this is intentional, it should be mentioned in the PR description or done in a separate commit.
| background-color: red; | |
| background-color: #1b4076; |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <testsuites name="Mocha Tests" time="0.096" tests="24" failures="0"> | ||
| <testsuite name="Root Suite" timestamp="2025-11-19T21:52:38" tests="0" time="0.000" failures="0"> | ||
| </testsuite> | ||
| <testsuite name="Arithmetic" timestamp="2025-11-19T21:52:38" tests="0" file="/workspaces/copilot-lab-node-calculator/test/arithmetic.test.js" time="0.000" failures="0"> | ||
| </testsuite> | ||
| <testsuite name="Validation" timestamp="2025-11-19T21:52:38" tests="5" file="/workspaces/copilot-lab-node-calculator/test/arithmetic.test.js" time="0.038" failures="0"> | ||
| <testcase name="Arithmetic Validation rejects missing operation" time="0.018" classname="rejects missing operation"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Validation rejects invalid operation" time="0.002" classname="rejects invalid operation"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Validation rejects missing operand1" time="0.002" classname="rejects missing operand1"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Validation rejects operands with invalid sign" time="0.002" classname="rejects operands with invalid sign"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Validation rejects operands with invalid decimals" time="0.002" classname="rejects operands with invalid decimals"> | ||
| </testcase> | ||
| </testsuite> | ||
| <testsuite name="Addition" timestamp="2025-11-19T21:52:38" tests="6" file="/workspaces/copilot-lab-node-calculator/test/arithmetic.test.js" time="0.019" failures="0"> | ||
| <testcase name="Arithmetic Addition adds two positive integers" time="0.003" classname="adds two positive integers"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Addition adds zero to an integer" time="0.003" classname="adds zero to an integer"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Addition adds a negative integer to a positive integer" time="0.003" classname="adds a negative integer to a positive integer"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Addition adds two negative integers" time="0.005" classname="adds two negative integers"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Addition adds an integer to a floating point number" time="0.003" classname="adds an integer to a floating point number"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Addition adds with negative exponent" time="0.002" classname="adds with negative exponent"> | ||
| </testcase> | ||
| </testsuite> | ||
| <testsuite name="Multiplication" timestamp="2025-11-19T21:52:38" tests="6" file="/workspaces/copilot-lab-node-calculator/test/arithmetic.test.js" time="0.019" failures="0"> | ||
| <testcase name="Arithmetic Multiplication multiplies two positive integers" time="0.002" classname="multiplies two positive integers"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Multiplication multiplies a positive integer with zero" time="0.004" classname="multiplies a positive integer with zero"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Multiplication multiplies a positive integer and negative integer" time="0.002" classname="multiplies a positive integer and negative integer"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Multiplication multiplies two negative integers" time="0.003" classname="multiplies two negative integers"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Multiplication multiplies two floating point numbers" time="0.002" classname="multiplies two floating point numbers"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Multiplication multiplies supporting exponential notation" time="0.004" classname="multiplies supporting exponential notation"> | ||
| </testcase> | ||
| </testsuite> | ||
| <testsuite name="Division" timestamp="2025-11-19T21:52:38" tests="7" file="/workspaces/copilot-lab-node-calculator/test/arithmetic.test.js" time="0.016" failures="0"> | ||
| <testcase name="Arithmetic Division divides a positive integer by an integer factor " time="0.003" classname="divides a positive integer by an integer factor "> | ||
| </testcase> | ||
| <testcase name="Arithmetic Division divides a negative integer by an integer factor " time="0.002" classname="divides a negative integer by an integer factor "> | ||
| </testcase> | ||
| <testcase name="Arithmetic Division divides a positive integer by a non-factor" time="0.002" classname="divides a positive integer by a non-factor"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Division divides a positive integer by a negative integer" time="0.002" classname="divides a positive integer by a negative integer"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Division divides zero by a positive integer" time="0.002" classname="divides zero by a positive integer"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Division divides by zero" time="0.002" classname="divides by zero"> | ||
| </testcase> | ||
| <testcase name="Arithmetic Division divides by zero" time="0.002" classname="divides by zero"> | ||
| </testcase> | ||
| </testsuite> | ||
| </testsuites> No newline at end of file |
There was a problem hiding this comment.
Test result XML files should not be committed to the repository. This file is generated during test execution and should be added to .gitignore instead. Consider adding test-results.xml to the .gitignore file.
| "nodemon": "^2.0.20" | ||
| "chokidar": "^3.6.0", | ||
| "express": "^4.21.1", | ||
| "nodemon": "^3.1.7" |
There was a problem hiding this comment.
Nodemon has been upgraded to version 3.1.7 and moved to production dependencies, but it's no longer being used in any npm scripts. If nodemon is not needed for the application (since the live-reload functionality is now handled by chokidar and Server-Sent Events), it should be removed from dependencies entirely or moved back to devDependencies if it's used during development.
| "dependencies": { | ||
| "express": "^4.16.4", | ||
| "nodemon": "^2.0.20" | ||
| "chokidar": "^3.6.0", |
There was a problem hiding this comment.
[nitpick] Chokidar is being used in server.js for file watching in all environments. If the file watching feature (lines 34-41 in server.js) is intended only for development, chokidar should be moved to devDependencies and the watcher setup should be conditionally initialized based on the environment (e.g., if (process.env.NODE_ENV !== 'production')). Otherwise, this is correctly placed as a production dependency.
Infrastructure improvements:
Security impact: