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

Bug in obfuscate js code.

Abierto
#24 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug cannot reproduce
Lenguaje dominante
JavaScript
Estrellas
103
Forks
37
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

No se especifica ningún archivo del repositorio, prueba, versión ni configuración. Empieza reproduciendo el ejemplo de Painter proporcionado mediante el pipeline de ofuscación de gulp y compara las referencias generadas para this.prePaint, this.paint y this.postPaint. Se considera hecho cuando el código ofuscado conserva las referencias a propiedades invocables sin requerir saltos de línea insertados.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
build-system, tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.