mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed errors related to identifiers. Changed self defending helper
This commit is contained in:
@@ -5,6 +5,7 @@ import { TInputOptions } from '../../src/types/options/TInputOptions';
|
||||
import { StringArrayEncoding } from '../../src/enums/StringArrayEncoding';
|
||||
import { IdentifierNamesGenerator } from '../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
|
||||
|
||||
import { evaluateInWorker } from '../helpers/evaluateInWorker';
|
||||
import { readFileAsString } from '../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../src/JavaScriptObfuscatorFacade';
|
||||
@@ -36,7 +37,7 @@ describe('JavaScriptObfuscator runtime eval', function () {
|
||||
unicodeEscapeSequence: true
|
||||
};
|
||||
|
||||
this.timeout(100000);
|
||||
this.timeout(200000);
|
||||
|
||||
[
|
||||
{
|
||||
@@ -164,5 +165,123 @@ describe('JavaScriptObfuscator runtime eval', function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`Obfuscator. ${detailedDescription}`, () => {
|
||||
const evaluationTimeout: number = 10000;
|
||||
|
||||
let evaluationResult: string;
|
||||
|
||||
beforeEach((done) => {
|
||||
const code: string = readFileAsString(process.cwd() + '/dist/index.js');
|
||||
|
||||
const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...baseOptions,
|
||||
...options
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
evaluateInWorker(
|
||||
`
|
||||
${getEnvironmentCode()}
|
||||
${obfuscatedCode}
|
||||
module.exports.obfuscate('var foo = 1;').getObfuscatedCode();
|
||||
`,
|
||||
(response: string) => {
|
||||
evaluationResult = response;
|
||||
done();
|
||||
},
|
||||
(error: Error) => {
|
||||
evaluationResult = error.message;
|
||||
done();
|
||||
},
|
||||
() => {
|
||||
done();
|
||||
},
|
||||
evaluationTimeout
|
||||
);
|
||||
});
|
||||
|
||||
it('should obfuscate code without any runtime errors after obfuscation: Variant #3 obfuscator', () => {
|
||||
assert.equal(
|
||||
evaluationResult,
|
||||
'var foo=0x1;'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
{
|
||||
debugProtection: false,
|
||||
selfDefending: false,
|
||||
stringArray: true
|
||||
},
|
||||
{
|
||||
debugProtection: false,
|
||||
selfDefending: true,
|
||||
stringArray: false
|
||||
},
|
||||
{
|
||||
debugProtection: true,
|
||||
selfDefending: false,
|
||||
stringArray: false
|
||||
},
|
||||
{
|
||||
debugProtection: true,
|
||||
selfDefending: true,
|
||||
stringArray: false
|
||||
},
|
||||
{
|
||||
debugProtection: true,
|
||||
selfDefending: true,
|
||||
stringArray: true
|
||||
}
|
||||
].forEach((webpackBootstrapOptions: Partial<TInputOptions>) => {
|
||||
describe(`Webpack bootstrap code. ${detailedDescription}. ${JSON.stringify(webpackBootstrapOptions)}`, () => {
|
||||
const evaluationTimeout: number = 10000;
|
||||
|
||||
let evaluationResult: string;
|
||||
|
||||
beforeEach((done) => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/webpack-bootstrap.js');
|
||||
|
||||
const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...baseOptions,
|
||||
...options,
|
||||
...webpackBootstrapOptions
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
evaluateInWorker(
|
||||
`
|
||||
${getEnvironmentCode()}
|
||||
${obfuscatedCode}
|
||||
`,
|
||||
(response: string) => {
|
||||
evaluationResult = response;
|
||||
done();
|
||||
},
|
||||
(error: Error) => {
|
||||
evaluationResult = error.message;
|
||||
done();
|
||||
},
|
||||
() => {
|
||||
done();
|
||||
},
|
||||
evaluationTimeout
|
||||
);
|
||||
});
|
||||
|
||||
it('should obfuscate code without any runtime errors after obfuscation: Variant #4 webpack bootstrap', () => {
|
||||
assert.equal(
|
||||
evaluationResult,
|
||||
'foo'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user