javascript-obfuscator / javascript-obfuscator/webpack-obfuscator
identifierNamesCache not working as expected
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 928
- Fork
- 92
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách kiểm tra phương thức obfuscate trong index.js đã được build và luồng của tùy chọn identifierNamesCache. Tái hiện vấn đề với Webpack 5 trên nhiều tệp phụ thuộc, sau đó xác minh rằng cache được truyền giữa các kết quả obfuscation và các tệp được obfuscate một cách nhất quán.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, typescript, webpack
- Lĩnh vực
- build-system, tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100