javascript-obfuscator / javascript-obfuscator/webpack-obfuscator

identifierNamesCache not working as expected

Offen
#127 0 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
TypeScript
Sterne
928
Forks
92
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Untersuchung der obfuscate-Methode in der gebauten index.js und des Ablaufs der Option identifierNamesCache. Reproduziere das Problem mit Webpack 5 über mehrere voneinander abhängige Dateien hinweg und überprüfe anschließend, dass der Cache zwischen den Obfuskationsergebnissen weitergegeben wird und die Dateien konsistent obfuskiert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript, webpack
Bereich
build-system, tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.