GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — controlFlowFlattening evaluates the skipped operand of `&&` / `||` / `??` (LogicalExpressionControlFlowReplacer) · Issue #1456 · javascript-obfuscator/javascript-obfuscator Closed Labels DescriptionExpected BehaviorObfuscated code keeps short-circuit evaluation: in Current BehaviorWith
Each eligible site is replaced with probability
Steps to Reproduce// node repro.js const JavaScriptObfuscator = require('javascript-obfuscator'); const code = ` function size(img) { return img && { width: img.width }; } function pick(ready) { return ready && late; } var count = 0; function next(seen) { return seen || { seen: seen, n: ++count }; } function report(name, fn) { try { console.log(name, JSON.stringify(fn())); } catch (e) { console.log(name, 'throws', e.constructor.name + ': ' + e.message); } } report('size(null) ', function () { return size(null); }); report('pick(false) ', function () { return pick(false); }); report('next(true) ', function () { next(true); return count; }); let late = 1; `; const options = { controlFlowFlattening: true, controlFlowFlatteningThreshold: 1, seed: 1 }; console.log('--- plain'); new Function(code)(); console.log('--- obfuscated'); new Function(JavaScriptObfuscator.obfuscate(code, options).getObfuscatedCode())(); Output (5.5.0 and 5.8.0):
function size(_0x3f434e) { var _0x2c7393 = { 'PSBht': function (_0x26868c, _0x4eb5be) { return _0x26868c && _0x4eb5be; } }; return _0x2c7393['PSBht'](_0x3f434e, { 'width': _0x3f434e['width'] }); } The same happens in methods, getters, class field initialisers inside functions, async functions, generators and block-bodied arrows. Expression-bodied arrows, parameter defaults and top-level code are not affected ( JavaScript Obfuscator Edition
Your Environment
WorkaroundBefore obfuscating, rewrite each such right operand as Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |