javascript-obfuscator / javascript-obfuscator/webpack-obfuscator
identifierNamesCache not working as expected
- 主要言語
- TypeScript
- スター
- 928
- フォーク
- 92
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hi,
I was trying this plugin with WebPack 5 and found that `identifierNamesCache` is not working properly to obfuscate multiple files that depends on each other.
I modified the built `index.js` to fix this issue.
**Old code:**
```js
obfuscate(javascript, fileName, identifiersPrefixCounter) {
const obfuscationResult = javascript_obfuscator_1.default.obfuscate(javascript, Object.assign({ identifiersPrefix: `${WebpackObfuscatorPlugin.baseIdentifiersPrefix}${identifiersPrefixCounter}`, inputFileName: fileName, sourceMapMode: 'separate', sourceMapFileName: fileName + '.map' }, this.options));
return {
obfuscatedSource: obfuscationResult.getObfuscatedCode(),
obfuscationSourceMap: obfuscationResult.getSourceMap()
};
}
```
**New code:**
```js
obfuscate(javascript, fileName, identifiersPrefixCounter) {
const obfuscationResult = javascript_obfuscator_1.default.obfuscate(javascript, Object.assign({ identifiersPrefix: `${WebpackObfuscatorPlugin.baseIdentifiersPrefix}${identifiersPrefixCounter}`, inputFileName: fileName, sourceMapMode: 'separate', sourceMapFileName: fileName + '.map' }, this.options));
this.options.identifierNamesCache = obfuscationResult.getIdentifierNamesCache();
return {
obfuscatedSource: obfuscationResult.getObfuscatedCode(),
obfuscationSourceMap: obfuscationResult.getSourceMap()
};
}
```
I justed add `this.options.identifierNamesCache = obfuscationResult.getIdentifierNamesCache();` and now it works correctly.
PS: I'm not sure if the issue is in this plugin or `javascript-obfuscator` itself.
Thanks.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず、ビルドされた index.js の obfuscate メソッドと、identifierNamesCache オプションのフローを調査します。複数の依存ファイルにまたがる Webpack 5 で問題を再現し、その後、オブスケーション結果間でキャッシュが引き継がれ、ファイルが一貫してオブスケートされることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript, webpack
- 領域
- build-system, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100