Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change Log

v2.6.1
---
* Fixed missing rename of object pattern properties in some cases. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/781

v2.6.0
---
* Migration to `webpack@5`
Expand Down
2 changes: 1 addition & 1 deletion dist/index.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.cli.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "2.6.0",
"version": "2.6.1",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
Expand Down Expand Up @@ -47,7 +47,7 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "1.0.1",
"@types/chai": "4.2.13",
"@types/chai": "4.2.14",
"@types/chance": "1.1.0",
"@types/escodegen": "0.0.6",
"@types/eslint-scope": "3.7.0",
Expand All @@ -58,7 +58,7 @@
"@types/mkdirp": "1.0.1",
"@types/mocha": "8.0.3",
"@types/multimatch": "4.0.0",
"@types/node": "14.11.8",
"@types/node": "14.11.10",
"@types/rimraf": "3.0.0",
"@types/sinon": "9.0.8",
"@types/string-template": "1.0.2",
Expand All @@ -71,7 +71,7 @@
"cross-env": "7.0.2",
"eslint": "7.11.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.6.4",
"eslint-plugin-jsdoc": "30.6.5",
"eslint-plugin-no-null": "1.0.2",
"eslint-plugin-prefer-arrow": "1.2.2",
"eslint-plugin-unicorn": "22.0.0",
Expand All @@ -87,7 +87,7 @@
"ts-loader": "8.0.5",
"ts-node": "9.0.0",
"typescript": "4.1.0-beta",
"webpack": "5.1.0",
"webpack": "5.1.3",
"webpack-cli": "4.0.0",
"webpack-node-externals": "2.5.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class ObjectPatternPropertiesTransformer extends AbstractNodeTransformer
propertyNode.shorthand = false;
propertyNode.value = NodeUtils.clone(propertyNode.value);

NodeUtils.parentizeNode(propertyNode.value, parentNode);
NodeUtils.parentizeNode(propertyNode.value, propertyNode);

return propertyNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export class ScopeIdentifiersTransformer extends AbstractNodeTransformer {
&& !parentNode.computed
&& NodeGuards.isIdentifierNode(parentNode.key)
&& NodeGuards.isIdentifierNode(node)
&& parentNode.shorthand
&& parentNode.key.name === node.name;
}

Expand Down
19 changes: 11 additions & 8 deletions test/dev/dev.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
'use strict';

import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
import { IdentifierNamesGenerator } from '../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';

(function () {
const JavaScriptObfuscator: any = require('../../index');

let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
var test = '\\nreturn \\n//# sourceURL= there can only be \\'^\\' and \\'!\\' markers in a subscription marble diagram.';

console.log(test);
function foo () {
const {
qq,
qqq,
} = object;

const foo = {
prop: 1
};
}
`,
{
...NO_ADDITIONAL_NODES_PRESET,
compact: false,
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
stringArray: true,
stringArrayThreshold: 1,
unicodeEscapeSequence: false
transformObjectKeys: true
}
).getObfuscatedCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,37 @@ describe('ObjectPatternPropertiesTransformer', () => {
assert.match(obfuscatedCode, regExp);
});
});

describe('Variant #3: issue 781. Wrong parentize of cloned `propertyNode` value', () => {
const regExp: RegExp = new RegExp(
'const { *' +
'foo: *_0x([a-f0-9]){4,6}, *' +
'bar: *_0x([a-f0-9]){4,6} *' +
'} *= *{}; *' +
'const _0x([a-f0-9]){4,6} *= *{};' +
'_0x([a-f0-9]){4,6}\\[\'prop\'] *= *0x1;' +
'const _0x([a-f0-9]){4,6} *= *_0x([a-f0-9]){4,6};'
);

let obfuscatedCode: string;

before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/function-scope-wrong-parentize.js');

obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
renameGlobals: false,
transformObjectKeys: true
}
).getObfuscatedCode();
});

it('should transform object properties', () => {
assert.match(obfuscatedCode, regExp);
});
});
});

describe('Variant #2: global scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(function () {
const {foo, bar} = {};
const baz = {
prop: 1
};
})();
Loading