javascript-obfuscator / javascript-obfuscator/gulp-javascript-obfuscator

Bug in obfuscate js code.

Đang mở
#24 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug cannot reproduce
Ngôn ngữ chính
JavaScript
Star
103
Fork
37
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

First at all, sorry for my english, i will try to explain it as better as possible.

I have the following js code:

```javascript
export const Painter = function (elements, data) {
let title = elements.title;
let container = elements.container;
this.prePaint = () => { };
this.paint = () => { };
this.postPaint = () => { };
let finalPaint = () => {
this.prePaint = () => { };
this.paint = () => { };
this.postPaint = () => { };
createPromise();
};

let createPromise = () => {
return new Promise((resolve, reject) => {
this.paint = () => { resolve() }
}).then(() => {
this.prePaint(elements, data);
title.innerHTML = data.title;
container.innerHTML = data.html;
this.postPaint(elements, data);
finalPaint();
});
}

createPromise();
};
```

When i obfuscate this code, it seems like this (it was minimized and formatted by the browser):
```javascript
5: [function(a, b, c) {
"use strict";
Object[_0x56ae("0x6")](c, _0x56ae("0x6e"), {
value: !0
});
c[_0x56ae("0xb5")] = function(a, b) {
var c = this
, d = a[_0x56ae("0xb6")]
, e = a[_0x56ae("0xb7")];
this.prePaint = function() {} //// THIS LINE
,
this[_0x56ae("0xb8")] = function() {}
,
this[_0x56ae("0xb9")] = function() {}
;
var f = function() {
c[_0x56ae("0xba")] = function() {}
,
c.paint = function() {} ///// THIS LINE TOO
,
c.postPaint = function() {} ///// AND THIS LINE TOO
,
g()
}
, g = function() {
return new Promise(function(a) {
c.paint = function() {
a()
}
}
)[_0x56ae("0x24")](function() {
c[_0x56ae("0xba")](a, b),
d.innerHTML = b[_0x56ae("0xb6")],
e.innerHTML = b[_0x56ae("0x34")],
c.postPaint(a, b),
f()
})
};
g()
}
}
, {}]
```

You can see, how the fisrt this.prePaint has not transformed to this[_0x56ae("0xba")] and when this is called, it said undefined function.
But if i insert breaklines between all this "problematic" lines, it work. Like this:

```javascript

export const Painter = function (elements, data) {
let title = elements.title;
let container = elements.container;

this.prePaint = () => { };

this.paint = () => { };

this.postPaint = () => { };

let finalPaint = () => {

this.prePaint = () => { };

this.paint = () => { };

this.postPaint = () => { };

createPromise();
};

let createPromise = () => {
return new Promise((resolve, reject) => {

this.paint = () => { resolve() }

}).then(() => {
this.prePaint(elements, data);

title.innerHTML = data.title;
container.innerHTML = data.html;

this.postPaint(elements, data);

finalPaint();

});
}

createPromise();
};
```

I did fix this issue with this partial solution, but i don't know where more places of my code, will appear the same issue.

Thank you

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

Hướng nghiên cứu

Không có tệp repository, bài kiểm thử, phiên bản hoặc cấu hình nào được nêu. Hãy bắt đầu bằng cách tái hiện ví dụ Painter được cung cấp thông qua pipeline làm rối của gulp và so sánh các tham chiếu được tạo cho this.prePaint, this.paint và this.postPaint. Được xem là hoàn tất khi mã đã làm rối giữ nguyên các tham chiếu thuộc tính có thể gọi mà không cần chèn các ngắt dòng.

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
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.