Commit 85a84a2
Overhaul and More Modularity (#150)
* Fix typo in comment and enhance deobfuscation logic in REstringer class. Update the algorithm description for clarity and improve iteration tracking during safe and unsafe method applications.
* Refactor normalization logic in normalizeComputed.js to enhance clarity and functionality. Split the normalization process into separate functions for matching and transforming computed properties, improving code organization and readability. Update comments for better understanding of the transformation process.
* Refactor normalizeEmptyStatements.js to improve empty statement normalization. Introduced separate functions for matching and transforming empty statements, enhancing clarity and maintainability. Updated comments to better explain the logic and conditions for preserving empty statements in control flow structures.
* Refactor parseTemplateLiteralsIntoStringLiterals.js to enhance template literal processing. Introduced separate functions for matching and transforming template literals, improving code organization and readability. Updated comments to clarify the transformation logic and conditions for processing literals. Expanded test cases to cover various scenarios, ensuring robust handling of template literals with different expressions.
* Refactor rearrangeSequences.js to improve sequence expression handling. Introduced separate functions for matching and transforming sequence expressions in return statements and if conditions, enhancing code readability. Updated comments for clarity on the transformation process. Added new test cases to cover various scenarios, ensuring correct behavior for multiple expressions and edge cases.
* Add quick test script to package.json for targeted testing of functionality and modules
* Refactor functions across multiple modules to enhance clarity and maintainability. Each module now includes separate functions for matching and transforming nodes, improving code organization. Updated comments to better explain the transformation processes and added return statements to ensure proper handling of the Arborist object.
* Enhance rearrangeSwitches functionality by separating matching and transformation processes into distinct functions. Updated documentation to clarify the purpose and algorithm of each function, improving code organization and readability. This refactor allows for better handling of switch statements with deterministic flow, converting them into sequential code blocks.
* Refactor removeDeadNodes.js to improve dead code elimination process. Introduced separate functions for matching and transforming dead nodes, enhancing code organization and readability. Updated documentation to clarify the purpose and algorithm of each function, ensuring better understanding of the dead code removal logic.
* Declare static arrays once outside of a loop
* Refactor removeRedundantBlockStatements.js to improve redundancy elimination in block statements. Introduced separate functions for matching and transforming redundant blocks, enhancing code organization and readability. Updated documentation to clarify the purpose and algorithm of each function, ensuring better understanding of the block statement flattening process.
* Refactor replaceBooleanExpressionsWithIf.js to enhance logical expression handling. Introduced separate functions for matching and transforming logical expressions into explicit if statements, improving code organization and readability. Updated documentation to clarify the purpose and algorithm of each function, ensuring better understanding of the transformation process. Added comprehensive test cases to validate various logical expression scenarios.
Introduced a comprehensive guide for refactoring REstringer JavaScript deobfuscator modules. The document outlines overall approach, code structure requirements, performance requirements, documentation standards, testing requirements, and a checklist for each module. It emphasizes best practices for separating matching and transformation logic, optimizing performance, and ensuring thorough documentation and testing.
* refactor(safe): replaceCallExpressionsWithUnwrappedIdentifier - match/transform pattern
- Split into separate match and transform functions following established pattern
- Extract static FUNCTION_EXPRESSION_TYPES array to avoid recreation overhead
- Remove spread operators from typeMap access for better performance
- Add comprehensive JSDoc documentation for all functions
- Add inline comments explaining algorithm steps and edge cases
- Enhance test coverage from 2 to 9 cases (TP and TN scenarios)
- Add isUnwrappableExpression helper to reduce code duplication
- Maintain full backward compatibility and functionality
* refactor(safe): replaceEvalCallsWithLiteralContent match/transform pattern
Split into match/transform functions, optimize performance, add documentation and tests
* refactor(safe): replaceFunctionShellsWithWrappedValue match/transform pattern
Split into match/transform functions, extract static arrays, optimize performance, add comprehensive documentation and tests
* refactor(safe): replaceFunctionShellsWithWrappedValueIIFE match/transform pattern
Split into match/transform functions, fix condition ordering, add safety checks, optimize performance, add comprehensive documentation and tests
* refactor(safe): replaceIdentifierWithFixedAssignedValue match/transform pattern
Split into match/transform functions, add helper function, optimize condition ordering, add safety checks, optimize performance, add comprehensive documentation and tests
* refactor(safe): replaceIdentifierWithFixedValueNotAssignedAtDeclaration match/transform pattern
Split into match/transform functions, extract static regex, optimize performance, add comprehensive documentation and tests
* refactor(safe): replaceNewFuncCallsWithLiteralContent match/transform pattern
Split into match/transform functions, extract helper functions, optimize performance, add comprehensive documentation and tests
* refactor: replaceSequencesWithExpressions - match/transform pattern, performance optimization, enhanced test coverage
- Split into match/transform functions following established pattern
- Optimized performance with helper functions and eliminated spread operators
- Added comprehensive JSDoc documentation and algorithm explanations
- Enhanced test coverage from 2 to 12 test cases with edge cases
- Improved safety checks and array building efficiency
* refactor: resolveDeterministicIfStatements - match/transform pattern, unary expression support, enhanced truthiness handling
- Split into match/transform functions following established pattern
- Added support for UnaryExpression nodes (e.g., -1, +5, !true)
- Enhanced JavaScript truthiness evaluation with proper edge case handling
- Optimized performance with helper functions and eliminated spread operators
- Added comprehensive JSDoc documentation and algorithm explanations
- Enhanced test coverage from 1 to 14 test cases covering all literal types and edge cases
- Improved safety checks and unary operator evaluation
* refactor(safe): Split resolveFunctionConstructorCalls into match/transform pattern
- Extract helper functions buildArgumentsString and generateFunctionExpression
- Add comprehensive JSDoc documentation and inline comments
- Optimize performance with direct typeMap access
- Enhance test coverage with 13 test cases for edge cases
- Maintain original behavior for any .constructor call with literal arguments
- Add error handling for invalid function syntax
* refactor(resolveMemberExpressionReferencesToArrayIndex): split into match/transform pattern
- Separate matching and transformation logic into distinct functions
- Add comprehensive validation with bounds checking and type validation
- Extract MIN_ARRAY_LENGTH constant and optimize performance
- Add JSDoc documentation explaining array resolution algorithm
- Enhance test coverage with 6 additional edge cases
- Use traditional for loops and direct typeMap access for performance
* refactor(resolveMemberExpressionsWithDirectAssignment): split into match/transform pattern
- Separate matching and transformation logic into distinct functions
- Add conservative computed property access validation (literals only)
- Enhance modification detection for assignments and update expressions
- Extract helper functions for property name resolution and reference checking
- Add comprehensive JSDoc documentation explaining safety constraints
- Optimize performance with traditional for loops and direct typeMap access
- Enhance test coverage with 8 additional test cases for edge scenarios
* refactor(resolveProxyCalls): implement match/transform pattern for proxy function resolution
- Introduce separate functions for matching and transforming proxy calls
- Enhance validation to ensure proxy functions meet specific criteria
- Add comprehensive JSDoc documentation detailing function behavior and safety constraints
- Expand test coverage with multiple test cases for various proxy scenarios and edge cases
- Ensure that only valid proxy functions are transformed, maintaining original behavior for non-proxy functions
* refactor(resolveProxyReferences): split into match/transform pattern with comprehensive safety checks
- Split logic into match and transform functions following established pattern
- Extract SUPPORTED_REFERENCE_TYPES array and LOOP_STATEMENT_REGEX for performance
- Add helper functions for proxy pattern validation and replacement safety
- Enhance loop detection to include while/do-while statements
- Remove overly restrictive safety check that prevented valid transformations
- Add comprehensive JSDoc documentation and inline comments
- Expand test coverage with positive, negative, and edge cases
- Use single optional chaining checks for cleaner code
* Improve JSDoc type documentation
* refactor(resolveProxyVariables): implement match/transform pattern for proxy variable handling
- Introduce separate functions for matching and transforming proxy variable declarations
- Enhance validation to ensure only valid proxy patterns are processed
- Add comprehensive JSDoc documentation detailing function behavior and safety constraints
- Expand test coverage with multiple test cases for various proxy scenarios, including edge cases
- Ensure that transformations maintain original behavior for non-proxy variables and handle unused declarations
* refactor(safe): enhance resolveRedundantLogicalExpressions with comprehensive edge case documentation
- Split into match/transform functions following established pattern
- Extract static arrays (LOGICAL_OPERATORS, TRUTHY_NODE_TYPES) to avoid recreation overhead
- Replace multiple || conditions with TRUTHY_NODE_TYPES.includes() for cleaner code
- Remove spread operators and || [] fallbacks from typeMap access
- Add comprehensive truth table in JSDoc showing JavaScript's short-circuit evaluation
- Document 6 major edge cases where optimization could break code (getters, side effects, proxies, etc.)
- Format edge case documentation as plain JSDoc (no markdown emphasis)
- Explain safety justification for obfuscated code analysis context
- Enhance truthiness evaluation to handle arrays, objects, functions, and regex
- Combine multiple if conditions for more efficient matching
- Improve performance with optimized condition ordering and single-pass evaluation
* refactor(separateChainedDeclarators): implement match/transform pattern with comprehensive test coverage
- Split into separateChainedDeclaratorsMatch and separateChainedDeclaratorsTransform functions
- Extract FOR_STATEMENT_REGEX constant to avoid recreation overhead
- Optimize createReplacementParent to eliminate code duplication using unified replacement pattern
- Remove spread operators from typeMap access for better performance
- Add comprehensive JSDoc documentation for all functions with detailed examples
- Enhance test coverage with 8 TP and 6 TN cases covering edge cases, mixed patterns, and for-loop preservation
- Use traditional for loops with 'i' variable for optimal performance
- Ensure explicit arb returns and proper functional flow throughout
* refactor(simplifyCalls): implement match/transform pattern with enhanced test coverage and bug fixes
- Split into simplifyCallsMatch and simplifyCallsTransform functions
- Extract CALL_APPLY_METHODS constant to avoid recreation overhead
- Add helper functions getPropertyName and extractSimplifiedArguments for better code organization
- Fix computed property access bug - preserve obj['call']/obj['apply'] patterns instead of transforming them
- Remove spread operators from typeMap access for better performance
- Add comprehensive JSDoc documentation with detailed examples and edge case warnings
- Enhance test coverage with 6 new cases covering complex arguments, member expressions, empty arrays, mixed calls, and computed property exclusions
- Use traditional for loops with 'i' variable for optimal performance
- Ensure explicit arb returns and proper functional flow throughout
* refactor(simplifyIfStatements): implement match/transform pattern with comprehensive test coverage
- Split into simplifyIfStatementsMatch and simplifyIfStatementsTransform functions
- Add helper functions isEmpty and createInvertedTest for better code organization
- Remove spread operators from typeMap access for better performance
- Use traditional for loops with 'i' variable for optimal performance
- Add comprehensive JSDoc documentation with detailed transformation examples
- Enhance test coverage with 8 new cases covering complex expressions, nested statements, and edge cases
- Logic review confirms sound implementation with proper handling of all if statement simplification scenarios
* refactor(unwrapFunctionShells): implement match/transform pattern with comprehensive test coverage
- Split into unwrapFunctionShellsMatch and unwrapFunctionShellsTransform functions
- Add helper functions getPropertyName and createUnwrappedFunction for better code organization
- Extract FUNCTION_TYPES constant to avoid recreation overhead
- Remove spread operators from typeMap access for better performance
- Use traditional for loops with 'i' variable for optimal performance
- Add comprehensive JSDoc documentation with detailed transformation examples
- Enhance test coverage with 12 new cases covering function expressions, parameter handling, and edge cases
- Add 8 TN cases for multiple statements, wrong methods, invalid arguments, and empty functions
- Logic review confirms correct handling of identifier and parameter transfer from outer to inner functions
* refactor(unwrapFunctionShells): implement match/transform pattern with comprehensive test coverage
- Split into unwrapFunctionShellsMatch and unwrapFunctionShellsTransform functions
- Add helper functions getPropertyName and createUnwrappedFunction for better code organization
- Extract FUNCTION_TYPES constant to avoid recreation overhead
- Use .concat() for array concatenation and spread operators for safe AST node cloning
- Add comprehensive JSDoc documentation with specific ASTNode types
- Ensure consistent return types - getPropertyName returns string not string|null
- Use traditional for loops with 'i' variable for optimal performance
- Enhance test coverage from 2 to 15 cases with proper behavior validation
- Add TN cases for arrow functions, empty bodies, wrong arguments, and computed properties
- Remove invalid test assumptions and verify expected results match actual behavior
* refactor(unwrapIIFEs): implement match/transform pattern with comprehensive test coverage
- Split into unwrapIIFEsMatch and unwrapIIFEsTransform functions
- Add helper functions isUnwrappableIIFE and computeUnwrappingNodes for better code organization
- Extract IIFE_FUNCTION_TYPES constant to avoid recreation overhead
- Remove spread operators from typeMap access for better performance
- Use .concat() for array concatenation and spread operators for safe AST node cloning
- Add comprehensive JSDoc documentation with specific ASTNode types and detailed examples
- Use traditional for loops with 'i' variable for optimal performance
- Enhance test coverage from 5 to 10 cases with proper behavior validation
- Add TP cases for multiple statement unwrapping and arrow function expression bodies
- Add TN cases for IIFEs with arguments, named functions, and assignment contexts
- Verify all test expectations match actual code behavior
* refactor(unwrapSimpleOperations): implement match/transform pattern with enhanced test coverage
- Split into unwrapSimpleOperationsMatch and unwrapSimpleOperationsTransform functions
- Add helper functions isBinaryOrLogicalWrapper, isUnaryOrUpdateWrapper, createBinaryOrLogicalExpression, and createUnaryOrUpdateExpression for better code organization
- Extract static constants BINARY_OPERATORS, UNARY_OPERATORS, BINARY_EXPRESSION_TYPES, and UNARY_EXPRESSION_TYPES to avoid recreation overhead
- Use .concat() for array concatenation in typeMap access for better performance
- Add comprehensive JSDoc documentation with specific ASTNode types and detailed transformation examples
- Use traditional for loops with 'i' variable for optimal performance
- Enhance test coverage from 3 to 8 cases with proper behavior validation
- Add TN cases for multiple statements, wrong parameter count, non-parameter operations, no return statement, and unsupported operators
- Verify all test expectations match actual code behavior for both positive and negative cases
* refactor(normalizeRedundantNotOperator): implement match/transform pattern with enhanced test coverage
- Split into normalizeRedundantNotOperatorMatch and normalizeRedundantNotOperatorTransform functions
- Extract RESOLVABLE_ARGUMENT_TYPES constant to avoid recreation overhead
- Remove spread operators from typeMap access for better performance
- Use traditional for loops with 'i' variable for optimal performance
- Inline match logic directly in loop to eliminate function call overhead
- Add comprehensive JSDoc documentation with specific ASTNode types and detailed transformation examples
- Optimize sandbox creation by only creating when matches are found and sharing across transforms
- Enhance test coverage from 1 to 11 cases with proper TP/TN scenarios and descriptive names
* refactor(resolveAugmentedFunctionWrappedArrayReplacements): implement match/transform pattern with performance optimizations
- Split into match and transform functions following established pattern
- Remove spread operators from typeMap access for better performance
- Defer expensive validation to transform function where results are used
- Add comprehensive test coverage from 3 to 7 TN cases covering all edge cases
- Optimize sandbox creation by only creating when expensive validations succeed
* Refactor resolveBuiltinCalls.js: implement match/transform pattern with performance optimizations
- Split into resolveBuiltinCallsMatch and resolveBuiltinCallsTransform functions
- Inline helper functions in match loop to eliminate function call overhead
- Optimize candidateFilter placement and use .some() instead of .find() for better performance
- Add comprehensive JSDoc with specific ASTNode types
- Enhance test coverage from 6 to 14 cases covering member expressions and edge cases
* Refactor resolveDefiniteBinaryExpressions.js: implement match/transform pattern with comprehensive test coverage
- Split into resolveDefiniteBinaryExpressionsMatch and resolveDefiniteBinaryExpressionsTransform functions
- Remove spread operators and optimize performance with direct typeMap access
- Add comprehensive JSDoc with specific ASTNode types
- Enhance test coverage from 1 to 12 cases covering arithmetic, bitwise, comparison operations and edge cases
- Add meaningful inline comments explaining negative number edge case handling
* Refactor resolveDefiniteMemberExpressions.js: implement match/transform pattern with performance optimizations
- Split into resolveDefiniteMemberExpressionsMatch and resolveDefiniteMemberExpressionsTransform functions
- Optimize with direct typeMap access and traditional for loops
- Add comprehensive JSDoc with specific ASTNode types
- Enhance test coverage from 2 to 13 cases covering various member access patterns
* Refactor resolveDeterministicConditionalExpressions.js: implement match/transform pattern with performance optimizations
- Split into resolveDeterministicConditionalExpressionsMatch and resolveDeterministicConditionalExpressionsTransform functions
- Optimize with direct typeMap access and traditional for loops
- Add comprehensive JSDoc with specific ASTNode types
- Enhance test coverage from 2 to 13 cases covering various literal types and edge cases
* Refactor resolveEvalCallsOnNonLiterals.js: implement match/transform pattern with performance optimizations
- Split into resolveEvalCallsOnNonLiteralsMatch and resolveEvalCallsOnNonLiteralsTransform functions
- Optimize sandbox creation to only occur when matches are found
- Add comprehensive JSDoc with specific ASTNode types and context handling explanations
- Enhance test coverage from 2 to 12 cases covering variable references, IIFEs, and edge cases
* Refactor resolveFunctionToArray.js: implement match/transform pattern with enhanced logic validation
- Split into resolveFunctionToArrayMatch and resolveFunctionToArrayTransform functions
- Add member expression validation to prevent method call transformations
- Optimize with direct typeMap access and traditional for loops
- Add comprehensive JSDoc with specific ASTNode types
- Enhance test coverage from 1 to 12 cases covering various usage patterns
* Refactor resolveInjectedPrototypeMethodCalls: split match/transform pattern, add arrow function support, optimize performance, and enhance test coverage
* Refactor config.js and resolveBuiltinCalls.js: rename skipIdentifiers to SKIP_IDENTIFIERS for consistency and clarity in imports
* Refactor resolveLocalCalls: split match/transform pattern, optimize performance with static constants and direct typeMap access, enhance test coverage from 6 to 15 cases
* Refactor resolveMemberExpressionsLocalReferences: split match/transform pattern, extract static constant, optimize performance, add comprehensive JSDoc and test coverage from 0 to 10 cases
* Refactor resolveBuiltinCalls.js and resolveLocalCalls.js: rename skipProperties for consistency in imports
* refactor: split resolveMinimalAlphabet into match/transform functions
- Extract match and transform logic into separate functions following established pattern
- Optimize ThisExpression checks by replacing single-item array with direct === comparison
- Add comprehensive JSDoc with specific types (ASTNode, ASTNode[], Arborist)
- Use traditional for loops with direct typeMap access for better performance
- Enhance test coverage from 3 to 8 cases (4 TP, 4 TN) with descriptive names
- Add inline comments explaining JSFuck pattern detection and safe evaluation constraints
* refactor: standardize constant naming in config.js and related modules
- Rename constants in config.js to uppercase for consistency (e.g., badValue to BAD_VALUE)
- Update imports across multiple modules to reflect new constant names
- Enhance clarity and maintainability of the codebase by following naming conventions
- Ensure all references to renamed constants are updated in logic and tests
* refactor: enhance areReferencesModified detection and standardize config variables
- Fix delete operation detection for member expressions (delete obj.prop, delete arr[index])
- Fix update expression detection for member expressions (obj.count++, ++obj.prop)
- Add for-in/for-of/for-await loop modification detection with member expressions
- Centralize additional mutating methods (sort, reverse, fill, copyWithin) in config.js
- Expand test coverage from 5 to 19 cases covering all enhanced detection capabilities
* refactor: consolidate canNotOperatorArgument check into normalizeRedundantNotOperator
- Move NOT operator argument validation directly into normalizeRedundantNotOperator module
- Remove unnecessary single-use utility function to eliminate function call overhead
- Enhance argument support for arrays, objects, template literals with comprehensive evaluation
- Update test coverage to reflect enhanced complex literal evaluation capability
* refactor: enhance createNewNode utility with modern JavaScript type support
- Add BigInt and Symbol support with proper AST node generation
- Eliminate unnecessary Node-to-string conversion by returning AST Nodes directly
* refactor: optimize createOrderedSrc utility with enhanced error handling and performance
- Add proper error handling for parse failures in addNameToFE
- Replace O(n²) duplicate detection with O(1) Set-based approach
- Fix undefined return values and remove redundant assignments
- Comprehensive JSDoc documentation with examples
- Robust test coverage for all functionality and edge cases
* refactor: enhance and integrate doesBinaryExpressionContainOnlyLiterals into resolveDefiniteBinaryExpressions
- Add support for LogicalExpression, ConditionalExpression, SequenceExpression, UpdateExpression
- Move single-use utility function into its only consumer module
* refactor: enhance doesDescendantMatchCondition utility with performance optimizations
- Add null/undefined input validation and function type checking
- Replace spread operator with traditional loop for better performance
- Add comprehensive test coverage (10 test cases covering real usage patterns)
* refactor: enhance generateHash utility with robust input validation and error handling
- Add support for AST nodes with .src property alongside string inputs
- Add null/undefined input validation with graceful fallback values
- Add crypto error handling with fallback hash generation algorithm
- Add comprehensive test coverage (10 test cases covering all input types)
* refactor: enhance getCache utility with robust input validation and comprehensive documentation
- Add null/undefined script hash validation with 'no-hash' fallback
- Add comprehensive JSDoc explaining cache invalidation strategy and usage patterns
- Expand test coverage from 2 to 10 test cases with proper isolation
* refactor: enhance getCalleeName utility with comprehensive logic and improved test coverage
- Refactor getCalleeName to accurately extract function names from CallExpressions, handling direct calls, variable method calls, and avoiding collisions with literal method calls
- Add extensive input validation to handle null, undefined, and complex expressions
- Expand test coverage with 9 new test cases, ensuring robust handling of various call scenarios and edge cases
* refactor(getDeclarationWithContext): optimize visitedNodes tracking and enhance documentation
- Replace O(n) Array.includes with O(1) Set operations for visitedNodes tracking
- Rename constants to ALL_CAPS convention (TYPES_TO_COLLECT, SKIP_TRAVERSAL_TYPES)
- Add comprehensive JSDoc explaining context collection algorithm
- Add input validation for null/undefined inputs
- Enhance test coverage with 3 edge case TN tests
* refactor(getDescendants): optimize traversal with Set, fix typos, and enhance documentation
- Use Set for O(1) duplicate detection during traversal, convert to array for cache storage
- Fix typo 'decendants' -> 'descendants' in JSDoc and property names
- Add null/undefined input validation with empty array fallback
- Enhance JSDoc with comprehensive algorithm explanation and examples
- Improve variable naming (offsprings -> descendants)
* refactor(getMainDeclaredObjectOfMemberExpression): add safety checks and enhance documentation
- Add input validation for null/undefined inputs
- Add infinite loop protection with iteration counter
- Enhance JSDoc with comprehensive algorithm explanation and examples
- Expand test coverage from 2 to 9 tests covering edge cases
- Preserve original behavior for all valid inputs
* refactor(getObjType): enhance documentation and add comprehensive test coverage
- Add comprehensive JSDoc with algorithm explanation and examples
- Change to direct export pattern for consistency
- Create 16 test cases covering all JavaScript types including primitives, objects, and built-ins
* refactor(isNodeInRanges): enhance documentation and streamline implementation
- Add comprehensive JSDoc with algorithm explanation and examples
- Add early return optimization for empty ranges array
- Expand test coverage to 9 essential cases covering core functionality
- Change to direct export pattern for consistency
* refactor(normalizeScript): enhance documentation and clarify transformation pipeline
- Add comprehensive JSDoc explaining normalization transformations
* Enhance safe-atob and safe-btoa documentation with comprehensive JSDoc and examples
* Enhanced documentation with comprehensive JSDoc and improved trap neutralization
* Enhanced VM sandbox documentation with honest security disclaimers, fixed null handling bug, and created comprehensive test coverage for critical deobfuscation infrastructure.
* refactor(processors): enhance augmentedArray with match/transform pattern and intelligent function filtering
- Split into augmentedArrayMatch and augmentedArrayTransform functions
- Add sophisticated self-modification detection for function declarations
- Use direct typeMap access
- Extract FUNCTION_DECLARATION_PATTERN regex outside functions
- Add comprehensive test coverage (6 TP, 9 TN) including arrow functions and edge cases
- Use standard candidateFilter default pattern (() => true)
* Enhance functionToArray processor documentation and examples
- Add comprehensive JSDoc explaining array replacement patterns
- Document common obfuscation scenarios and transformations
- Improve test descriptions and usage examples
- Clarify processor wrapper configuration
* Refactor obfuscator.io processor with match/transform pattern and rename file
- Rename obfuscatorIo.js to obfuscator.io.js for consistency
- Split into obfuscatorIoMatch/obfuscatorIoTransform functions
- Extract DEBUG_PROTECTION_TRIGGERS and FREEZE_REPLACEMENT_STRING constants
- Add comprehensive JSDoc explaining debug protection bypass mechanisms
- Optimize performance with static extraction and direct typeMap access
- Update all references across codebase (tests, README, resources)
* Refactor parseArgs utility with comprehensive improvements
- Fix empty catch block and add meaningful error handling
- Replace inefficient multi-regex approach with single-pass parsing
- Add pre-compiled regex patterns for performance optimization
- Enhance input validation and edge case handling
- Add comprehensive JSDoc documentation with examples
- Improve error reporting with actionable user feedback
- Extract helper functions to reduce code duplication
- Maintain full backward compatibility with existing tests
* Update CONTRIBUTING.md to enhance clarity and structure
- Revise the document to provide a comprehensive guide for contributing to REstringer
- Introduce a detailed table of contents for easier navigation
- Expand sections on getting started, contribution process, module and processor development, code quality, testing guidelines, and documentation standards
- Include specific guidelines for pull request processes and review checklists
- Improve overall readability and organization to facilitate new contributors
* Update package.json for repository URL change and add watch script for quick tests
- Change repository URL from PerimeterX to HumanSecurity
- Add a new script "test:quick:watch" for running quick tests in watch mode
- Ensure existing test scripts remain intact
* Update README.md and add CONTRIBUTING.md for improved documentation
- Revise README.md to enhance clarity, including a new introduction and detailed features section
- Expand the Table of Contents for easier navigation
- Add a new CONTRIBUTING.md file to provide comprehensive guidelines for contributing to the project
- Include sections on development setup, contribution process, module and processor development, testing requirements, and documentation standards
- Remove outdated refactor-modules-guide.md to streamline documentation
* typo
* Refactor error handling in evaluation functions to use evalInVm.BAD_VALUE
- Replace direct references to BAD_VALUE with evalInVm.BAD_VALUE across multiple modules for consistency and clarity
- Update evaluation checks in functions such as normalizeRedundantNotOperatorTransform, resolveAugmentedFunctionWrappedArrayReplacementsTransform, and others
- Ensure all modules using evalInVm have access to BAD_VALUE through the evalInVm utility
* Rename constants in multiple modules for consistency to uppercase
* Extract constants that are used once from the config to where they're used
* Update dependencies and refactor argument parsing
- Add 'commander' as a dependency to simplify command line argument parsing.
- Refactor the parseArgs function to utilize 'commander' for improved argument handling and validation.
- Remove the argsAreValid function and related tests as validation is now integrated within the parseArgs function.
- Update deobfuscate.js to skip processing if help is displayed, enhancing user experience.
* Update LICENSE year and copyright holder to reflect current ownership by HUMAN Security
* Refactor README.md to streamline advanced configuration section
- Remove outdated advanced configuration example for REstringer
- Update import statements for safe and unsafe modules to use default exports
- Enhance clarity in advanced usage section by ensuring consistent import syntax
* Update README.md and refactor custom processor tests
- Correct the link in the resources section to point to the updated analysis page.
- Modify the custom processor matching logic to use regex for pattern detection.
- Update test imports to use Node's built-in assert and test modules, enhancing compatibility.
- Refactor test cases to utilize applyIteratively for processing scripts, improving clarity and consistency.
* Update constructor parameter documentation in REstringer class
- Modify the constructor parameter documentation for 'normalize' to indicate it is optional, improving clarity for users.
* Refactor normalizeComputedMatch function for improved clarity and efficiency
- Simplify the normalization logic by processing MemberExpression, MethodDefinition, and Property nodes separately.
- Add a missing use case where object keys that are strings can be stripped of their quotes.
* Update parameter documentation across multiple modules for consistency
- Change parameter documentation to indicate optional filters using square brackets for clarity.
- Simplify the initialization of relevant nodes in several functions by removing unnecessary concatenation.
* Update dependencies in package.json and package-lock.json
- Upgrade 'commander' to version 14.0.2 for improved functionality.
- Update 'isolated-vm' to version 6.0.2 and 'obfuscation-detector' to version 2.0.6 for enhanced performance and security.
- Revise development dependencies: bump '@babel/eslint-parser' to 7.28.5, '@babel/plugin-syntax-import-assertions' to 7.27.1, 'eslint' to 9.39.1, and 'globals' to 16.5.0 for better linting support.
* Refactor simplifyCalls.js to enhance argument extraction and context validation
- Add support for `null` as a context argument.
- Fix issue with property name extraction failure
* Refactor simplifyIfStatementsTransform for improved readability
- Rename variables for clarity: `consequentEmpty` to `isConsequentEmpty` and `alternateEmpty` to `isAlternateEmpty`.
- Enhance conditional checks to improve code understanding and maintainability.
* Enhance reference handling in resolveMemberExpressionsWithDirectAssignment.js
- Improve logic to prevent replacing references if any modifying references are found.
- Add additional check to ensure references belong to the same scope as the assignment.
- Simplify condition for adding candidates based on replaceable references.
* Fix conditional check in simplifyIfStatementsTransform to ensure alternate is not null before removal to avoid unwanted recursion
* Adjust expected result
* Adjust expected result
* Enhance reference handling in replaceIdentifierWithFixedValueNotAssignedAtDeclaration.js
- Update conditional checks to ensure references have a length before processing.
- Add scope validation to ensure references are replaced only if they match the assignment's scope.
* Enhance simplifyCalls tests to cover null context and refine expected results
- Add a test case for handling `null` as a context argument in function calls.
- Update test case to use `undefined` instead of `null` for context in specific scenarios.
- Adjust expected result for a test case to match the original code structure.
* Update obfuscation-detector dependency to version 2.0.7 in package.json and package-lock.json
* Install isolated-vm's Linux prerequisits
* Fix isolated-vm to version 5.0.4 to keep support for node 20
---------
Co-authored-by: Ben Baryo <[email protected]>1 parent 1f91462 commit 85a84a2
File tree
93 files changed
+11910
-3027
lines changed- .github/workflows
- bin
- docs
- src
- modules
- safe
- unsafe
- utils
- processors
- utils
- tests
- resources
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
93 files changed
+11910
-3027
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments