Skip to content

Commit c0fd72e

Browse files
committed
1 parent 70c7885 commit c0fd72e

File tree

12 files changed

+116
-39
lines changed

12 files changed

+116
-39
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ v0.13.0
77
* **Breaking change:** all CLI options were renamed to `kebab-case` format (`--disableConsoleOutout` -> `--disable-console-output`).
88
* Implemented custom `mangle` option algorithm without `esmangle`; fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/110
99
* Comments with `@license`, `@preserve` and `javascript-obfuscator` words won't be removed from obfuscated code.
10+
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/149
1011

1112
v0.12.5
1213
---
13-
* https://github.com/javascript-obfuscator/javascript-obfuscator/issues/139
14+
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/139
1415

1516
v0.12.4
1617
---
17-
* https://github.com/javascript-obfuscator/javascript-obfuscator/issues/136
18+
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/136
1819

1920
v0.12.3
2021
---

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javascript-obfuscator",
3-
"version": "0.13.0-dev.3",
3+
"version": "0.13.0-dev.4",
44
"description": "JavaScript obfuscator",
55
"keywords": [
66
"obfuscator",
@@ -37,7 +37,7 @@
3737
"tslib": "1.8.1"
3838
},
3939
"devDependencies": {
40-
"@types/chai": "4.0.9",
40+
"@types/chai": "4.0.10",
4141
"@types/chance": "0.7.35",
4242
"@types/commander": "2.12.2",
4343
"@types/escodegen": "0.0.6",
@@ -47,8 +47,8 @@
4747
"@types/md5": "2.1.32",
4848
"@types/mkdirp": "0.5.2",
4949
"@types/mocha": "2.2.44",
50-
"@types/node": "8.0.58",
51-
"@types/sinon": "4.1.0",
50+
"@types/node": "8.5.0",
51+
"@types/sinon": "4.1.2",
5252
"@types/string-template": "1.0.2",
5353
"@types/webpack-env": "1.13.3",
5454
"awesome-typescript-loader": "3.4.1",
@@ -63,7 +63,7 @@
6363
"pre-commit": "1.2.2",
6464
"sinon": "4.1.3",
6565
"threads": "^0.10.0",
66-
"ts-node": "3.3.0",
66+
"ts-node": "4.0.1",
6767
"tslint": "5.8.0",
6868
"tslint-eslint-rules": "4.1.1",
6969
"tslint-language-service": "0.9.7",

scripts/test-dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
$(yarn bin)/ts-node test/dev/dev.ts
3+
$(yarn bin)/ts-node --type-check test/dev/dev.ts

src/node/NodeGuards.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,20 @@ export class NodeGuards {
228228
return false;
229229
}
230230

231-
const parentNodeIsPropertyNode: boolean = NodeGuards.isPropertyNode(parentNode)
232-
&& !parentNode.computed
233-
&& parentNode.key === node;
231+
const parentNodeIsPropertyNode: boolean = NodeGuards.isPropertyNode(parentNode) &&
232+
!parentNode.computed &&
233+
parentNode.key === node;
234234
const parentNodeIsMemberExpressionNode: boolean = (
235235
NodeGuards.isMemberExpressionNode(parentNode) &&
236236
parentNode.computed === false &&
237237
parentNode.property === node
238238
);
239+
const parentNodeIsMethodDefinitionNode: boolean = NodeGuards.isMethodDefinitionNode(parentNode) &&
240+
!parentNode.computed;
239241

240242
return !parentNodeIsPropertyNode &&
241243
!parentNodeIsMemberExpressionNode &&
244+
!parentNodeIsMethodDefinitionNode &&
242245
!NodeGuards.isLabelIdentifierNode(node, parentNode);
243246
}
244247

test/dev/dev.ts

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes'
3535
{
3636
...NO_CUSTOM_NODES_PRESET,
3737
compact: false,
38-
identifierNamesGenerator: 'mangled'
3938
}
4039
).getObfuscatedCode();
4140

test/functional-tests/node-transformers/converting-transformers/method-definition-transformer/MethodDefinitionTransformer.spec.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import { readFileAsString } from '../../../../helpers/readFileAsString';
99
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
1010

1111
describe('MethodDefinitionTransformer', () => {
12-
const code: string = readFileAsString(__dirname + '/fixtures/input.js');
13-
1412
describe('variant #1: default behaviour', () => {
1513
const regExp: RegExp = /\['bar'\]\(\)\{\}/;
1614

1715
let obfuscatedCode: string;
1816

1917
before(() => {
18+
const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
2019
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
2120
code,
2221
{
@@ -39,6 +38,7 @@ describe('MethodDefinitionTransformer', () => {
3938
let obfuscatedCode: string;
4039

4140
before(() => {
41+
const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
4242
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
4343
code,
4444
{
@@ -66,6 +66,7 @@ describe('MethodDefinitionTransformer', () => {
6666
let obfuscatedCode: string;
6767

6868
before(() => {
69+
const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
6970
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
7071
code,
7172
{

test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ describe('DeadCodeInjectionTransformer', () => {
280280
});
281281
});
282282

283-
describe('variant #7- chance of `IfStatement` variant', () => {
283+
describe('variant #7 - chance of `IfStatement` variant', () => {
284284
const samplesCount: number = 1000;
285285
const delta: number = 0.1;
286286
const expectedDistribution: number = 0.25;

test/functional-tests/node-transformers/obfuscating-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec.ts

+22
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,26 @@ describe('VariableDeclarationTransformer', () => {
413413
assert.match(obfuscatedCode, computedObjectExpressionRegExp);
414414
});
415415
});
416+
417+
describe('variant #12: method definition key identifier', () => {
418+
const regExp: RegExp = /\['bar'] *\(\) *{}/;
419+
420+
let obfuscatedCode: string;
421+
422+
before(() => {
423+
const code: string = readFileAsString(__dirname + '/fixtures/method-definition-identifier.js');
424+
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
425+
code,
426+
{
427+
...NO_CUSTOM_NODES_PRESET
428+
}
429+
);
430+
431+
obfuscatedCode = obfuscationResult.getObfuscatedCode();
432+
});
433+
434+
it('shouldn\'t transform method definition node key identifier', () => {
435+
assert.match(obfuscatedCode, regExp);
436+
});
437+
});
416438
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(function () {
2+
var bar = 1;
3+
4+
class Foo {
5+
bar() {}
6+
}
7+
})();

yarn.lock

+67-23
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
# yarn lockfile v1
33

44

5-
6-
version "4.0.9"
7-
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.9.tgz#9897c0ca23acb117f8b4e3af2c81d85cccdd9bc0"
5+
"@types/arrify@^1.0.1":
6+
version "1.0.2"
7+
resolved "https://registry.yarnpkg.com/@types/arrify/-/arrify-1.0.2.tgz#4a6856b9bfd4713c781df95349c6b15db60d4de1"
8+
9+
10+
version "4.0.10"
11+
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.10.tgz#0eb222c7353adde8e0980bea04165d4d3b6afef3"
812

913
1014
version "0.7.35"
@@ -16,6 +20,10 @@
1620
dependencies:
1721
commander "*"
1822

23+
"@types/diff@^3.2.1":
24+
version "3.2.2"
25+
resolved "https://registry.yarnpkg.com/@types/diff/-/diff-3.2.2.tgz#4d6f45537322a7a420d353a0939513c7e96d14a6"
26+
1927
2028
version "0.0.6"
2129
resolved "https://registry.yarnpkg.com/@types/escodegen/-/escodegen-0.0.6.tgz#5230a9ce796e042cda6f086dbf19f22ea330659c"
@@ -42,7 +50,11 @@
4250
dependencies:
4351
"@types/node" "*"
4452

45-
53+
"@types/minimist@^1.2.0":
54+
version "1.2.0"
55+
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
56+
57+
"@types/[email protected]", "@types/mkdirp@^0.5.0":
4658
version "0.5.2"
4759
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f"
4860
dependencies:
@@ -56,22 +68,44 @@
5668
version "8.0.53"
5769
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.53.tgz#396b35af826fa66aad472c8cb7b8d5e277f4e6d8"
5870

59-
"@types/node@8.0.58":
60-
version "8.0.58"
61-
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.58.tgz#5b3881c0be3a646874803fee3197ea7f1ed6df90"
71+
"@types/node@8.5.0", "@types/node@^8.0.27":
72+
version "8.5.0"
73+
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.5.0.tgz#c5be22ffc84b221466fc8dfc0d6b1f88060808ef"
6274

63-
64-
version "4.1.0"
65-
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-4.1.0.tgz#cdfb934d656b2c888e51f53e95900c7bbca11c08"
75+
76+
version "4.1.2"
77+
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-4.1.2.tgz#9085db9cc3288b0f12daceee20a26c4afd9c2dcd"
78+
79+
"@types/source-map-support@^0.4.0":
80+
version "0.4.0"
81+
resolved "https://registry.yarnpkg.com/@types/source-map-support/-/source-map-support-0.4.0.tgz#a62a1866614af68c888173c001481f242aaf148b"
82+
dependencies:
83+
"@types/node" "*"
6684

6785
6886
version "1.0.2"
6987
resolved "https://registry.yarnpkg.com/@types/string-template/-/string-template-1.0.2.tgz#363b273c9b456705e3111e3571e9248f6474eba4"
7088

89+
"@types/strip-bom@^3.0.0":
90+
version "3.0.0"
91+
resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2"
92+
93+
94+
version "0.0.30"
95+
resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
96+
97+
"@types/v8flags@github:types/npm-v8flags#de224ae1cd5fd7dbb4e7158a6cc7a29e5315930d":
98+
version "2.0.0"
99+
resolved "https://codeload.github.com/types/npm-v8flags/tar.gz/de224ae1cd5fd7dbb4e7158a6cc7a29e5315930d"
100+
71101
72102
version "1.13.3"
73103
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.13.3.tgz#0ecbe70f87341767793774d3683b51aa3246434c"
74104

105+
"@types/yn@github:types/npm-yn#ca75f6c82940fae6a06fb41d2d37a6aa9b4ea8e9":
106+
version "2.0.0"
107+
resolved "https://codeload.github.com/types/npm-yn/tar.gz/ca75f6c82940fae6a06fb41d2d37a6aa9b4ea8e9"
108+
75109
76110
version "1.0.9"
77111
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
@@ -939,7 +973,7 @@ [email protected], chalk@^1.0.0, chalk@^1.1.3:
939973
strip-ansi "^3.0.0"
940974
supports-color "^2.0.0"
941975

942-
[email protected], chalk@^2.0.0, chalk@^2.1.0:
976+
[email protected], chalk@^2.1.0, chalk@^2.3.0:
943977
version "2.3.0"
944978
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba"
945979
dependencies:
@@ -3359,13 +3393,13 @@ source-map-resolve@^0.5.0:
33593393
source-map-url "^0.4.0"
33603394
urix "^0.1.0"
33613395

3362-
3396+
[email protected], source-map-support@^0.5.0:
33633397
version "0.5.0"
33643398
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.0.tgz#2018a7ad2bdf8faf2691e5fddab26bed5a2bacab"
33653399
dependencies:
33663400
source-map "^0.6.0"
33673401

3368-
source-map-support@^0.4.0, source-map-support@^0.4.15:
3402+
source-map-support@^0.4.15:
33693403
version "0.4.18"
33703404
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f"
33713405
dependencies:
@@ -3640,25 +3674,35 @@ trim-right@^1.0.1:
36403674
version "1.0.1"
36413675
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
36423676

3643-
3644-
version "3.3.0"
3645-
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-3.3.0.tgz#c13c6a3024e30be1180dd53038fc209289d4bf69"
3646-
dependencies:
3677+
3678+
version "4.0.1"
3679+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-4.0.1.tgz#4d368088b50c382d78285c029784ea0f32a4eb5c"
3680+
dependencies:
3681+
"@types/arrify" "^1.0.1"
3682+
"@types/diff" "^3.2.1"
3683+
"@types/minimist" "^1.2.0"
3684+
"@types/mkdirp" "^0.5.0"
3685+
"@types/node" "^8.0.27"
3686+
"@types/source-map-support" "^0.4.0"
3687+
"@types/v8flags" types/npm-v8flags#de224ae1cd5fd7dbb4e7158a6cc7a29e5315930d
3688+
"@types/yn" types/npm-yn#ca75f6c82940fae6a06fb41d2d37a6aa9b4ea8e9
36473689
arrify "^1.0.0"
3648-
chalk "^2.0.0"
3690+
chalk "^2.3.0"
36493691
diff "^3.1.0"
36503692
make-error "^1.1.1"
36513693
minimist "^1.2.0"
36523694
mkdirp "^0.5.1"
3653-
source-map-support "^0.4.0"
3654-
tsconfig "^6.0.0"
3695+
source-map-support "^0.5.0"
3696+
tsconfig "^7.0.0"
36553697
v8flags "^3.0.0"
36563698
yn "^2.0.0"
36573699

3658-
tsconfig@^6.0.0:
3659-
version "6.0.0"
3660-
resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-6.0.0.tgz#6b0e8376003d7af1864f8df8f89dd0059ffcd032"
3700+
tsconfig@^7.0.0:
3701+
version "7.0.0"
3702+
resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7"
36613703
dependencies:
3704+
"@types/strip-bom" "^3.0.0"
3705+
"@types/strip-json-comments" "0.0.30"
36623706
strip-bom "^3.0.0"
36633707
strip-json-comments "^2.0.0"
36643708

0 commit comments

Comments
 (0)