소스 검색

Added preserved variable names check to the hexadecimal identifiers name generator

sanex3339 5 년 전
부모
커밋
c60627ac3c

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/index.browser.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/index.cli.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/index.js


+ 2 - 7
src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts

@@ -17,11 +17,6 @@ export class HexadecimalIdentifierNamesGenerator extends AbstractIdentifierNames
      */
     private static readonly baseIdentifierNameLength: number = 6;
 
-    /**
-     * @type {Set<string>}
-     */
-    private readonly randomVariableNameSet: Set <string> = new Set();
-
     /**
      * @param {IRandomGenerator} randomGenerator
      * @param {IOptions} options
@@ -49,11 +44,11 @@ export class HexadecimalIdentifierNamesGenerator extends AbstractIdentifierNames
         const baseIdentifierName: string = hexadecimalNumber.substr(0, baseNameLength);
         const identifierName: string = `_${Utils.hexadecimalPrefix}${baseIdentifierName}`;
 
-        if (this.randomVariableNameSet.has(identifierName)) {
+        if (!this.isValidIdentifierName(identifierName)) {
             return this.generateForGlobalScope(nameLength);
         }
 
-        this.randomVariableNameSet.add(identifierName);
+        this.preserveName(identifierName);
 
         return identifierName;
     }

+ 1 - 1
src/node-transformers/preparing-transformers/VariablePreserveTransformer.ts

@@ -8,9 +8,9 @@ import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
-import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
 import { IScopeIdentifiersTraverser } from '../../interfaces/node/IScopeIdentifiersTraverser';
 import { IScopeIdentifiersTraverserCallbackData } from '../../interfaces/node/IScopeIdentifiersTraverserCallbackData';
+import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
 
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { TransformationStage } from '../../enums/node-transformers/TransformationStage';

+ 1 - 1
test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts

@@ -886,7 +886,7 @@ describe('JavaScriptObfuscator', () => {
                             {
                                 ...NO_ADDITIONAL_NODES_PRESET,
                                 ...baseParams,
-                                stringArrayEncoding: StringArrayEncoding.Rc4
+                                stringArrayEncoding: StringArrayEncoding.Base64
                             }
                         ).getObfuscatedCode();
 

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.