mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added additional test for eval transformer
This commit is contained in:
+4
-5
@@ -7,12 +7,11 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
|
||||
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function(){
|
||||
function foo (a, b) {
|
||||
return eval('var c = a + b; eval(\\'a + c\\');');
|
||||
|
||||
function foo () {
|
||||
eval('var s = 1;');
|
||||
}
|
||||
|
||||
console.log(foo(1, 2));
|
||||
|
||||
foo();
|
||||
})();
|
||||
`,
|
||||
{
|
||||
|
||||
-1
@@ -36,7 +36,6 @@ describe('BlockStatementControlFlowTransformer', function () {
|
||||
);
|
||||
|
||||
obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
||||
console.log(obfuscatedCode);
|
||||
});
|
||||
|
||||
describe('`console.log` statements', ()=> {
|
||||
|
||||
+23
-1
@@ -233,7 +233,29 @@ describe('AstToEvalCallExpressionTransformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #7: integration with control flow flattening', () => {
|
||||
describe('variant #7: wrong eval string', () => {
|
||||
const evalExpressionRegExp: RegExp = /eval *\('~'\);/;
|
||||
|
||||
let obfuscatedCode: string
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/wrong-eval-string.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET
|
||||
}
|
||||
);
|
||||
|
||||
obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should skip obfuscation of eval string', () => {
|
||||
assert.match(obfuscatedCode, evalExpressionRegExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #8: integration with control flow flattening', () => {
|
||||
const variableMatch: string = '_0x([a-f0-9]){4,6}';
|
||||
const controlFlowStorageNodeMatch: string = `` +
|
||||
`var *${variableMatch} *= *\\{` +
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
(function(){
|
||||
function foo () {
|
||||
eval('~');
|
||||
}
|
||||
|
||||
foo();
|
||||
})();
|
||||
Reference in New Issue
Block a user