mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed incorrect rename of the identifiers of the added helpers in some rare cases
Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/804
This commit is contained in:
@@ -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
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+6
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "javascript-obfuscator",
|
||||
"version": "2.8.0",
|
||||
"version": "2.8.1",
|
||||
"description": "JavaScript obfuscator",
|
||||
"keywords": [
|
||||
"obfuscator",
|
||||
@@ -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",
|
||||
@@ -76,7 +76,7 @@
|
||||
"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",
|
||||
@@ -84,7 +84,7 @@
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
function foo () {}
|
||||
|
||||
foo();
|
||||
@@ -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';
|
||||
|
||||
@@ -2187,10 +2187,10 @@ fork-ts-checker-notifier-webpack-plugin@3.0.0:
|
||||
dependencies:
|
||||
node-notifier "^6.0.0"
|
||||
|
||||
fork-ts-checker-webpack-plugin@6.0.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==
|
||||
fork-ts-checker-webpack-plugin@6.0.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"
|
||||
@@ -4311,10 +4311,10 @@ tough-cookie@~2.5.0:
|
||||
psl "^1.1.28"
|
||||
punycode "^2.1.1"
|
||||
|
||||
ts-loader@8.0.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==
|
||||
ts-loader@8.0.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"
|
||||
|
||||
Reference in New Issue
Block a user