Parcourir la source

Merge pull request #1010 from javascript-obfuscator/options-rename

Timofey Kachalov il y a 3 ans
Parent
commit
4b5da457c4
29 fichiers modifiés avec 157 ajouts et 133 suppressions
  1. 7 0
      CHANGELOG.md
  2. 28 28
      README.md
  3. 1 1
      package.json
  4. 9 9
      src/cli/JavaScriptObfuscatorCLI.ts
  5. 3 3
      src/container/modules/node-transformers/PreparingTransformersModule.ts
  6. 1 1
      src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.ts
  7. 3 3
      src/interfaces/options/IOptions.ts
  8. 1 1
      src/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.ts
  9. 26 10
      src/node-transformers/preparing-transformers/obfuscating-guards/IgnoredImportObfuscatingGuard.ts
  10. 1 1
      src/node-transformers/string-array-transformers/StringArrayRotateFunctionTransformer.ts
  11. 2 2
      src/node-transformers/string-array-transformers/StringArrayTransformer.ts
  12. 13 13
      src/options/Options.ts
  13. 2 2
      src/options/normalizer-rules/StringArrayRule.ts
  14. 3 3
      src/options/presets/Default.ts
  15. 2 2
      src/options/presets/LowObfuscation.ts
  16. 3 3
      src/options/presets/NoCustomNodes.ts
  17. 1 1
      src/storages/string-array-transformers/StringArrayStorage.ts
  18. 4 4
      test/functional-tests/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.spec.ts
  19. 5 5
      test/functional-tests/custom-code-helpers/string-array/templates/string-array-rotate-function-template/StringArrayRotateFunctionTemplate.spec.ts
  20. 2 2
      test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts
  21. 11 10
      test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-import-obfuscating-guard/IgnoredImportObfuscatingGuard.spec.ts
  22. 1 1
      test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-import-obfuscating-guard/fixtures/base-behaviour.js
  23. 8 8
      test/functional-tests/node-transformers/string-array-transformers/string-array-rotate-function-transformer/StringArrayRotateFunctionTransformer.spec.ts
  24. 6 6
      test/functional-tests/node-transformers/string-array-transformers/string-array-transformer/StringArrayTransformer.spec.ts
  25. 6 6
      test/functional-tests/options/OptionsNormalizer.spec.ts
  26. 4 4
      test/functional-tests/storages/string-array-transformers/string-array-storage/StringArrayStorage.spec.ts
  27. 1 1
      test/index.spec.ts
  28. 2 2
      test/performance-tests/JavaScriptObfuscatorMemory.spec.ts
  29. 1 1
      test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts

+ 7 - 0
CHANGELOG.md

@@ -1,5 +1,12 @@
 Change Log
 
+v3.0.0
+---
+* **Breaking change:** `ignoreRequireImports` option renamed to `ignoreImports`
+* **Breaking change:** `rotateStringArray` option renamed to `stringArrayRotate`
+* **Breaking change:** `shuffleStringArray` option renamed to `stringArrayShuffle`
+* `ignoreImports` now ignores `dynamic` imports in addition to `require` imports
+
 v2.19.1
 ---
 * Updated `@javascript-obfuscator/escodegen` with fixed parenthesis of `default export` IIFE

+ 28 - 28
README.md

@@ -112,7 +112,7 @@ var obfuscationResult = JavaScriptObfuscator.obfuscate(
         controlFlowFlatteningThreshold: 1,
         numbersToExpressions: true,
         simplify: true,
-        shuffleStringArray: true,
+        stringArrayShuffle: true,
         splitStrings: true,
         stringArrayThreshold: 1
     }
@@ -368,10 +368,8 @@ Following options are available for the JS Obfuscator:
     renamePropertiesMode: 'safe',
     reservedNames: [],
     reservedStrings: [],
-    rotateStringArray: true,
     seed: 0,
     selfDefending: false,
-    shuffleStringArray: true,
     simplify: true,
     sourceMap: false,
     sourceMapBaseUrl: '',
@@ -386,6 +384,8 @@ Following options are available for the JS Obfuscator:
     ],
     stringArrayEncoding: [],
     stringArrayIndexShift: true,
+    stringArrayRotate: true,
+    stringArrayShuffle: true,
     stringArrayWrappersCount: 1,
     stringArrayWrappersChainedCalls: true,
     stringArrayWrappersParametersMaxCount: 2,
@@ -421,7 +421,7 @@ Following options are available for the JS Obfuscator:
     --identifier-names-generator <string> [dictionary, hexadecimal, mangled, mangled-shuffled]
     --identifiers-dictionary '<list>' (comma separated)
     --identifiers-prefix <string>
-    --ignore-require-imports <boolean>
+    --ignore-imports <boolean>
     --log <boolean>
     --numbers-to-expressions <boolean>
     --options-preset <string> [default, low-obfuscation, medium-obfuscation, high-obfuscation]
@@ -430,10 +430,8 @@ Following options are available for the JS Obfuscator:
     --rename-properties-mode <string> [safe, unsafe]
     --reserved-names '<list>' (comma separated)
     --reserved-strings '<list>' (comma separated)
-    --rotate-string-array <boolean>
     --seed <string|number>
     --self-defending <boolean>
-    --shuffle-string-array <boolean>
     --simplify <boolean>
     --source-map <boolean>
     --source-map-base-url <string>
@@ -446,6 +444,8 @@ Following options are available for the JS Obfuscator:
     --string-array-indexes-type '<list>' (comma separated) [hexadecimal-number, hexadecimal-numeric-string]
     --string-array-encoding '<list>' (comma separated) [none, base64, rc4]
     --string-array-index-shift <boolean>
+    --string-array-rotate <boolean>
+    --string-array-shuffle <boolean>
     --string-array-wrappers-count <number>
     --string-array-wrappers-chained-calls <boolean>
     --string-array-wrappers-parameters-max-count <number>
@@ -968,13 +968,6 @@ Example:
 	}
 ```
 
-### `rotateStringArray`
-Type: `boolean` Default: `true`
-
-##### :warning: [`stringArray`](#stringarray) must be enabled
-
-Shift the `stringArray` array by a fixed and random (generated at the code obfuscation) places. This makes it harder to match the order of the removed strings to their original place.
-
 ### `seed`
 Type: `string|number` Default: `0`
 
@@ -990,13 +983,6 @@ Type: `boolean` Default: `false`
 
 This option makes the output code resilient against formatting and variable renaming. If one tries to use a JavaScript beautifier on the obfuscated code, the code won't work anymore, making it harder to understand and modify it.
 
-### `shuffleStringArray`
-Type: `boolean` Default: `true`
-
-##### :warning: [`stringArray`](#stringarray) must be enabled
-
-Randomly shuffles the `stringArray` array items.
-
 ### `simplify`
 Type: `boolean` Default: `true`
 
@@ -1163,6 +1149,20 @@ Type: `boolean` Default: `true`
 
 Enables additional index shift for all string array calls
 
+### `stringArrayRotate`
+Type: `boolean` Default: `true`
+
+##### :warning: [`stringArray`](#stringarray) must be enabled
+
+Shift the `stringArray` array by a fixed and random (generated at the code obfuscation) places. This makes it harder to match the order of the removed strings to their original place.
+
+### `stringArrayShuffle`
+Type: `boolean` Default: `true`
+
+##### :warning: [`stringArray`](#stringarray) must be enabled
+
+Randomly shuffles the `stringArray` array items.
+
 ### `stringArrayWrappersCount`
 Type: `number` Default: `1`
 
@@ -1435,15 +1435,15 @@ Performance will 50-100% slower than without obfuscation
     log: false,
     numbersToExpressions: true,
     renameGlobals: false,
-    rotateStringArray: true,
     selfDefending: true,
-    shuffleStringArray: true,
     simplify: true,
     splitStrings: true,
     splitStringsChunkLength: 5,
     stringArray: true,
     stringArrayEncoding: ['rc4'],
     stringArrayIndexShift: true,
+    stringArrayRotate: true,
+    stringArrayShuffle: true,
     stringArrayWrappersCount: 5,
     stringArrayWrappersChainedCalls: true,    
     stringArrayWrappersParametersMaxCount: 5,
@@ -1472,15 +1472,15 @@ Performance will 30-35% slower than without obfuscation
     log: false,
     numbersToExpressions: true,
     renameGlobals: false,
-    rotateStringArray: true,
     selfDefending: true,
-    shuffleStringArray: true,
     simplify: true,
     splitStrings: true,
     splitStringsChunkLength: 10,
     stringArray: true,
     stringArrayEncoding: ['base64'],
     stringArrayIndexShift: true,
+    stringArrayRotate: true,
+    stringArrayShuffle: true,
     stringArrayWrappersCount: 2,
     stringArrayWrappersChainedCalls: true,
     stringArrayWrappersParametersMaxCount: 4,
@@ -1507,14 +1507,14 @@ Performance will slightly slower than without obfuscation
     log: false,
     numbersToExpressions: false,
     renameGlobals: false,
-    rotateStringArray: true,
     selfDefending: true,
-    shuffleStringArray: true,
     simplify: true,
     splitStrings: false,
     stringArray: true,
     stringArrayEncoding: [],
     stringArrayIndexShift: true,
+    stringArrayRotate: true,
+    stringArrayShuffle: true,
     stringArrayWrappersCount: 1,
     stringArrayWrappersChainedCalls: true,
     stringArrayWrappersParametersMaxCount: 2,
@@ -1538,14 +1538,14 @@ Performance will slightly slower than without obfuscation
     log: false,
     numbersToExpressions: false,
     renameGlobals: false,
-    rotateStringArray: true,
     selfDefending: false,
-    shuffleStringArray: true,
     simplify: true,
     splitStrings: false,
     stringArray: true,
     stringArrayEncoding: [],
     stringArrayIndexShift: true,
+    stringArrayRotate: true,
+    stringArrayShuffle: true,
     stringArrayWrappersCount: 1,
     stringArrayWrappersChainedCalls: true,
     stringArrayWrappersParametersMaxCount: 2,

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "javascript-obfuscator",
-  "version": "2.19.1",
+  "version": "3.0.0",
   "description": "JavaScript obfuscator",
   "keywords": [
     "obfuscator",

+ 9 - 9
src/cli/JavaScriptObfuscatorCLI.ts

@@ -271,7 +271,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 ArraySanitizer
             )
             .option(
-                '--ignore-require-imports <boolean>', 'Prevents obfuscation of `require` imports',
+                '--ignore-imports <boolean>', 'Prevents obfuscation of `require` and `dynamic` imports',
                 BooleanSanitizer
             )
             .option(
@@ -312,10 +312,6 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 `Values: ${CLIUtils.stringifyOptionAvailableValues(RenamePropertiesMode)}. ` +
                 `Default: ${RenamePropertiesMode.Safe}`
             )
-            .option(
-                '--rotate-string-array <boolean>', 'Enable rotation of string array values during obfuscation',
-                BooleanSanitizer
-            )
             .option(
                 '--seed <string|number>',
                 'Sets seed for random generator. This is useful for creating repeatable results.',
@@ -326,10 +322,6 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 'Disables self-defending for obfuscated code',
                 BooleanSanitizer
             )
-            .option(
-                '--shuffle-string-array <boolean>', 'Randomly shuffles string array items',
-                BooleanSanitizer
-            )
             .option(
                 '--simplify <boolean>', 'Enables additional code obfuscation through simplification',
                 BooleanSanitizer
@@ -393,6 +385,14 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 'Enables additional index shift for all string array calls',
                 BooleanSanitizer
             )
+            .option(
+                '--string-array-rotate <boolean>', 'Enable rotation of string array values during obfuscation',
+                BooleanSanitizer
+            )
+            .option(
+                '--string-array-shuffle <boolean>', 'Randomly shuffles string array items',
+                BooleanSanitizer
+            )
             .option(
                 '--string-array-wrappers-count <number>',
                 'Sets the count of wrappers for the string array inside each root or function scope',

+ 3 - 3
src/container/modules/node-transformers/PreparingTransformersModule.ts

@@ -13,7 +13,7 @@ import { ConditionalCommentObfuscatingGuard } from '../../../node-transformers/p
 import { CustomCodeHelpersTransformer } from '../../../node-transformers/preparing-transformers/CustomCodeHelpersTransformer';
 import { EvalCallExpressionTransformer } from '../../../node-transformers/preparing-transformers/EvalCallExpressionTransformer';
 import { ForceTransformStringObfuscatingGuard } from '../../../node-transformers/preparing-transformers/obfuscating-guards/ForceTransformStringObfuscatingGuard';
-import { IgnoredRequireImportObfuscatingGuard } from '../../../node-transformers/preparing-transformers/obfuscating-guards/IgnoredRequireImportObfuscatingGuard';
+import { IgnoredImportObfuscatingGuard } from '../../../node-transformers/preparing-transformers/obfuscating-guards/IgnoredImportObfuscatingGuard';
 import { MetadataTransformer } from '../../../node-transformers/preparing-transformers/MetadataTransformer';
 import { ObfuscatingGuardsTransformer } from '../../../node-transformers/preparing-transformers/ObfuscatingGuardsTransformer';
 import { ParentificationTransformer } from '../../../node-transformers/preparing-transformers/ParentificationTransformer';
@@ -63,9 +63,9 @@ export const preparingTransformersModule: interfaces.ContainerModule = new Conta
         .whenTargetNamed(ObfuscatingGuard.ForceTransformStringObfuscatingGuard);
 
     bind<IObfuscatingGuard>(ServiceIdentifiers.INodeGuard)
-        .to(IgnoredRequireImportObfuscatingGuard)
+        .to(IgnoredImportObfuscatingGuard)
         .inSingletonScope()
-        .whenTargetNamed(ObfuscatingGuard.IgnoredRequireImportObfuscatingGuard);
+        .whenTargetNamed(ObfuscatingGuard.IgnoredImportObfuscatingGuard);
 
     bind<IObfuscatingGuard>(ServiceIdentifiers.INodeGuard)
         .to(ReservedStringObfuscatingGuard)

+ 1 - 1
src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.ts

@@ -2,6 +2,6 @@ export enum ObfuscatingGuard {
     BlackListObfuscatingGuard = 'BlackListObfuscatingGuard',
     ConditionalCommentObfuscatingGuard = 'ConditionalCommentObfuscatingGuard',
     ForceTransformStringObfuscatingGuard = 'ForceTransformStringObfuscatingGuard',
-    IgnoredRequireImportObfuscatingGuard = 'IgnoredRequireImportObfuscatingGuard',
+    IgnoredImportObfuscatingGuard = 'IgnoredImportObfuscatingGuard',
     ReservedStringObfuscatingGuard = 'ReservedStringObfuscatingGuard'
 }

+ 3 - 3
src/interfaces/options/IOptions.ts

@@ -27,7 +27,7 @@ export interface IOptions {
     readonly identifierNamesGenerator: TTypeFromEnum<typeof IdentifierNamesGenerator>;
     readonly identifiersDictionary: string[];
     readonly identifiersPrefix: string;
-    readonly ignoreRequireImports: boolean;
+    readonly ignoreImports: boolean;
     readonly inputFileName: string;
     readonly log: boolean;
     readonly numbersToExpressions: boolean;
@@ -37,10 +37,8 @@ export interface IOptions {
     readonly renamePropertiesMode: TRenamePropertiesMode;
     readonly reservedNames: string[];
     readonly reservedStrings: string[];
-    readonly rotateStringArray: boolean;
     readonly seed: string | number;
     readonly selfDefending: boolean;
-    readonly shuffleStringArray: boolean;
     readonly simplify: boolean;
     readonly sourceMap: boolean;
     readonly sourceMapBaseUrl: string;
@@ -53,6 +51,8 @@ export interface IOptions {
     readonly stringArrayEncoding: TStringArrayEncoding[];
     readonly stringArrayIndexesType: TStringArrayIndexesType[];
     readonly stringArrayIndexShift: boolean;
+    readonly stringArrayRotate: boolean;
+    readonly stringArrayShuffle: boolean;
     readonly stringArrayWrappersChainedCalls: boolean;
     readonly stringArrayWrappersCount: number;
     readonly stringArrayWrappersParametersMaxCount: number;

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

@@ -31,7 +31,7 @@ export class ObfuscatingGuardsTransformer extends AbstractNodeTransformer {
         ObfuscatingGuard.BlackListObfuscatingGuard,
         ObfuscatingGuard.ConditionalCommentObfuscatingGuard,
         ObfuscatingGuard.ForceTransformStringObfuscatingGuard,
-        ObfuscatingGuard.IgnoredRequireImportObfuscatingGuard,
+        ObfuscatingGuard.IgnoredImportObfuscatingGuard,
         ObfuscatingGuard.ReservedStringObfuscatingGuard
     ];
 

+ 26 - 10
src/node-transformers/preparing-transformers/obfuscating-guards/IgnoredRequireImportObfuscatingGuard.ts → src/node-transformers/preparing-transformers/obfuscating-guards/IgnoredImportObfuscatingGuard.ts

@@ -12,7 +12,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { NodeGuards } from '../../../node/NodeGuards';
 
 @injectable()
-export class IgnoredRequireImportObfuscatingGuard implements IObfuscatingGuard {
+export class IgnoredImportObfuscatingGuard implements IObfuscatingGuard {
     /**
      * @type {IOptions}
      */
@@ -27,20 +27,36 @@ export class IgnoredRequireImportObfuscatingGuard implements IObfuscatingGuard {
         this.options = options;
     }
 
+    /**
+     * @param {Node} node
+     * @returns {boolean}
+     */
+    private static isDynamicImport (node: ESTree.Node): boolean {
+        return NodeGuards.isImportExpressionNode(node);
+    }
+
+    /**
+     * @param {Node} node
+     * @returns {boolean}
+     */
+    private static isRequireImport (node: ESTree.Node): boolean {
+        return NodeGuards.isCallExpressionNode(node)
+            && NodeGuards.isIdentifierNode(node.callee)
+            && node.callee.name === 'require';
+    }
+
     /**
      * @param {Node} node
      * @returns {ObfuscatingGuardResult}
      */
     public check (node: ESTree.Node): ObfuscatingGuardResult {
-        if (this.options.ignoreRequireImports) {
-            if (
-                NodeGuards.isCallExpressionNode(node)
-                && NodeGuards.isIdentifierNode(node.callee)
-                && node.callee.name === 'require'
-            ) { return ObfuscatingGuardResult.Ignore; }
-            if (
-                NodeGuards.isImportExpressionNode(node)
-            ) { return ObfuscatingGuardResult.Ignore; }
+        if (this.options.ignoreImports) {
+            const isIgnoredImport = IgnoredImportObfuscatingGuard.isDynamicImport(node)
+                || IgnoredImportObfuscatingGuard.isRequireImport(node);
+
+            if (isIgnoredImport) {
+                return ObfuscatingGuardResult.Ignore;
+            }
         }
 
         return ObfuscatingGuardResult.Transform;

+ 1 - 1
src/node-transformers/string-array-transformers/StringArrayRotateFunctionTransformer.ts

@@ -136,7 +136,7 @@ export class StringArrayRotateFunctionTransformer extends AbstractNodeTransforme
      * @returns {IVisitor | null}
      */
     public getVisitor (nodeTransformationStage: NodeTransformationStage): IVisitor | null {
-        if (!this.options.rotateStringArray) {
+        if (!this.options.stringArrayRotate) {
             return null;
         }
 

+ 2 - 2
src/node-transformers/string-array-transformers/StringArrayTransformer.ts

@@ -162,11 +162,11 @@ export class StringArrayTransformer extends AbstractNodeTransformer {
             this.stringArrayStorageAnalyzer.analyze(programNode);
         }
 
-        if (this.options.shuffleStringArray) {
+        if (this.options.stringArrayShuffle) {
             this.stringArrayStorage.shuffleStorage();
         }
 
-        if (this.options.rotateStringArray) {
+        if (this.options.stringArrayRotate) {
             this.stringArrayStorage.rotateStorage();
         }
     }

+ 13 - 13
src/options/Options.ts

@@ -191,7 +191,7 @@ export class Options implements IOptions {
      * @type {boolean}
      */
     @IsBoolean()
-    public readonly ignoreRequireImports!: boolean;
+    public readonly ignoreImports!: boolean;
 
     /**
      * @type {string}
@@ -260,24 +260,12 @@ export class Options implements IOptions {
     })
     public readonly reservedStrings!: string[];
 
-    /**
-     * @type {boolean}
-     */
-    @IsBoolean()
-    public readonly rotateStringArray!: boolean;
-
     /**
      * @type {boolean}
      */
     @IsBoolean()
     public readonly selfDefending!: boolean;
 
-    /**
-     * @type {boolean}
-     */
-    @IsBoolean()
-    public readonly shuffleStringArray!: boolean;
-
     /**
      * @type {boolean}
      */
@@ -363,6 +351,18 @@ export class Options implements IOptions {
     @IsBoolean()
     public readonly stringArrayIndexShift!: boolean;
 
+    /**
+     * @type {boolean}
+     */
+    @IsBoolean()
+    public readonly stringArrayRotate!: boolean;
+
+    /**
+     * @type {boolean}
+     */
+    @IsBoolean()
+    public readonly stringArrayShuffle!: boolean;
+
     /**
      * @type {boolean}
      */

+ 2 - 2
src/options/normalizer-rules/StringArrayRule.ts

@@ -12,13 +12,13 @@ export const StringArrayRule: TOptionsNormalizerRule = (options: IOptions): IOpt
     if (!options.stringArray) {
         options = {
             ...options,
-            rotateStringArray: false,
-            shuffleStringArray: false,
             stringArray: false,
             stringArrayEncoding: [
                 StringArrayEncoding.None
             ],
             stringArrayIndexShift: false,
+            stringArrayRotate: false,
+            stringArrayShuffle: false,
             stringArrayWrappersChainedCalls: false,
             stringArrayWrappersCount: 0,
             stringArrayThreshold: 0

+ 3 - 3
src/options/presets/Default.ts

@@ -28,7 +28,7 @@ export const DEFAULT_PRESET: TInputOptions = Object.freeze({
     identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
     identifiersPrefix: '',
     identifiersDictionary: [],
-    ignoreRequireImports: false,
+    ignoreImports: false,
     inputFileName: '',
     log: false,
     numbersToExpressions: false,
@@ -38,10 +38,10 @@ export const DEFAULT_PRESET: TInputOptions = Object.freeze({
     renamePropertiesMode: RenamePropertiesMode.Safe,
     reservedNames: [],
     reservedStrings: [],
-    rotateStringArray: true,
+    stringArrayRotate: true,
     seed: 0,
     selfDefending: false,
-    shuffleStringArray: true,
+    stringArrayShuffle: true,
     simplify: true,
     sourceMap: false,
     sourceMapBaseUrl: '',

+ 2 - 2
src/options/presets/LowObfuscation.ts

@@ -8,8 +8,8 @@ export const LOW_OBFUSCATION_PRESET: TInputOptions = Object.freeze({
     ...DEFAULT_PRESET,
     disableConsoleOutput: true,
     optionsPreset: OptionsPreset.LowObfuscation,
-    rotateStringArray: true,
+    stringArrayRotate: true,
     selfDefending: true,
-    shuffleStringArray: true,
+    stringArrayShuffle: true,
     simplify: true
 });

+ 3 - 3
src/options/presets/NoCustomNodes.ts

@@ -25,7 +25,7 @@ export const NO_ADDITIONAL_NODES_PRESET: TInputOptions = Object.freeze({
     identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
     identifiersPrefix: '',
     identifiersDictionary: [],
-    ignoreRequireImports: false,
+    ignoreImports: false,
     inputFileName: '',
     log: false,
     numbersToExpressions: false,
@@ -34,10 +34,10 @@ export const NO_ADDITIONAL_NODES_PRESET: TInputOptions = Object.freeze({
     renamePropertiesMode: RenamePropertiesMode.Safe,
     reservedNames: [],
     reservedStrings: [],
-    rotateStringArray: false,
+    stringArrayRotate: false,
     seed: 0,
     selfDefending: false,
-    shuffleStringArray: false,
+    stringArrayShuffle: false,
     simplify: false,
     sourceMap: false,
     sourceMapBaseUrl: '',

+ 1 - 1
src/storages/string-array-transformers/StringArrayStorage.ts

@@ -139,7 +139,7 @@ export class StringArrayStorage extends MapStorage <`${string}-${TStringArrayEnc
                 StringArrayStorage.maximumIndexShiftAmount
             )
             : 0;
-        this.rotationAmount = this.options.rotateStringArray
+        this.rotationAmount = this.options.stringArrayRotate
             ? this.randomGenerator.getRandomInteger(
                 StringArrayStorage.minimumRotationAmount,
                 StringArrayStorage.maximumRotationAmount

+ 4 - 4
test/functional-tests/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.spec.ts

@@ -22,7 +22,7 @@ describe('StringArrayRotateFunctionCodeHelper', () => {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
@@ -44,7 +44,7 @@ describe('StringArrayRotateFunctionCodeHelper', () => {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: false,
+                        stringArrayRotate: false,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
@@ -70,7 +70,7 @@ describe('StringArrayRotateFunctionCodeHelper', () => {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
@@ -97,7 +97,7 @@ describe('StringArrayRotateFunctionCodeHelper', () => {
                 {
                     ...NO_ADDITIONAL_NODES_PRESET,
                     identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
-                    rotateStringArray: true,
+                    stringArrayRotate: true,
                     stringArray: true,
                     stringArrayThreshold: 1
                 }

+ 5 - 5
test/functional-tests/custom-code-helpers/string-array/templates/string-array-rotate-function-template/StringArrayRotateFunctionTemplate.spec.ts

@@ -25,7 +25,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArrayThreshold: 1,
-                        rotateStringArray: true
+                        stringArrayRotate: true
                     }
                 );
 
@@ -55,7 +55,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArrayThreshold: 1,
-                        rotateStringArray: true
+                        stringArrayRotate: true
                     }
                 );
 
@@ -85,7 +85,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArrayThreshold: 1,
-                        rotateStringArray: true
+                        stringArrayRotate: true
                     }
                 );
 
@@ -113,7 +113,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArrayThreshold: 1,
-                        rotateStringArray: true
+                        stringArrayRotate: true
                     }
                 );
 
@@ -141,7 +141,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
                         ...NO_ADDITIONAL_NODES_PRESET,
                         stringArray: true,
                         stringArrayThreshold: 1,
-                        rotateStringArray: true
+                        stringArrayRotate: true
                     }
                 );
 

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

@@ -1272,7 +1272,7 @@ describe('JavaScriptObfuscator', () => {
                         numbersToExpressions: true,
                         simplify: true,
                         renameProperties: true,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         stringArray: true,
                         stringArrayEncoding: [
                             StringArrayEncoding.Base64,
@@ -1406,7 +1406,7 @@ describe('JavaScriptObfuscator', () => {
                 debugProtection: true,
                 debugProtectionInterval: true,
                 disableConsoleOutput: false,
-                rotateStringArray: true,
+                stringArrayRotate: true,
                 selfDefending: true,
                 stringArray: true,
                 stringArrayThreshold: 1,

+ 11 - 10
test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-require-import-obfuscating-guard/IgnoredRequireImportObfuscatingGuard.spec.ts → test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-import-obfuscating-guard/IgnoredImportObfuscatingGuard.spec.ts

@@ -6,13 +6,14 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/preset
 
 import { readFileAsString } from '../../../../../helpers/readFileAsString';
 
-describe('IgnoredRequireImportObfuscatingGuard', () => {
+describe('IgnoredImportObfuscatingGuard', () => {
     describe('check', () => {
-        describe('`ignoreRequireImports` option is enabled', () => {
+        describe('`ignoreImports` option is enabled', () => {
             const obfuscatingGuardRegExp: RegExp = new RegExp(
                 'const foo *= *require\\(\'\\./foo\'\\);.*' +
                 'import _0x(?:[a-f0-9]){4,6} from *\'\\./bar\';.*' +
-                'const baz *= *_0x(?:[a-f0-9]){4,6}\\(0x0\\);'
+                'const baz *= *_0x(?:[a-f0-9]){4,6}\\(0x0\\);.*' +
+                'const bark *= *await import\\(\'\\./bark\'\\);'
             );
 
             let obfuscatedCode: string;
@@ -24,24 +25,24 @@ describe('IgnoredRequireImportObfuscatingGuard', () => {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        ignoreRequireImports: true,
+                        ignoreImports: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
                 ).getObfuscatedCode();
             });
 
-            it('match #1: shouldn\'t obfuscate require import', () => {
+            it('match #1: shouldn\'t obfuscate imports', () => {
                 assert.match(obfuscatedCode, obfuscatingGuardRegExp);
             });
         });
 
-        describe('`ignoreRequireImports` option is disabled', () => {
+        describe('`ignoreImports` option is disabled', () => {
             const obfuscatingGuardRegExp: RegExp = new RegExp(
                 'const foo *= *require\\(_0x(?:[a-f0-9]){4,6}\\(0x0\\)\\);.*' +
                 'import _0x(?:[a-f0-9]){4,6} from *\'\\./bar\';.*' +
-                'const baz *= *_0x(?:[a-f0-9]){4,6}\\(0x1\\);' +
-                'const qux *= *import\\(_0x(?:[a-f0-9]){4,6}\\(0x0\\)\\);.*'
+                'const baz *= *_0x(?:[a-f0-9]){4,6}\\(0x1\\);.*' +
+                'const bark *= *await import\\(_0x(?:[a-f0-9]){4,6}\\(0x2\\)\\);'
             );
 
             let obfuscatedCode: string;
@@ -53,14 +54,14 @@ describe('IgnoredRequireImportObfuscatingGuard', () => {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        ignoreRequireImports: false,
+                        ignoreImports: false,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
                 ).getObfuscatedCode();
             });
 
-            it('match #1: should obfuscate require import', () => {
+            it('match #1: should obfuscate imports', () => {
                 assert.match(obfuscatedCode, obfuscatingGuardRegExp);
             });
         });

+ 1 - 1
test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-require-import-obfuscating-guard/fixtures/base-behaviour.js → test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-import-obfuscating-guard/fixtures/base-behaviour.js

@@ -1,4 +1,4 @@
 const foo = require('./foo');
 import bar from './bar';
 const baz = 'baz';
-const qux = await import('quux')
+const bark = await import('./bark');

+ 8 - 8
test/functional-tests/node-transformers/string-array-transformers/string-array-rotate-function-transformer/StringArrayRotateFunctionTransformer.spec.ts

@@ -31,7 +31,7 @@ describe('StringArrayRotateFunctionTransformer', function () {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
@@ -53,7 +53,7 @@ describe('StringArrayRotateFunctionTransformer', function () {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: false,
+                        stringArrayRotate: false,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
@@ -75,7 +75,7 @@ describe('StringArrayRotateFunctionTransformer', function () {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         stringArray: true,
                         stringArrayThreshold: 0.00001
                     }
@@ -97,7 +97,7 @@ describe('StringArrayRotateFunctionTransformer', function () {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         stringArray: true,
                         stringArrayThreshold: 0
                     }
@@ -119,7 +119,7 @@ describe('StringArrayRotateFunctionTransformer', function () {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         stringArray: true,
                         stringArrayThreshold: 1
                     }
@@ -155,7 +155,7 @@ describe('StringArrayRotateFunctionTransformer', function () {
                             numbersToExpressions: true,
                             simplify: true,
                             renameProperties: true,
-                            rotateStringArray: true,
+                            stringArrayRotate: true,
                             selfDefending: true,
                             splitStrings: true,
                             splitStringsChunkLength: 3,
@@ -227,8 +227,8 @@ describe('StringArrayRotateFunctionTransformer', function () {
                         code,
                         {
                             seed: i,
-                            rotateStringArray: true,
-                            shuffleStringArray: true,
+                            stringArrayRotate: true,
+                            stringArrayShuffle: true,
                             stringArray: true,
                             stringArrayThreshold: 1
                         }

+ 6 - 6
test/functional-tests/node-transformers/string-array-transformers/string-array-transformer/StringArrayTransformer.spec.ts

@@ -233,7 +233,7 @@ describe('StringArrayTransformer', function () {
             });
         });
 
-        describe('Variant #2: `rotateStringArray` option is enabled', () => {
+        describe('Variant #2: `stringArrayRotate` option is enabled', () => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/string-array-index-shift.js');
 
@@ -244,7 +244,7 @@ describe('StringArrayTransformer', function () {
                         stringArray: true,
                         stringArrayThreshold: 1,
                         stringArrayIndexShift: true,
-                        rotateStringArray: true
+                        stringArrayRotate: true
                     }
                 ).getObfuscatedCode();
 
@@ -265,7 +265,7 @@ describe('StringArrayTransformer', function () {
             });
         });
 
-        describe('Variant #3: `shuffleStringArray` option is enabled', () => {
+        describe('Variant #3: `stringArrayShuffle` option is enabled', () => {
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/string-array-index-shift.js');
 
@@ -276,7 +276,7 @@ describe('StringArrayTransformer', function () {
                         stringArray: true,
                         stringArrayThreshold: 1,
                         stringArrayIndexShift: true,
-                        shuffleStringArray: true
+                        stringArrayShuffle: true
                     }
                 ).getObfuscatedCode();
 
@@ -328,8 +328,8 @@ describe('StringArrayTransformer', function () {
                     code,
                     {
                         ...NO_ADDITIONAL_NODES_PRESET,
-                        rotateStringArray: true,
-                        shuffleStringArray: true,
+                        stringArrayRotate: true,
+                        stringArrayShuffle: true,
                         stringArray: true,
                         stringArrayEncoding: [
                             StringArrayEncoding.Rc4

+ 6 - 6
test/functional-tests/options/OptionsNormalizer.spec.ts

@@ -739,26 +739,26 @@ describe('OptionsNormalizer', () => {
             before(() => {
                 optionsPreset = getNormalizedOptions({
                     ...getDefaultOptions(),
-                    shuffleStringArray: true,
                     stringArray: false,
                     stringArrayEncoding: [StringArrayEncoding.Rc4],
                     stringArrayIndexShift: true,
+                    stringArrayRotate: true,
+                    stringArrayShuffle: true,
                     stringArrayWrappersChainedCalls: true,
                     stringArrayWrappersCount: 5,
-                    stringArrayThreshold: 0.5,
-                    rotateStringArray: true
+                    stringArrayThreshold: 0.5
                 });
 
                 expectedOptionsPreset = {
                     ...getDefaultOptions(),
-                    shuffleStringArray: false,
                     stringArray: false,
                     stringArrayEncoding: [StringArrayEncoding.None],
                     stringArrayIndexShift: false,
+                    stringArrayRotate: false,
+                    stringArrayShuffle: false,
                     stringArrayWrappersChainedCalls: false,
                     stringArrayWrappersCount: 0,
-                    stringArrayThreshold: 0,
-                    rotateStringArray: false
+                    stringArrayThreshold: 0
                 };
             });
 

+ 4 - 4
test/functional-tests/storages/string-array-transformers/string-array-storage/StringArrayStorage.spec.ts

@@ -33,7 +33,7 @@ describe('StringArrayStorage', () => {
                        code,
                        {
                            ...NO_ADDITIONAL_NODES_PRESET,
-                           rotateStringArray: true,
+                           stringArrayRotate: true,
                            stringArray: true,
                            stringArrayThreshold: 1
                        }
@@ -100,7 +100,7 @@ describe('StringArrayStorage', () => {
                         code,
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
-                            rotateStringArray: true,
+                            stringArrayRotate: true,
                             stringArray: true,
                             stringArrayThreshold: 1
                         }
@@ -173,7 +173,7 @@ describe('StringArrayStorage', () => {
                         code,
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
-                            shuffleStringArray: true,
+                            stringArrayShuffle: true,
                             stringArray: true,
                             stringArrayThreshold: 1
                         }
@@ -268,7 +268,7 @@ describe('StringArrayStorage', () => {
                         code,
                         {
                             ...NO_ADDITIONAL_NODES_PRESET,
-                            shuffleStringArray: true,
+                            stringArrayShuffle: true,
                             stringArray: true,
                             stringArrayThreshold: 1
                         }

+ 1 - 1
test/index.spec.ts

@@ -108,7 +108,7 @@ import './functional-tests/node-transformers/preparing-transformers/eval-call-ex
 import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec';
 import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec';
 import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/force-transform-string-obfuscating-guard/ForceTransformStringObfuscatingGuard.spec';
-import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-require-import-obfuscating-guard/IgnoredRequireImportObfuscatingGuard.spec';
+import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/ignored-import-obfuscating-guard/IgnoredImportObfuscatingGuard.spec';
 import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/reserved-string-obfuscating-guard/ReservedStringObfuscatingGuard.spec';
 import './functional-tests/node-transformers/preparing-transformers/variable-preserve-transformer/VariablePreserveTransformer.spec';
 import './functional-tests/node-transformers/rename-identifiers-transformers/identifier-replacer/IdentifierReplacer.spec';

+ 2 - 2
test/performance-tests/JavaScriptObfuscatorMemory.spec.ts

@@ -37,9 +37,9 @@ describe('JavaScriptObfuscator memory', function () {
                         identifierNamesGenerator: 'mangled',
                         log: false,
                         renameGlobals: false,
-                        rotateStringArray: true,
+                        stringArrayRotate: true,
                         selfDefending: true,
-                        shuffleStringArray: true,
+                        stringArrayShuffle: true,
                         splitStrings: true,
                         splitStringsChunkLength: 2,
                         stringArray: true,

+ 1 - 1
test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts

@@ -33,7 +33,7 @@ describe('JavaScriptObfuscator runtime eval', function () {
         simplify: true,
         renameProperties: true,
         renamePropertiesMode: RenamePropertiesMode.Unsafe,
-        rotateStringArray: true,
+        stringArrayRotate: true,
         selfDefending: true,
         splitStrings: true,
         splitStringsChunkLength: 3,