Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #805 from javascript-obfuscator/fixed-attach-missi…
…ng-ranges Fixed incorrect rename of the identifiers of the added helpers in some rare cases
- Loading branch information
Showing
10 changed files
with
123 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
test/functional-tests/analyzers/scope-analyzer/ScopeAnalyzer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/functional-tests/analyzers/scope-analyzer/fixtures/attach-missing-ranges.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function foo () {} | ||
|
||
foo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters