javascript-obfuscator / javascript-obfuscator/webpack-obfuscator

identifierNamesCache not working as expected

Đang mở
#127 0 bình luận 2 reaction 0 người được giao Xem trên GitHub

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.