Renamed options

This commit is contained in:
sanex
2021-10-17 15:25:29 +03:00
parent faaab45c6a
commit ec1c90a27f
21 changed files with 102 additions and 99 deletions
+8 -8
View File
@@ -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',
+2 -2
View File
@@ -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;
@@ -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;
}
@@ -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();
}
}
+12 -12
View File
@@ -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}
*/
@@ -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
+2 -2
View File
@@ -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
View File
@@ -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
});
+2 -2
View File
@@ -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: '',
@@ -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