fix: Replace dangerous eval with safe calculator implementation#2
Open
surajyog wants to merge 1 commit intoTech-Net-bit:mainfrom
Open
fix: Replace dangerous eval with safe calculator implementation#2surajyog wants to merge 1 commit intoTech-Net-bit:mainfrom
surajyog wants to merge 1 commit intoTech-Net-bit:mainfrom
Conversation
- Remove security vulnerability caused by eval() usage - Add safeCalculator function with input validation - Implement parentheses balancing checks - Add JSDoc documentation for all functions - Add comprehensive README with usage examples and security notes This contribution improves code security by: - Preventing arbitrary code execution - Validating input to only allow mathematical expressions - Providing clear error messages for invalid input
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.
Summary
This PR addresses a critical security vulnerability by removing the dangerous
eval()function and replacing it with a safe calculator implementation.Changes
dangerousCalcfunction that usedeval()safeCalculatorfunction with proper input validationSecurity Improvements
Testing
The new
safeCalculatorfunction: