Remove eval() security risk by extracting getMajorVersion to shared module#6
Merged
Merged
Conversation
Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add changes to address feedback on production enhancements
Remove eval() security risk by extracting getMajorVersion to shared module
Jan 15, 2026
mdaashir
approved these changes
Jan 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes a security vulnerability by eliminating the use of eval() in functional tests. The getMajorVersion utility function is extracted from extension.js into a new shared module scripts/utils.js, which is then imported by both the main extension and the functional tests.
Changes:
- Created a new shared utility module
scripts/utils.jswith thegetMajorVersionfunction - Updated
extension.jsto importgetMajorVersionfrom the shared module instead of defining it inline - Updated
scripts/functional-tests.jsto importgetMajorVersiondirectly instead of using regex extraction andeval()
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/utils.js | New shared utility module exporting getMajorVersion for extracting major version numbers from semver strings |
| scripts/functional-tests.js | Removed eval() security risk by importing getMajorVersion directly; eliminated helper function that extracted code via regex |
| extension.js | Refactored to import getMajorVersion from shared utils module instead of inline definition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3a88ad1
into
feature/production-enhancements-v2.3
6 checks passed
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.
Addresses security feedback on using
eval()in functional tests to extract and test thegetMajorVersionfunction from extension.js.Changes
scripts/utils.js: Shared module exportinggetMajorVersionfunctionextension.js: ImportgetMajorVersionfrom utils instead of inline definitionscripts/functional-tests.js: Direct import replaces regex extraction + eval patternBefore
After
Eliminates eval() while maintaining identical functionality. All 31 functional tests pass.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.