sanex3339
2017-09-19 12:22:43 +03:00
parent f81190266a
commit 2a171ae9a0
8 changed files with 72 additions and 2 deletions
@@ -52,4 +52,26 @@ describe('ObjectExpressionTransformer', () => {
assert.match(obfuscatedCode, regExp);
});
});
describe('computed property name', () => {
const regExp: RegExp = /var *_0x[a-f0-9]{4,6} *= *\{\[_0x[a-f0-9]{4,6}\]: *0x1\};/;
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name.js');
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
code,
{
...NO_CUSTOM_NODES_PRESET
}
);
obfuscatedCode = obfuscationResult.getObfuscatedCode();
});
it('should ignore computed property identifier', () => {
assert.match(obfuscatedCode, regExp);
});
});
});
@@ -0,0 +1,6 @@
(function () {
var key = 'foo';
var test = {
[key]: 1
};
})();
@@ -391,4 +391,26 @@ describe('VariableDeclarationTransformer', () => {
assert.equal(objectPatternIdentifierName2, identifierName2);
});
});
describe('variant #11: computed object expression identifier', () => {
const computedObjectExpressionRegExp: RegExp = /var *_0x[a-f0-9]{4,6} *= *\{\[_0x[a-f0-9]{4,6}\]: *0x1\};/;
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/computed-object-expression-identifier.js');
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
code,
{
...NO_CUSTOM_NODES_PRESET
}
);
obfuscatedCode = obfuscationResult.getObfuscatedCode();
});
it('should transform computed object expression identifier', () => {
assert.match(obfuscatedCode, computedObjectExpressionRegExp);
});
});
});
@@ -0,0 +1,10 @@
function foo () {
var test = 'abc';
var object = {
[test]: 1
};
console.log(test);
console.log(object.abc);
}