javascript-obfuscator / javascript-obfuscator/webpack-obfuscator

How to onfuscate only my own code using webpack-obfuscator?

オープン
#178 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
928
フォーク
92
PR マージ指標
30日以内にマージされた PR はありません

説明

I'm building an electron application using TypeScript and WebPack. I want to process my own code without touching any 3rd party dependencies in order to rename only my own classes property names.

I've tried to use two approaches but with no success:
1) Using plugin

```typescript
import path from 'node:path';
import type { Configuration } from 'webpack';

import { rules } from './webpack.rules';
import WebpackObfuscator from 'webpack-obfuscator';

export const mainConfig: Configuration = {
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: "./src/index.ts",
// Put your normal webpack config below here
module: {
rules
},
plugins: [
new WebpackObfuscator({
sourceMap: true,
renameProperties: true,
rotateStringArray: true
}, "node_modules/")
],
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx", ".css", ".json"],
// Workaround to make import aliases ("paths" from tscondig.json) work
// https://stackoverflow.com/a/75373097/6698055
alias: {
"@domain": path.resolve(__dirname, "src/domain"),
"@platform": path.resolve(__dirname, "src/platform"),
"@build_src": path.resolve(__dirname, "build_src")
}
}
};
```

2) Using loader

```typescript
import type { ModuleOptions } from 'webpack';
import WebpackObfuscator from 'webpack-obfuscator';
import path from 'node:path'

export const rules: Required["rules"] = [
// Add support for native node modules
{
// We're specifying native_modules in the test because the asset relocator loader generates a
// "fake" .node file which is really a cjs file.
test: /native_modules[/\\].+\.node$/,
use: "node-loader"
},
{
test: /[/\\]node_modules[/\\].+\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: "@vercel/webpack-asset-relocator-loader",
options: {
outputAssetBase: "native_modules"
}
}
},
{
test: /\.js$/,
enforce: 'post', // Ensure this loader will be called after normal loaders
use: {
loader: WebpackObfuscator.loader,
options: {
rotateStringArray: true,
renameProperties: true
}
}
}
];
```

How can I force WebPack to process only my own code without touching any dependencies?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

webpack のメイン設定と webpack.rules のルールから始め、バンドルされたモジュールに対する plugin と loader のマッチに注目してください。Electron の webpack ビルドを実行し、その出力を調べて、どのモジュールが難読化されているかを判断してください。アプリケーション独自の TypeScript コードが処理され、サードパーティ依存関係が変更されない状態になれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
electron, typescript, webpack
領域
build-system, desktop
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。