mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Tests structure reorganized
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ export class Obfuscator implements IObfuscator {
|
||||
[NodeType.VariableDeclaration, [NodeTransformers.VariableDeclarationTransformer]],
|
||||
[NodeType.LabeledStatement, [NodeTransformers.LabeledStatementTransformer]],
|
||||
[NodeType.TemplateLiteral, [NodeTransformers.TemplateLiteralTransformer]],
|
||||
[NodeType.Literal, [NodeTransformers.LiteralTransformer]]
|
||||
[NodeType.Literal, [NodeTransformers.LiteralTransformer]] // should be latest in the chain of obfuscators
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
+4
-2
@@ -4,6 +4,8 @@ import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResul
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('ConsoleOutputDisableExpressionNode', () => {
|
||||
@@ -11,7 +13,7 @@ describe('ConsoleOutputDisableExpressionNode', () => {
|
||||
|
||||
it('should correctly append `ConsoleOutputDisableExpressionNode` custom node into the obfuscated code if `disableConsoleOutput` option is set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
disableConsoleOutput: true
|
||||
@@ -23,7 +25,7 @@ describe('ConsoleOutputDisableExpressionNode', () => {
|
||||
|
||||
it('should\'t append `ConsoleOutputDisableExpressionNode` custom node into the obfuscated code if `disableConsoleOutput` option is not set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
disableConsoleOutput: false,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
var test = 'test';
|
||||
@@ -4,12 +4,14 @@ import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResul
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('DomainLockNode', () => {
|
||||
it('should correctly append `DomainLockNode` custom node into the obfuscated code if `domainLock` option is set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
domainLock: ['.example.com']
|
||||
@@ -21,7 +23,7 @@ describe('DomainLockNode', () => {
|
||||
|
||||
it('should\'t append `DomainLockNode` custom node into the obfuscated code if `domainLock` option is not set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
domainLock: []
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
var test = 'test';
|
||||
+3
-1
@@ -4,12 +4,14 @@ import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResul
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('StringArrayCallsWrapper', () => {
|
||||
it('should correctly append `StringArrayCallsWrapper` custom node into the obfuscated code', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
|
||||
@@ -4,12 +4,14 @@ import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResul
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('StringArrayNode', () => {
|
||||
it('should correctly append `StringArrayNode` custom node into the obfuscated code if `stringArray` option is set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -22,7 +24,7 @@ describe('StringArrayNode', () => {
|
||||
|
||||
it('should\'t append `StringArrayNode` custom node into the obfuscated code if `stringArray` option is not set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: false
|
||||
|
||||
+4
-2
@@ -4,12 +4,14 @@ import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResul
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('StringArrayRotateFunctionNode', () => {
|
||||
it('should correctly append `StringArrayRotateFunctionNode` custom node into the obfuscated code if `rotateStringArray` option is set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
rotateStringArray: true,
|
||||
@@ -23,7 +25,7 @@ describe('StringArrayRotateFunctionNode', () => {
|
||||
|
||||
it('should\'t append `StringArrayRotateFunctionNode` custom node into the obfuscated code if `rotateStringArray` option is not set', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
rotateStringArray: false,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
var test = 'test';
|
||||
+2
-2
@@ -4,9 +4,9 @@ import * as sinon from 'sinon';
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { StdoutWriteMock } from '../mocks/StdoutWriteMock';
|
||||
import { StdoutWriteMock } from '../../mocks/StdoutWriteMock';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let fixturesDirName: string = 'test/fixtures',
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
import { ServiceIdentifiers } from '../../src/container/ServiceIdentifiers';
|
||||
import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IInversifyContainerFacade } from '../../src/interfaces/container/IInversifyContainerFacade';
|
||||
import { IJavaScriptObfuscator } from '../../src/interfaces/IJavaScriptObfsucator';
|
||||
import { IObfuscationResult } from '../../src/interfaces/IObfuscationResult';
|
||||
import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
|
||||
import { IJavaScriptObfuscator } from '../../../src/interfaces/IJavaScriptObfsucator';
|
||||
import { IObfuscationResult } from '../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { InversifyContainerFacade } from '../../src/container/InversifyContainerFacade';
|
||||
import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
|
||||
|
||||
describe('JavaScriptObfuscatorInternal', () => {
|
||||
describe(`setSourceMapUrl (url: string)`, () => {
|
||||
+16
-15
@@ -2,14 +2,15 @@ import { assert } from 'chai';
|
||||
|
||||
import { Chance } from 'chance';
|
||||
|
||||
import { IObfuscationResult } from '../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../src/JavaScriptObfuscator';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../helpers/readFileAsString';
|
||||
import { RandomGeneratorUtils } from '../../src/utils/RandomGeneratorUtils';
|
||||
import { readFileAsString } from '../../helpers/readFileAsString';
|
||||
|
||||
import { RandomGeneratorUtils } from '../../../src/utils/RandomGeneratorUtils';
|
||||
|
||||
describe('JavaScriptObfuscator', () => {
|
||||
describe('obfuscate (sourceCode: string, customOptions?: IObfuscatorOptions): IObfuscationResult', () => {
|
||||
@@ -20,7 +21,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
describe('if `sourceMap` option is `false`', () => {
|
||||
it('should returns object with obfuscated code and empty source map', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 1;`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -34,7 +35,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
describe('if `sourceMap` option is `true`', () => {
|
||||
it('should returns object with obfuscated code and source map', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 1;`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
sourceMap: true
|
||||
@@ -47,7 +48,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
|
||||
it('should returns object with obfuscated code with inline source map as Base64 string', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 1;`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
sourceMap: true,
|
||||
@@ -65,7 +66,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
|
||||
it('should returns object with empty obfuscated code and source map with empty data if source code is empty', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
readFileAsString(__dirname + '/fixtures/empty-input.js'),
|
||||
{
|
||||
sourceMap: true
|
||||
}
|
||||
@@ -81,7 +82,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
it('should returns an empty string if source code is empty', () => {
|
||||
assert.isNotOk(
|
||||
JavaScriptObfuscator.obfuscate(
|
||||
''
|
||||
readFileAsString(__dirname + '/fixtures/empty-input.js'),
|
||||
).getObfuscatedCode()
|
||||
);
|
||||
});
|
||||
@@ -89,7 +90,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
it('should returns an empty string if source code contains only comments', () => {
|
||||
assert.isNotOk(
|
||||
JavaScriptObfuscator.obfuscate(
|
||||
'// comment'
|
||||
readFileAsString(__dirname + '/fixtures/comments-only.js'),
|
||||
).getObfuscatedCode()
|
||||
);
|
||||
});
|
||||
@@ -97,7 +98,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
it('should obfuscate simple code with variable inside global scope', () => {
|
||||
assert.match(
|
||||
JavaScriptObfuscator.obfuscate(
|
||||
`var test = 1;`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -109,7 +110,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
it('should obfuscate simple code with variable inside block-scope', () => {
|
||||
assert.match(
|
||||
JavaScriptObfuscator.obfuscate(
|
||||
`(function () {var test = 1;})()`,
|
||||
readFileAsString(__dirname + '/fixtures/block-scope.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -122,7 +123,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
let pattern1: RegExp = /^var _0x(\w){4} *= *\['(\\[x|u]\d+)+'\];/,
|
||||
pattern2: RegExp = /var *test *= *_0x(\w){4}\('0x0'\);$/,
|
||||
obfuscatedCode1: string = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'abc';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -130,7 +131,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
}
|
||||
).getObfuscatedCode(),
|
||||
obfuscatedCode2: string = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'абц';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input-cyrillic.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -0,0 +1 @@
|
||||
(function () {var test = 1;})()
|
||||
@@ -0,0 +1 @@
|
||||
// comment
|
||||
@@ -0,0 +1 @@
|
||||
var test = 1;
|
||||
@@ -0,0 +1 @@
|
||||
var test = 'abc';
|
||||
@@ -0,0 +1 @@
|
||||
var test = 'абц';
|
||||
+13
-31
@@ -1,20 +1,18 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('BlockStatementControlFlowTransformer', () => {
|
||||
describe('transformNode (blockStatementNode: ESTree.BlockStatement): ESTree.Node', () => {
|
||||
describe('variant #1: 5 simple statements', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -59,9 +57,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #2: 5 simple statements inside while loop without break or continue statement', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-2.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -106,9 +102,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #3: less then 5 statements', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-one-statement.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/one-statement.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -126,9 +120,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #4: const declaration inside block statement', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-const-declaration.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/const-declaration.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -146,9 +138,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #5: let declaration inside block statement', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-let-declaration.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/let-declaration.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -166,9 +156,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #6: break statement inside block statement', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-break-statement.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/break-statement.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -186,9 +174,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #7: continue statement inside block statement', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-continue-statement.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/continue-statement.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -206,9 +192,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #8: function declaration inside block statement', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-function-declaration.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/function-declaration.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -229,9 +213,7 @@ describe('BlockStatementControlFlowTransformer', () => {
|
||||
const controlFlowFlatteningThreshold: number = 0.5;
|
||||
const delta: number = 0.1;
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/block-statement-control-flow-transformer-1.js'
|
||||
).repeat(samples),
|
||||
readFileAsString(__dirname + '/fixtures/input-1.js').repeat(samples),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
+8
-12
@@ -1,20 +1,18 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('BinaryExpressionControlFlowReplacer', () => {
|
||||
describe('replace (binaryExpressionNode: ESTree.BinaryExpression,parentNode: ESTree.Node,controlFlowStorage: IStorage <ICustomNode>)', () => {
|
||||
describe('variant #1 - single binary expression', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -31,9 +29,9 @@ describe('BinaryExpressionControlFlowReplacer', () => {
|
||||
|
||||
describe('variant #2 - multiple binary expressions with threshold = 1', () => {
|
||||
it('should replace binary expression node by call to control flow storage node', function () {
|
||||
this.timeout(4000);
|
||||
this.timeout(15000);
|
||||
|
||||
const samplesCount: number = 200;
|
||||
const samplesCount: number = 1000;
|
||||
const expectedValue: number = 0.5;
|
||||
const delta: number = 0.1;
|
||||
|
||||
@@ -41,9 +39,7 @@ describe('BinaryExpressionControlFlowReplacer', () => {
|
||||
|
||||
for (let i = 0; i < samplesCount; i++) {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer-2.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
+9
-15
@@ -1,20 +1,18 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('CallExpressionControlFlowReplacer', () => {
|
||||
describe('replace (callExpressionNode: ESTree.CallExpression,parentNode: ESTree.Node,controlFlowStorage: IStorage <ICustomNode>)', () => {
|
||||
describe('variant #1 - single call expression', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -31,9 +29,9 @@ describe('CallExpressionControlFlowReplacer', () => {
|
||||
|
||||
describe('variant #2 - multiple call expressions with threshold = 1', () => {
|
||||
it('should replace call expression node by call to control flow storage node', function () {
|
||||
this.timeout(4000);
|
||||
this.timeout(15000);
|
||||
|
||||
const samplesCount: number = 200;
|
||||
const samplesCount: number = 1000;
|
||||
const expectedValue: number = 0.5;
|
||||
const delta: number = 0.1;
|
||||
|
||||
@@ -41,9 +39,7 @@ describe('CallExpressionControlFlowReplacer', () => {
|
||||
|
||||
for (let i = 0; i < samplesCount; i++) {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer-2.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -76,9 +72,7 @@ describe('CallExpressionControlFlowReplacer', () => {
|
||||
|
||||
describe('variant #3 - callee - member expression', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer-3.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-3.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
+10
-18
@@ -1,20 +1,18 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('LogicalExpressionControlFlowReplacer', () => {
|
||||
describe('replace (logicalExpressionNode: ESTree.LogicalExpression,parentNode: ESTree.Node,controlFlowStorage: IStorage <ICustomNode>)', () => {
|
||||
describe('variant #1 - single logical expression', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -31,9 +29,9 @@ describe('LogicalExpressionControlFlowReplacer', () => {
|
||||
|
||||
describe('variant #2 - multiple logical expressions with threshold = 1', () => {
|
||||
it('should replace logical expression node by call to control flow storage node', function () {
|
||||
this.timeout(4000);
|
||||
this.timeout(15000);
|
||||
|
||||
const samplesCount: number = 200;
|
||||
const samplesCount: number = 1000;
|
||||
const expectedValue: number = 0.5;
|
||||
const delta: number = 0.1;
|
||||
|
||||
@@ -41,9 +39,7 @@ describe('LogicalExpressionControlFlowReplacer', () => {
|
||||
|
||||
for (let i = 0; i < samplesCount; i++) {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer-2.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -76,9 +72,7 @@ describe('LogicalExpressionControlFlowReplacer', () => {
|
||||
|
||||
describe('variant #3 - single logical expression with unary expression', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer-3.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-3.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -95,9 +89,7 @@ describe('LogicalExpressionControlFlowReplacer', () => {
|
||||
|
||||
describe('prohibited nodes variant #1', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer-prohibited-nodes-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/prohibited-nodes.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
+11
-23
@@ -1,12 +1,12 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('FunctionControlFlowTransformer', () => {
|
||||
const variableMatch: string = '_0x([a-z0-9]){4,6}';
|
||||
@@ -28,9 +28,7 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
describe('transformNode (functionNode: ESTree.Function): ESTree.Node', () => {
|
||||
describe('variant #1 - single `control flow storage` node with single item', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/function-control-flow-transformer-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -46,7 +44,7 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
});
|
||||
|
||||
describe('variant #2 - two `control flow storage` nodes: root and inner', () => {
|
||||
const samplesCount: number = 200;
|
||||
const samplesCount: number = 1000;
|
||||
const delta: number = 0.1;
|
||||
const expectedValue: number = 0.5;
|
||||
const regExp1: RegExp = new RegExp(
|
||||
@@ -62,9 +60,7 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
|
||||
for (let i = 0; i < samplesCount; i++) {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/function-control-flow-transformer-2.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -89,9 +85,7 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #3 - single `control flow storage` node with multiple items', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/function-control-flow-transformer-multiple-items-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/multiple-items.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -117,9 +111,7 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #4 - no `control flow storage` node to the root block scope', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/function-control-flow-transformer-root-block-scope-1.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/root-block-scope-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -150,9 +142,7 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
|
||||
for (let i = 0; i < samplesCount; i++) {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/function-control-flow-transformer-root-block-scope-2.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/root-block-scope-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
@@ -172,9 +162,7 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
|
||||
describe('variant #6 - no single `control flow storage` node when threshold is 0', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/control-flow-transformers/function-control-flow-transformer-zero-threshold.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/zero-threshold.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
+6
-8
@@ -1,19 +1,17 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('CatchClauseTransformer', () => {
|
||||
describe('changeControlFlow (catchClauseNode: ESTree.CatchClause): void', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/obfuscation-transformers/catch-clause-transformer.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -22,7 +20,7 @@ describe('CatchClauseTransformer', () => {
|
||||
const paramNameRegExp: RegExp = /catch *\((_0x([a-z0-9]){4,6})\) *\{/;
|
||||
const bodyParamNameRegExp: RegExp = /console\['\\x6c\\x6f\\x67'\]\((_0x([a-z0-9]){4,6})\);/;
|
||||
|
||||
it('should obfuscate catch clause node', () => {
|
||||
it('should transform catch clause node', () => {
|
||||
assert.match(obfuscatedCode, paramNameRegExp);
|
||||
assert.match(obfuscatedCode, bodyParamNameRegExp);
|
||||
});
|
||||
+9
-20
@@ -1,35 +1,24 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('FunctionDeclarationTransformer', () => {
|
||||
describe('obfuscation of `functionDeclaration` node names', () => {
|
||||
describe('transformation of `functionDeclaration` node names', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
function foo () {
|
||||
function bar () {
|
||||
}
|
||||
|
||||
if (true) {
|
||||
bar();
|
||||
}
|
||||
}
|
||||
|
||||
if (true) {
|
||||
foo();
|
||||
}
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
|
||||
|
||||
it('shouldn\'t obfuscate function name if `functionDeclaration` parent block scope is a `ProgramNode`', () => {
|
||||
it('shouldn\'t transform function name if `functionDeclaration` parent block scope is a `ProgramNode`', () => {
|
||||
const functionNameIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
|
||||
.match(/function *foo *\(\) *\{/);
|
||||
const functionCallIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
|
||||
@@ -41,7 +30,7 @@ describe('FunctionDeclarationTransformer', () => {
|
||||
assert.equal(functionParamIdentifierName, functionBodyIdentifierName);
|
||||
});
|
||||
|
||||
it('should obfuscate function name if `functionDeclaration` parent block scope is not a `ProgramNode`', () => {
|
||||
it('should transform function name if `functionDeclaration` parent block scope is not a `ProgramNode`', () => {
|
||||
const functionNameIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
|
||||
.match(/function *_0x[a-z0-9]{4,6} *\(\) *\{/);
|
||||
const functionCallIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
function foo () {
|
||||
function bar () {
|
||||
}
|
||||
|
||||
if (true) {
|
||||
bar();
|
||||
}
|
||||
}
|
||||
|
||||
if (true) {
|
||||
foo();
|
||||
}
|
||||
+9
-21
@@ -1,36 +1,24 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('FunctionTransformer', () => {
|
||||
describe('identifiers obfuscation inside `FunctionDeclaration` and `FunctionExpression` node body', () => {
|
||||
describe('identifiers transformation inside `FunctionDeclaration` and `FunctionExpression` node body', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function () {
|
||||
var test = function (test) {
|
||||
console.log(test);
|
||||
|
||||
if (true) {
|
||||
var test = 5
|
||||
}
|
||||
|
||||
variable = 6;
|
||||
|
||||
return test;
|
||||
}
|
||||
})();
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
|
||||
|
||||
it('should correct obfuscate both function parameter identifier and function body identifier with same name', () => {
|
||||
it('should correct transform both function parameter identifier and function body identifier with same name', () => {
|
||||
const functionParamIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
|
||||
.match(/var _0x[a-z0-9]{4,6} *= *function *\((_0x[a-z0-9]{4,6})\) *\{/);
|
||||
const functionBodyIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
|
||||
@@ -42,7 +30,7 @@ describe('FunctionTransformer', () => {
|
||||
assert.equal(functionParamIdentifierName, functionBodyIdentifierName);
|
||||
});
|
||||
|
||||
it('shouldn\'t obfuscate other variables in function body', () => {
|
||||
it('shouldn\'t transform other variables in function body', () => {
|
||||
assert.equal(/variable *= *0x6;/.test(obfuscatedCode), true);
|
||||
});
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
(function () {
|
||||
var test = function (test) {
|
||||
console.log(test);
|
||||
|
||||
if (true) {
|
||||
var test = 5
|
||||
}
|
||||
|
||||
variable = 6;
|
||||
|
||||
return test;
|
||||
}
|
||||
})();
|
||||
+8
-10
@@ -1,19 +1,17 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('LabeledStatementTransformer', () => {
|
||||
describe('changeControlFlow (labeledStatementNode: ESTree.LabeledStatement): void', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/obfuscation-transformers/labeled-statement-transformer.js'
|
||||
),
|
||||
readFileAsString(__dirname + '/fixtures/input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -23,15 +21,15 @@ describe('LabeledStatementTransformer', () => {
|
||||
const continueStatementRegExp: RegExp = /continue *(_0x([a-z0-9]){4,6});/;
|
||||
const breakStatementRegExp: RegExp = /break *(_0x([a-z0-9]){4,6});/;
|
||||
|
||||
it('should obfuscate `labeledStatement` identifier', () => {
|
||||
it('should transform `labeledStatement` identifier', () => {
|
||||
assert.match(obfuscatedCode, labeledStatementRegExp);
|
||||
});
|
||||
|
||||
it('should obfuscate `continueStatement` identifier', () => {
|
||||
it('should transform `continueStatement` identifier', () => {
|
||||
assert.match(obfuscatedCode, continueStatementRegExp);
|
||||
});
|
||||
|
||||
it('should obfuscate `breakStatement` identifier', () => {
|
||||
it('should transform `breakStatement` identifier', () => {
|
||||
assert.match(obfuscatedCode, breakStatementRegExp);
|
||||
});
|
||||
|
||||
+19
-23
@@ -1,18 +1,18 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('LiteralTransformer', () => {
|
||||
describe('obfuscation of literal node with string value', () => {
|
||||
describe('transformation of literal node with string value', () => {
|
||||
it('should replace literal node value with unicode escape sequence', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -23,7 +23,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('should replace literal node value with unicode escape sequence from string array', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -40,11 +40,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('should create only one item in string array for same literal node values', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
var test = 'test';
|
||||
var test = 'test';
|
||||
object.test();
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/same-literal-values.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -61,7 +57,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('should replace literal node value with raw value from string array if `unicodeEscapeSequence` is disabled', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -79,7 +75,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('should replace literal node value with raw value from string array if `unicodeEscapeSequence` and `stringArray` are disabled', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
unicodeEscapeSequence: false
|
||||
@@ -94,7 +90,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('should\'t throw an error when string contains non-latin and non-digit characters and `unicodeEscapeSequence` is disabled', () => {
|
||||
assert.doesNotThrow(() => JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString('./test/fixtures/node-transformers/obfuscation-transformers/literal-transformer-unicode-sequence.js'),
|
||||
readFileAsString(__dirname + '/fixtures/error-when-non-latin.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -106,7 +102,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('shouldn\'t replace short literal node value with value from string array', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'te';`,
|
||||
readFileAsString(__dirname + '/fixtures/short-literal-value.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -119,7 +115,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('should replace literal node value with value from string array encoded using base64', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -137,7 +133,7 @@ describe('LiteralTransformer', () => {
|
||||
|
||||
it('should replace literal node value with value from string array encoded using rc4', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -157,7 +153,7 @@ describe('LiteralTransformer', () => {
|
||||
const stringArrayThreshold: number = 0.5;
|
||||
const delta: number = 0.1;
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 'test';\n`.repeat(samples),
|
||||
`${readFileAsString(__dirname + '/fixtures/simple-input.js')}\n`.repeat(samples),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -175,9 +171,9 @@ describe('LiteralTransformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should obfuscate literal node with boolean value', () => {
|
||||
it('should transform literal node with boolean value', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = true;`,
|
||||
readFileAsString(__dirname + '/fixtures/boolean-value.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -188,9 +184,9 @@ describe('LiteralTransformer', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /^var *test *= *!!\[\];$/);
|
||||
});
|
||||
|
||||
it('should obfuscate literal node with number value', () => {
|
||||
it('should transform literal node with number value', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = 0;`,
|
||||
readFileAsString(__dirname + '/fixtures/number-value.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = true;
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = 0;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
var test = 'test';
|
||||
var test = 'test';
|
||||
object.test();
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = 'te';
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = 'test';
|
||||
+11
-12
@@ -1,16 +1,18 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('MemberExpressionTransformer', () => {
|
||||
describe('obfuscation of member expression node with dot notation', () => {
|
||||
describe('transformation of member expression node with dot notation', () => {
|
||||
it('should replace member expression dot notation call by square brackets call with unicode literal value', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = console.log;`,
|
||||
readFileAsString(__dirname + '/fixtures/dot-notation-call.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -21,7 +23,7 @@ describe('MemberExpressionTransformer', () => {
|
||||
|
||||
it('should replace member expression dot notation call by square brackets call to unicode array', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = console.log;`,
|
||||
readFileAsString(__dirname + '/fixtures/dot-notation-call.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -34,10 +36,10 @@ describe('MemberExpressionTransformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('obfuscation of member expression node without dot notation', () => {
|
||||
describe('transformation of member expression node without dot notation', () => {
|
||||
it('should replace member expression square brackets call by square brackets call to unicode array', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = console['log'];`,
|
||||
readFileAsString(__dirname + '/fixtures/square-brackets-call.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
@@ -51,10 +53,7 @@ describe('MemberExpressionTransformer', () => {
|
||||
|
||||
it('should ignore square brackets call with identifier value', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
var identifier = 'log';
|
||||
var test = console[identifier];
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/square-brackets-with-identifier-call.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = console.log;
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = console['log'];
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
var identifier = 'log';
|
||||
var test = console[identifier];
|
||||
+7
-10
@@ -1,18 +1,15 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('MethodDefinitionTransformer', () => {
|
||||
let code: string = `
|
||||
class Foo {
|
||||
constructor () {}
|
||||
bar () {}
|
||||
}
|
||||
`;
|
||||
let code: string = readFileAsString(__dirname + '/fixtures/input.js');
|
||||
|
||||
it('should replace method definition node `key` property with unicode value', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
@@ -39,7 +36,7 @@ describe('MethodDefinitionTransformer', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /\[_0x([a-z0-9]){4}\('0x0'\)\]\(\)\{\}/);
|
||||
});
|
||||
|
||||
it('should not obfuscate method definition node with `constructor` key', () => {
|
||||
it('should not transform method definition node with `constructor` key', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
constructor () {}
|
||||
bar () {}
|
||||
}
|
||||
+8
-32
@@ -1,15 +1,17 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('ObjectExpressionTransformer', () => {
|
||||
it('should replace object expression node `key` property with literal value by unicode value', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = { 'foo': 0 };`,
|
||||
readFileAsString(__dirname + '/fixtures/property-with-literal-value.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -20,7 +22,7 @@ describe('ObjectExpressionTransformer', () => {
|
||||
|
||||
it('should replace object expression node `key` property with identifier value by unicode value', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`var test = { foo: 0 };`,
|
||||
readFileAsString(__dirname + '/fixtures/property-with-identifier-value.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -31,33 +33,7 @@ describe('ObjectExpressionTransformer', () => {
|
||||
|
||||
it('should correct convert shorthand ES6 object expression to non-shorthand object expression', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function () {
|
||||
let a = 0;
|
||||
let b = 0;
|
||||
var test = {a, b};
|
||||
})();
|
||||
`,
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
|
||||
assert.match(
|
||||
obfuscationResult.getObfuscatedCode(),
|
||||
/var *_0x[a-z0-9]{4,6} *= *\{'\\x61': *_0x[a-z0-9]{4,6}\, *'\\x62': *_0x[a-z0-9]{4,6}\};/
|
||||
);
|
||||
});
|
||||
|
||||
it('should correct convert shorthand ES6 object expression to non-shorthand object expression', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function () {
|
||||
let a = 0;
|
||||
let b = 0;
|
||||
var test = {a, b};
|
||||
})();
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/shorthand-object-expression.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = { foo: 0 };
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = { 'foo': 0 };
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
(function () {
|
||||
let a = 0;
|
||||
let b = 0;
|
||||
var test = {a, b};
|
||||
})();
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('TemplateLiteralTransformer', () => {
|
||||
describe('variant #1: simple template literal', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(__dirname + '/fixtures/simple-input.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
unicodeEscapeSequence: false
|
||||
}
|
||||
);
|
||||
|
||||
it('should transform es6 template literal to es5', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /^var *test *= *'abc\\x20' *\+ *foo;$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #1: simple template literal with expression only', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(__dirname + '/fixtures/expression-only.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
unicodeEscapeSequence: false
|
||||
}
|
||||
);
|
||||
|
||||
it('should transform es6 template literal to es5 and add empty literal node before expression node', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /^var *test *= *'' *\+ *foo;$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #3: literal node inside expression', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(__dirname + '/fixtures/literal-inside-expression.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
unicodeEscapeSequence: false
|
||||
}
|
||||
);
|
||||
|
||||
it('should transform es6 template literal to es5', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /^var *test *= *'abc';$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #4: multiple expressions', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(__dirname + '/fixtures/multiple-expressions.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
unicodeEscapeSequence: false
|
||||
}
|
||||
);
|
||||
|
||||
it('should transform es6 template literal to es5', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /^var *test *= *0x1 *\+ *0x1 *\+ *'\\x20abc\\x20' *\+ *\(0x1 *\+ *0x1\);$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = `${foo}`;
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = `${'abc'}`;
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = `${1 + 1} abc ${1 + 1}`;
|
||||
+1
@@ -0,0 +1 @@
|
||||
var test = `abc ${foo}`;
|
||||
+20
-92
@@ -1,20 +1,17 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
|
||||
import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('VariableDeclarationTransformer', () => {
|
||||
it('should obfuscate `variableDeclaration` node', () => {
|
||||
it('should transform `variableDeclaration` node', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
function foo () {
|
||||
var test = 'abc';
|
||||
console.log(test);
|
||||
}
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/simple-declaration.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -24,15 +21,9 @@ describe('VariableDeclarationTransformer', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){4,6}\);/);
|
||||
});
|
||||
|
||||
it('should not obfuscate `variableDeclaration` node if parent block scope node is `Program` node', () => {
|
||||
it('should not transform `variableDeclaration` node if parent block scope node is `Program` node', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
if (true) {
|
||||
var test = 10;
|
||||
}
|
||||
|
||||
console.log(test);
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/parent-block-scope-is-program-node.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -42,17 +33,9 @@ describe('VariableDeclarationTransformer', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(test\);/);
|
||||
});
|
||||
|
||||
it('should obfuscate variable call (`identifier` node) outside of block scope of node in which this variable was declared with `var` kind', () => {
|
||||
it('should transform variable call (`identifier` node) outside of block scope of node in which this variable was declared with `var` kind', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function () {
|
||||
if (true) {
|
||||
var test = 10;
|
||||
}
|
||||
|
||||
console.log(test);
|
||||
})();
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/var-kind.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -61,17 +44,9 @@ describe('VariableDeclarationTransformer', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){4,6}\);/);
|
||||
});
|
||||
|
||||
it('should not obfuscate variable call (`identifier` node) outside of block scope of node in which this variable was declared with `let` kind', () => {
|
||||
it('should not transform variable call (`identifier` node) outside of block scope of node in which this variable was declared with `let` kind', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function () {
|
||||
if (true) {
|
||||
let test = 10;
|
||||
}
|
||||
|
||||
console.log(test);
|
||||
})();
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/let-kind.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -85,31 +60,18 @@ describe('VariableDeclarationTransformer', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
obfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
function foo () {
|
||||
function bar () {
|
||||
console.log(abc.item);
|
||||
}
|
||||
|
||||
console.log(abc);
|
||||
|
||||
var abc = {};
|
||||
|
||||
abc.item = 15;
|
||||
bar();
|
||||
}
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-1.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should obfuscate variable call (`identifier` node) before variable declaration if this call is inside function body', () => {
|
||||
it('should transform variable call (`identifier` node) before variable declaration if this call is inside function body', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){4,6}\['\\x69\\x74\\x65\\x6d'\]\);/);
|
||||
});
|
||||
|
||||
it('should not obfuscate variable call (`identifier` node) before variable declaration', () => {
|
||||
it('should not transform variable call (`identifier` node) before variable declaration', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){4,6}\);/);
|
||||
});
|
||||
});
|
||||
@@ -124,27 +86,14 @@ describe('VariableDeclarationTransformer', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
obfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function () {
|
||||
function foo (t, e) {
|
||||
return function () {
|
||||
function baz (t) {
|
||||
console.log(t);
|
||||
}
|
||||
|
||||
return {t: t};
|
||||
var t;
|
||||
}();
|
||||
}
|
||||
})();
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/variable-call-before-variable-declaration-2.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should correct obfuscate variables inside function body', () => {
|
||||
it('should correct transform variables inside function body', () => {
|
||||
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
|
||||
const functionParamIdentifierMatch: RegExpMatchArray|null = obfuscatedCode
|
||||
.match(/function *_0x[a-z0-9]{4,6} *\((_0x[a-z0-9]{4,6})\,(_0x[a-z0-9]{4,6})\) *\{/);
|
||||
@@ -177,17 +126,7 @@ describe('VariableDeclarationTransformer', () => {
|
||||
describe('wrong replacement', () => {
|
||||
it('shouldn\'t replace property node identifier', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
function foo () {
|
||||
var test = 'abc';
|
||||
|
||||
var object = {
|
||||
test: 'cde'
|
||||
};
|
||||
|
||||
console.log(test);
|
||||
}
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/property-identifier.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
@@ -198,18 +137,7 @@ describe('VariableDeclarationTransformer', () => {
|
||||
|
||||
it('shouldn\'t replace computed member expression identifier', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
function foo () {
|
||||
var test = 'abc';
|
||||
|
||||
var object = {
|
||||
'test': 'cde'
|
||||
};
|
||||
|
||||
console.log(test);
|
||||
console.log(object.test);
|
||||
}
|
||||
`,
|
||||
readFileAsString(__dirname + '/fixtures/member-expression-identifier.js'),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
(function () {
|
||||
if (true) {
|
||||
let test = 10;
|
||||
}
|
||||
|
||||
console.log(test);
|
||||
})();
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
function foo () {
|
||||
var test = 'abc';
|
||||
|
||||
var object = {
|
||||
'test': 'cde'
|
||||
};
|
||||
|
||||
console.log(test);
|
||||
console.log(object.test);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
if (true) {
|
||||
var test = 10;
|
||||
}
|
||||
|
||||
console.log(test);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function foo () {
|
||||
var test = 'abc';
|
||||
|
||||
var object = {
|
||||
test: 'cde'
|
||||
};
|
||||
|
||||
console.log(test);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
function foo () {
|
||||
var test = 'abc';
|
||||
console.log(test);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
(function () {
|
||||
if (true) {
|
||||
var test = 10;
|
||||
}
|
||||
|
||||
console.log(test);
|
||||
})();
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
function foo () {
|
||||
function bar () {
|
||||
console.log(abc.item);
|
||||
}
|
||||
|
||||
console.log(abc);
|
||||
|
||||
var abc = {};
|
||||
|
||||
abc.item = 15;
|
||||
bar();
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
(function () {
|
||||
function foo (t, e) {
|
||||
return function () {
|
||||
function baz (t) {
|
||||
console.log(t);
|
||||
}
|
||||
|
||||
return {t: t};
|
||||
var t;
|
||||
}();
|
||||
}
|
||||
})();
|
||||
+20
-20
@@ -1,22 +1,22 @@
|
||||
import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
|
||||
import { ServiceIdentifiers } from '../../../../src/container/ServiceIdentifiers';
|
||||
|
||||
import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { TNodeWithBlockStatement } from '../../../src/types/node/TNodeWithBlockStatement';
|
||||
import { TNodeWithBlockStatement } from '../../../../src/types/node/TNodeWithBlockStatement';
|
||||
|
||||
import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
|
||||
import { IStackTraceAnalyzer } from '../../../src/interfaces/stack-trace-analyzer/IStackTraceAnalyzer';
|
||||
import { IStackTraceData } from '../../../src/interfaces/stack-trace-analyzer/IStackTraceData';
|
||||
import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
|
||||
import { IStackTraceAnalyzer } from '../../../../src/interfaces/stack-trace-analyzer/IStackTraceAnalyzer';
|
||||
import { IStackTraceData } from '../../../../src/interfaces/stack-trace-analyzer/IStackTraceData';
|
||||
|
||||
import { readFileAsString } from '../../helpers/readFileAsString';
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
|
||||
import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
|
||||
import { Node } from '../../../src/node/Node';
|
||||
import { Nodes } from '../../../src/node/Nodes';
|
||||
import { NodeUtils } from '../../../src/node/NodeUtils';
|
||||
import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade';
|
||||
import { Node } from '../../../../src/node/Node';
|
||||
import { Nodes } from '../../../../src/node/Nodes';
|
||||
import { NodeUtils } from '../../../../src/node/NodeUtils';
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
@@ -159,7 +159,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #1: basic-1', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/basic-1.js')
|
||||
readFileAsString(__dirname + '/fixtures/basic-1.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -206,7 +206,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #2: basic-2', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/basic-2.js')
|
||||
readFileAsString(__dirname + '/fixtures/basic-2.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -242,7 +242,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #3: deep conditions nesting', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/deep-conditions-nesting.js')
|
||||
readFileAsString(__dirname + '/fixtures/deep-conditions-nesting.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -278,7 +278,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #4: call before declaration', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-before-declaration.js')
|
||||
readFileAsString(__dirname + '/fixtures/call-before-declaration.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -298,7 +298,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #5: call expression of object member #1', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-expression-of-object-member-1.js')
|
||||
readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-1.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -354,7 +354,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #5: call expression of object member #2', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-expression-of-object-member-2.js')
|
||||
readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-2.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -379,7 +379,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #6: no call expressions', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/no-call-expressions.js')
|
||||
readFileAsString(__dirname + '/fixtures/no-call-expressions.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -393,7 +393,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #7: only call expression', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/only-call-expression.js')
|
||||
readFileAsString(__dirname + '/fixtures/only-call-expression.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -407,7 +407,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #8: self-invoking functions', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/self-invoking-functions.js')
|
||||
readFileAsString(__dirname + '/fixtures/self-invoking-functions.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -439,7 +439,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
it('should returns correct IStackTraceData - variant #9: no recursion', () => {
|
||||
astTree = Nodes.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/no-recursion.js')
|
||||
readFileAsString(__dirname + '/fixtures/no-recursion.js')
|
||||
)
|
||||
);
|
||||
|
||||
+30
-29
@@ -7,44 +7,45 @@ BabelPolyfill.append();
|
||||
/**
|
||||
* Unit tests
|
||||
*/
|
||||
import './unit-tests/ObfuscationResult.spec';
|
||||
import './unit-tests/options/OptionsNormalizer.spec';
|
||||
import './unit-tests/SourceMapCorrector.spec';
|
||||
import './unit-tests/cli/CLIUtils.spec';
|
||||
import './unit-tests/decorators/Initializable.spec';
|
||||
import './unit-tests/node/NodeAppender.spec';
|
||||
import './unit-tests/node/NodeUtils.spec';
|
||||
import './unit-tests/stack-trace-analyzer/StackTraceAnalyzer.spec';
|
||||
import './unit-tests/utils/CryptUtils.spec';
|
||||
import './unit-tests/utils/RandomGeneratorUtils.spec';
|
||||
import './unit-tests/utils/Utils.spec';
|
||||
import './unit-tests/cli/cli-utils/CLIUtils.spec';
|
||||
import './unit-tests/decorators/initializable/Initializable.spec';
|
||||
import './unit-tests/node/node-appender/NodeAppender.spec';
|
||||
import './unit-tests/node/node-utils/NodeUtils.spec';
|
||||
import './unit-tests/obfuscation-result/ObfuscationResult.spec';
|
||||
import './unit-tests/options/options-normalizer/OptionsNormalizer.spec';
|
||||
import './unit-tests/source-map-corrector/SourceMapCorrector.spec';
|
||||
import './unit-tests/stack-trace-analyzer/stack-trace-analyzer/StackTraceAnalyzer.spec';
|
||||
import './unit-tests/utils/crypt-utils/CryptUtils.spec';
|
||||
import './unit-tests/utils/random-generator-utils/RandomGeneratorUtils.spec';
|
||||
import './unit-tests/utils/utils/Utils.spec';
|
||||
|
||||
/**
|
||||
* Functional tests
|
||||
*/
|
||||
import './functional-tests/JavaScriptObfuscator.spec';
|
||||
import './functional-tests/JavaScriptObfuscatorCLI.spec';
|
||||
import './functional-tests/JavaScriptObfuscatorInternal.spec';
|
||||
import './functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec';
|
||||
import './functional-tests/javascript-obfuscator-cli/JavaScriptObfuscatorCLI.spec';
|
||||
import './functional-tests/javascript-obfuscator-internal/JavaScriptObfuscatorInternal.spec';
|
||||
import './functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec';
|
||||
import './functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec';
|
||||
import './functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec';
|
||||
import './functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec';
|
||||
import './functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/CatchClauseTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/FunctionDeclarationTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/FunctionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/LabeledStatementTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/LiteralTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/MemberExpressionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/MethodDefinitionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/ObjectExpressionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/VariableDeclarationTransformer.spec';
|
||||
import './functional-tests/stack-trace-analyzer/StackTraceAnalyzer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec';
|
||||
import './functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/catch-clause-transformer/CatchClauseTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/function-declaration-transformer/FunctionDeclarationTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/function-transformer/FunctionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/literal-transformer/LiteralTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/member-expression-transformer/MemberExpressionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/method-definition-transformer/MethodDefinitionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/object-expression-transformer/ObjectExpressionTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/template-literal-transformer/TemplateLiteralTransformer.spec';
|
||||
import './functional-tests/node-transformers/obfuscation-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec';
|
||||
import './functional-tests/stack-trace-analyzer/stack-trace-analyzer/StackTraceAnalyzer.spec';
|
||||
import './functional-tests/templates/custom-nodes/domain-lock-nodes/DomainLockNodeTemplate.spec';
|
||||
import './functional-tests/templates/custom-nodes/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec';
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { readFileAsString } from '../helpers/readFileAsString';
|
||||
|
||||
import { IObfuscationResult } from '../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { readFileAsString } from '../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../src/JavaScriptObfuscator';
|
||||
|
||||
describe('JavaScriptObfuscator runtime eval', () => {
|
||||
it('should obfuscate code without any runtime errors after obfuscation: variant #1 sha256', () => {
|
||||
const code: string = readFileAsString('./test/fixtures/runtime/sha256.js');
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/sha256.js');
|
||||
|
||||
const obfuscationResult1: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import * as mkdirp from 'mkdirp';
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { CLIUtils } from '../../../src/cli/CLIUtils';
|
||||
import { CLIUtils } from '../../../../src/cli/CLIUtils';
|
||||
|
||||
describe('CLIUtils', () => {
|
||||
const fileContent: string = 'test',
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user