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