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.8.1
---
* Fixed incorrect rename of the identifiers of the added helpers in some rare cases. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/804

v2.8.0
---
* New option `ignoreRequireImports` prevents obfuscation of `require` imports. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/801
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.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "2.8.0",
"version": "2.8.1",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
Expand Down Expand Up @@ -58,13 +58,13 @@
"@types/mkdirp": "1.0.1",
"@types/mocha": "8.0.3",
"@types/multimatch": "4.0.0",
"@types/node": "14.14.6",
"@types/node": "14.14.7",
"@types/rimraf": "3.0.0",
"@types/sinon": "9.0.8",
"@types/string-template": "1.0.2",
"@types/webpack-env": "1.15.3",
"@typescript-eslint/eslint-plugin": "4.6.1",
"@typescript-eslint/parser": "4.6.1",
"@typescript-eslint/eslint-plugin": "4.7.0",
"@typescript-eslint/parser": "4.7.0",
"chai": "4.2.0",
"chai-exclude": "2.0.2",
"coveralls": "3.1.0",
Expand All @@ -76,15 +76,15 @@
"eslint-plugin-prefer-arrow": "1.2.2",
"eslint-plugin-unicorn": "23.0.0",
"fork-ts-checker-notifier-webpack-plugin": "3.0.0",
"fork-ts-checker-webpack-plugin": "6.0.0",
"fork-ts-checker-webpack-plugin": "6.0.1",
"mocha": "8.2.1",
"nyc": "15.1.0",
"pjson": "1.0.9",
"pre-commit": "1.2.2",
"rimraf": "3.0.2",
"sinon": "9.2.1",
"threads": "1.6.3",
"ts-loader": "8.0.10",
"ts-loader": "8.0.11",
"ts-node": "9.0.0",
"typescript": "4.1.0-beta",
"webpack": "5.4.0",
Expand Down
6 changes: 3 additions & 3 deletions src/analyzers/scope-analyzer/ScopeAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export class ScopeAnalyzer implements IScopeAnalyzer {
*/
private static attachMissingRanges (astTree: ESTree.Node): void {
estraverse.replace(astTree, {
enter: (node: ESTree.Node): ESTree.Node => {
enter: (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node => {
if (!node.range) {
node.range = [
node.parentNode?.range?.[0] ?? ScopeAnalyzer.emptyRangeValue,
node.parentNode?.range?.[1] ?? ScopeAnalyzer.emptyRangeValue
parentNode?.range?.[0] ?? ScopeAnalyzer.emptyRangeValue,
parentNode?.range?.[1] ?? ScopeAnalyzer.emptyRangeValue
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'reflect-metadata';

import { assert } from 'chai';

import { readFileAsString } from '../../../helpers/readFileAsString';

import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';

describe('ScopeAnalyzer', () => {
describe('analyze', () => {
/**
* https://github.com/javascript-obfuscator/javascript-obfuscator/issues/804
*/
describe('Variant #1: should attach a valid missing ranges', function() {
this.timeout(120000);

const samplesCount: number = 1000;
let error: string | null = null;

beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/attach-missing-ranges.js');

for (let i = 0; i < samplesCount; i++) {
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
code,
{
stringArray: false,
selfDefending: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.1,
splitStrings: false,
seed: i
}
).getObfuscatedCode();

try {
eval(obfuscatedCode);
} catch ({message}) {
error = message;
break;
}
}
});

it('should attach missing ranges based on the parent node and rename identifiers without errors', () => {
assert.equal(error, null);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function foo () {}

foo();
1 change: 1 addition & 0 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import './unit-tests/utils/Utils.spec';
* Functional tests
*/
import './functional-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec';
import './functional-tests/analyzers/scope-analyzer/ScopeAnalyzer.spec';
import './functional-tests/cli/JavaScriptObfuscatorCLI.spec';
import './functional-tests/code-transformers/preparing-transformers/hashbang-operator-transformer/HashbangOperatorTransformer.spec';
import './functional-tests/custom-code-helpers/common/templates/GlobalVariableNoEvalTemplate.spec';
Expand Down
106 changes: 53 additions & 53 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.3.tgz#6356df2647de9eac569f9a52eda3480fa9e70b4d"
integrity sha512-01s+ac4qerwd6RHD+mVbOEsraDHSgUaefQlEdBbUolnQFjKwCr7luvAlEwW1RFojh67u0z4OUTjPn9LEl4zIkA==

"@types/[email protected].6":
version "14.14.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.6.tgz#146d3da57b3c636cc0d1769396ce1cfa8991147f"
integrity sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==
"@types/[email protected].7":
version "14.14.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.7.tgz#8ea1e8f8eae2430cf440564b98c6dfce1ec5945d"
integrity sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -580,74 +580,74 @@
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.15.3.tgz#fb602cd4c2f0b7c0fb857e922075fdf677d25d84"
integrity sha512-5oiXqR7kwDGZ6+gmzIO2lTC+QsriNuQXZDWNYRV3l2XRN/zmPgnC21DLSx2D05zvD8vnXW6qUg7JnXZ4I6qLVQ==

"@typescript-eslint/eslint-plugin@4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.6.1.tgz#99d77eb7a016fd5a5e749d2c44a7e4c317eb7da3"
integrity sha512-SNZyflefTMK2JyrPfFFzzoy2asLmZvZJ6+/L5cIqg4HfKGiW2Gr1Go1OyEVqne/U4QwmoasuMwppoBHWBWF2nA==
"@typescript-eslint/eslint-plugin@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.7.0.tgz#85c9bbda00c0cb604d3c241f7bc7fb171a2d3479"
integrity sha512-li9aiSVBBd7kU5VlQlT1AqP0uWGDK6JYKUQ9cVDnOg34VNnd9t4jr0Yqc/bKxJr/tDCPDaB4KzoSFN9fgVxe/Q==
dependencies:
"@typescript-eslint/experimental-utils" "4.6.1"
"@typescript-eslint/scope-manager" "4.6.1"
"@typescript-eslint/experimental-utils" "4.7.0"
"@typescript-eslint/scope-manager" "4.7.0"
debug "^4.1.1"
functional-red-black-tree "^1.0.1"
regexpp "^3.0.0"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/experimental-utils@4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.6.1.tgz#a9c691dfd530a9570274fe68907c24c07a06c4aa"
integrity sha512-qyPqCFWlHZXkEBoV56UxHSoXW2qnTr4JrWVXOh3soBP3q0o7p4pUEMfInDwIa0dB/ypdtm7gLOS0hg0a73ijfg==
"@typescript-eslint/experimental-utils@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.7.0.tgz#8d1058c38bec3d3bbd9c898a1c32318d80faf3c5"
integrity sha512-cymzovXAiD4EF+YoHAB5Oh02MpnXjvyaOb+v+BdpY7lsJXZQN34oIETeUwVT2XfV9rSNpXaIcknDLfupO/tUoA==
dependencies:
"@types/json-schema" "^7.0.3"
"@typescript-eslint/scope-manager" "4.6.1"
"@typescript-eslint/types" "4.6.1"
"@typescript-eslint/typescript-estree" "4.6.1"
"@typescript-eslint/scope-manager" "4.7.0"
"@typescript-eslint/types" "4.7.0"
"@typescript-eslint/typescript-estree" "4.7.0"
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

"@typescript-eslint/parser@4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.6.1.tgz#b801bff67b536ecc4a840ac9289ba2be57e02428"
integrity sha512-lScKRPt1wM9UwyKkGKyQDqf0bh6jm8DQ5iN37urRIXDm16GEv+HGEmum2Fc423xlk5NUOkOpfTnKZc/tqKZkDQ==
"@typescript-eslint/parser@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.7.0.tgz#44bdab0f788b478178368baa65d3365fdc63da1c"
integrity sha512-+meGV8bMP1sJHBI2AFq1GeTwofcGiur8LoIr6v+rEmD9knyCqDlrQcFHR0KDDfldHIFDU/enZ53fla6ReF4wRw==
dependencies:
"@typescript-eslint/scope-manager" "4.6.1"
"@typescript-eslint/types" "4.6.1"
"@typescript-eslint/typescript-estree" "4.6.1"
"@typescript-eslint/scope-manager" "4.7.0"
"@typescript-eslint/types" "4.7.0"
"@typescript-eslint/typescript-estree" "4.7.0"
debug "^4.1.1"

"@typescript-eslint/scope-manager@4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.6.1.tgz#21872b91cbf7adfc7083f17b8041149148baf992"
integrity sha512-f95+80r6VdINYscJY1KDUEDcxZ3prAWHulL4qRDfNVD0I5QAVSGqFkwHERDoLYJJWmEAkUMdQVvx7/c2Hp+Bjg==
"@typescript-eslint/scope-manager@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.7.0.tgz#2115526085fb72723ccdc1eeae75dec7126220ed"
integrity sha512-ILITvqwDJYbcDCROj6+Ob0oCKNg3SH46iWcNcTIT9B5aiVssoTYkhKjxOMNzR1F7WSJkik4zmuqve5MdnA0DyA==
dependencies:
"@typescript-eslint/types" "4.6.1"
"@typescript-eslint/visitor-keys" "4.6.1"
"@typescript-eslint/types" "4.7.0"
"@typescript-eslint/visitor-keys" "4.7.0"

"@typescript-eslint/types@4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.6.1.tgz#d3ad7478f53f22e7339dc006ab61aac131231552"
integrity sha512-k2ZCHhJ96YZyPIsykickez+OMHkz06xppVLfJ+DY90i532/Cx2Z+HiRMH8YZQo7a4zVd/TwNBuRCdXlGK4yo8w==
"@typescript-eslint/types@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.7.0.tgz#5e95ef5c740f43d942542b35811f87b62fccca69"
integrity sha512-uLszFe0wExJc+I7q0Z/+BnP7wao/kzX0hB5vJn4LIgrfrMLgnB2UXoReV19lkJQS1a1mHWGGODSxnBx6JQC3Sg==

"@typescript-eslint/typescript-estree@4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.6.1.tgz#6025cce724329413f57e4959b2d676fceeca246f"
integrity sha512-/J/kxiyjQQKqEr5kuKLNQ1Finpfb8gf/NpbwqFFYEBjxOsZ621r9AqwS9UDRA1Rrr/eneX/YsbPAIhU2rFLjXQ==
"@typescript-eslint/typescript-estree@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.7.0.tgz#539531167f05ba20eb0b6785567076679e29d393"
integrity sha512-5XZRQznD1MfUmxu1t8/j2Af4OxbA7EFU2rbo0No7meb46eHgGkSieFdfV6omiC/DGIBhH9H9gXn7okBbVOm8jw==
dependencies:
"@typescript-eslint/types" "4.6.1"
"@typescript-eslint/visitor-keys" "4.6.1"
"@typescript-eslint/types" "4.7.0"
"@typescript-eslint/visitor-keys" "4.7.0"
debug "^4.1.1"
globby "^11.0.1"
is-glob "^4.0.1"
lodash "^4.17.15"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/visitor-keys@4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.6.1.tgz#6b125883402d8939df7b54528d879e88f7ba3614"
integrity sha512-owABze4toX7QXwOLT3/D5a8NecZEjEWU1srqxENTfqsY3bwVnl3YYbOh6s1rp2wQKO9RTHFGjKes08FgE7SVMw==
"@typescript-eslint/visitor-keys@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.7.0.tgz#6783824f22acfc49e754970ed21b88ac03b80e6f"
integrity sha512-aDJDWuCRsf1lXOtignlfiPODkzSxxop7D0rZ91L6ZuMlcMCSh0YyK+gAfo5zN/ih6WxMwhoXgJWC3cWQdaKC+A==
dependencies:
"@typescript-eslint/types" "4.6.1"
"@typescript-eslint/types" "4.7.0"
eslint-visitor-keys "^2.0.0"

"@ungap/[email protected]":
Expand Down Expand Up @@ -2187,10 +2187,10 @@ [email protected]:
dependencies:
node-notifier "^6.0.0"

[email protected].0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.0.0.tgz#7166d972fb07ce4b6e954085e02159a82d030d62"
integrity sha512-fa+ergrDxdy8d8fkCp14hy9slxrdXUnWwaHZEyM+k9qimq3RA+x3GncTz3oliTZrTshCTiFz8auPBedS19Tviw==
[email protected].1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.0.1.tgz#77d73640c9275ebfee6b60e6571c6efb7256ee84"
integrity sha512-G2uKf40W+a8/TzoCrGK+22ccTIzSBDFz7RquT5WaQ8kKw6TpplY9+THKp71h/3ne6BnXc7CXc2lcwj/nuHd8Vw==
dependencies:
"@babel/code-frame" "^7.8.3"
"@types/json-schema" "^7.0.5"
Expand Down Expand Up @@ -4311,10 +4311,10 @@ tough-cookie@~2.5.0:
psl "^1.1.28"
punycode "^2.1.1"

[email protected].10:
version "8.0.10"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.10.tgz#4af4afb8d26847290cd010df93a4c172df92278f"
integrity sha512-5fVbbZldz6LQi6RQ0v1P7lZ98CZGlQyM8b4xGZXw3G/XUqL8GIH+Ib6H01nImPhkHZ9+PVXZgTb+v3fRsaIHlg==
[email protected].11:
version "8.0.11"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.11.tgz#35d58a65932caacb120426eea59eca841786c899"
integrity sha512-06X+mWA2JXoXJHYAesUUL4mHFYhnmyoCdQVMXofXF552Lzd4wNwSGg7unJpttqUP7ziaruM8d7u8LUB6I1sgzA==
dependencies:
chalk "^2.3.0"
enhanced-resolve "^4.0.0"
Expand Down