jscrambler 8.9.0 → 8.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +14 -1
- package/dist/bin/jscrambler.js +6 -3
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -144,6 +144,7 @@ Options:
|
|
|
144
144
|
--mode <mode> (version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)
|
|
145
145
|
--save-src <bool> Protection should save application sources (default: true)
|
|
146
146
|
--protection-report <string> (version 8.4 and above) Protection id for the metadata report
|
|
147
|
+
--use-global-names-on-modules <bool> (version 8.5 and above) Force the usage of more complex names on modules (default: false)
|
|
147
148
|
-h, --help output usage information
|
|
148
149
|
```
|
|
149
150
|
|
|
@@ -393,6 +394,18 @@ Similarly, the resulting symbol table can be obtained using the `--output-symbol
|
|
|
393
394
|
|
|
394
395
|
**NOTE**: It only makes sense to use symbol tables on protections that use the identifiers renaming parameter.
|
|
395
396
|
|
|
397
|
+
## Use Global Names On Modules
|
|
398
|
+
|
|
399
|
+
When we detect we're protecting an ES module, we may generate top-level single-character identifiers for code size purposes. If, in your use case, you expect to transpile this module into a script using a tool that cannot guarantee ES Module isolation (as it should), this may lead to collisions, especially if you're doing this with multiple obfuscated modules.
|
|
400
|
+
To reduce the chance of collisions, you can set the `useGlobalNamesOnModules` option on your protection request:
|
|
401
|
+
|
|
402
|
+
// jscrambler.json
|
|
403
|
+
{
|
|
404
|
+
"useGlobalNamesOnModules": true
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
If you apply the previous configuration, all generated global variable names will follow the same principle as global variables (not on modules), and have at least 5 characters, thus reducing the chance of collisions.
|
|
408
|
+
|
|
396
409
|
## Global Names Prefix
|
|
397
410
|
|
|
398
411
|
If you need to make **separate obfuscation requests** for source code that belong to the same application instance, there is a small chance that you will encounter a **naming collision** on the generate global names.
|
|
@@ -411,7 +424,7 @@ To prevent **global naming collisions**, you can set the `globalNamesPrefix` par
|
|
|
411
424
|
}
|
|
412
425
|
```
|
|
413
426
|
|
|
414
|
-
If apply the previous configuration, all generated global variable names will start with the letters *p1* for *micro-frontend 1* and *p2* for *micro-frontend 2*.
|
|
427
|
+
If you apply the previous configuration, all generated global variable names will start with the letters *p1* for *micro-frontend 1* and *p2* for *micro-frontend 2*.
|
|
415
428
|
|
|
416
429
|
***Note***: The `globalNamesPrefix` parameter must be **short** and **unintelligible** to avoid code size increase and automated attacks
|
|
417
430
|
|
package/dist/bin/jscrambler.js
CHANGED
|
@@ -106,7 +106,7 @@ const validateBeforeProtection = function () {
|
|
|
106
106
|
});
|
|
107
107
|
return beforeProtectionArray;
|
|
108
108
|
};
|
|
109
|
-
_commander.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--base-path <path>', 'Base Path').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--instrument', 'Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted').option('--start-profiling', 'Starts profiling (assumes an already instrumented application)').option('--stop-profiling', 'Stops profiling').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--utc <bool>', 'Set UTC as the request time zone. Otherwise it uses the local time zone (default: true)', validateBool('utc')).option('--tolerate-minification <bool>', "Don't detect minification as malicious tampering (default: true)", validateBool('tolerate-minification')).option('--use-profiling-data <bool>', "(version 6.2 only) Protection should use the existing profiling data (default: true)", validateBool('use-profiling-data')).option('--profiling-data-mode <mode>', "(version 6.3 and above) Select profiling mode (default: automatic)", validateProfilingDataMode).option('--remove-profiling-data', "Removes the current application profiling information").option('--use-app-classification <bool>', '(version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--input-symbol-table <file>', '(version 6.3 and above) Protection should use symbol table when protecting. (default: no file)').option('--output-symbol-table <id>', '(version 6.3 and above) Download output symbol table (json)').option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').option('--skip-sources', 'Prevent source files from being updated').option('--force-app-environment <environment>', "(version 7.1 and above) Override application's environment detected automatically. Possible values: ".concat(availableEnvironments.toString()), validateForceAppEnvironment).option('--ensure-code-annotation <bool>', "(version 7.3 and above) Fail protection if no annotations are found on the source code (default: false)", validateBool('ensure-code-annotation')).option('-n <number>', "(version 7.2 and above) Create multiple protections at once.").option('--delete-protection-on-success <bool>', 'Deletes the protection files after they have been protected and downloaded (default: false)', validateBool('--delete-protection-on-success')).option('--mode <mode>', "(version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)", validateMode).option('--save-src <bool>', 'Protection should save application sources (default: true)', validateBool('--save-src')).option('--protection-report <string>', '(version 8.4 and above) Protection id for the metadata report').option('--balance', '(version 8.4 and above) Gets the balance of the user').parse(process.argv);
|
|
109
|
+
_commander.default.version(require('../../package.json').version).usage('[options] <file ...>').option('-a, --access-key <accessKey>', 'Access key').option('-c, --config <config>', 'Jscrambler configuration options').option('-H, --host <host>', 'Hostname').option('-i, --application-id <id>', 'Application ID').option('-o, --output-dir <dir>', 'Output directory').option('-p, --port <port>', 'Port').option('--base-path <path>', 'Base Path').option('--protocol <protocol>', 'Protocol (http or https)').option('--cafile <path>', 'Internal certificate authority').option('-C, --cwd <dir>', 'Current Working Directory').option('-s, --secret-key <secretKey>', 'Secret key').option('-m, --source-maps <id>', 'Download source maps').option('-R, --randomization-seed <seed>', 'Set randomization seed').option('--instrument', 'Instrument file(s) before start profiling. ATTENTION: previous profiling information will be deleted').option('--start-profiling', 'Starts profiling (assumes an already instrumented application)').option('--stop-profiling', 'Stops profiling').option('--code-hardening-threshold <threshold>', 'Set code hardening file size threshold. Format: {value}{unit="b,kb,mb"}. Example: 200kb', validateCodeHardeningThreshold).option('--recommended-order <bool>', 'Use recommended order', validateBool('recommended-order')).option('-W, --werror <bool>', 'Set werror flag value (default: true)', validateBool('werror')).option('--utc <bool>', 'Set UTC as the request time zone. Otherwise it uses the local time zone (default: true)', validateBool('utc')).option('--tolerate-minification <bool>', "Don't detect minification as malicious tampering (default: true)", validateBool('tolerate-minification')).option('--use-profiling-data <bool>', "(version 6.2 only) Protection should use the existing profiling data (default: true)", validateBool('use-profiling-data')).option('--profiling-data-mode <mode>', "(version 6.3 and above) Select profiling mode (default: automatic)", validateProfilingDataMode).option('--remove-profiling-data', "Removes the current application profiling information").option('--use-app-classification <bool>', '(version 6.3 and above) Protection should use Application Classification metadata when protecting (default: true)', validateBool('--use-app-classification')).option('--input-symbol-table <file>', '(version 6.3 and above) Protection should use symbol table when protecting. (default: no file)').option('--output-symbol-table <id>', '(version 6.3 and above) Download output symbol table (json)').option('--jscramblerVersion <version>', 'Use a specific Jscrambler version').option('--debugMode', 'Protect in debug mode').option('--skip-sources', 'Prevent source files from being updated').option('--force-app-environment <environment>', "(version 7.1 and above) Override application's environment detected automatically. Possible values: ".concat(availableEnvironments.toString()), validateForceAppEnvironment).option('--ensure-code-annotation <bool>', "(version 7.3 and above) Fail protection if no annotations are found on the source code (default: false)", validateBool('ensure-code-annotation')).option('-n <number>', "(version 7.2 and above) Create multiple protections at once.").option('--delete-protection-on-success <bool>', 'Deletes the protection files after they have been protected and downloaded (default: false)', validateBool('--delete-protection-on-success')).option('--mode <mode>', "(version 8.4 and above) Define protection mode. Possible values: automatic, manual (default: manual)", validateMode).option('--save-src <bool>', 'Protection should save application sources (default: true)', validateBool('--save-src')).option('--protection-report <string>', '(version 8.4 and above) Protection id for the metadata report').option('--use-global-names-on-modules <bool>', '(version 8.5 and above) Force the usage of more complex names on modules').option('--balance', '(version 8.4 and above) Gets the balance of the user').parse(process.argv);
|
|
110
110
|
let globSrc, filesSrc, config;
|
|
111
111
|
|
|
112
112
|
// If -c, --config file was provided
|
|
@@ -140,6 +140,7 @@ config.debugMode = _commander.default.debugMode || config.debugMode;
|
|
|
140
140
|
config.instrument = _commander.default.instrument || config.instrument;
|
|
141
141
|
config.mode = _commander.default.mode || config.mode;
|
|
142
142
|
config.globalNamesPrefix = _commander.default.globalNamesPrefix || config.globalNamesPrefix;
|
|
143
|
+
config.useGlobalNamesOnModules = _commander.default.useGlobalNamesOnModules || config.useGlobalNamesOnModules;
|
|
143
144
|
|
|
144
145
|
// handle codeHardening = 0
|
|
145
146
|
if (typeof _commander.default.codeHardeningThreshold === 'undefined') {
|
|
@@ -275,7 +276,8 @@ const {
|
|
|
275
276
|
deleteProtectionOnSuccess,
|
|
276
277
|
mode,
|
|
277
278
|
saveSrc,
|
|
278
|
-
globalNamesPrefix
|
|
279
|
+
globalNamesPrefix,
|
|
280
|
+
useGlobalNamesOnModules
|
|
279
281
|
} = config;
|
|
280
282
|
const params = config.params;
|
|
281
283
|
const incompatibleOptions = ['sourceMaps', 'instrument', 'startProfiling', 'stopProfiling'];
|
|
@@ -417,7 +419,8 @@ if (_commander.default.balance) {
|
|
|
417
419
|
deleteProtectionOnSuccess,
|
|
418
420
|
mode,
|
|
419
421
|
saveSrc,
|
|
420
|
-
globalNamesPrefix
|
|
422
|
+
globalNamesPrefix,
|
|
423
|
+
useGlobalNamesOnModules
|
|
421
424
|
});
|
|
422
425
|
try {
|
|
423
426
|
if (typeof werror !== 'undefined') {
|
package/dist/index.js
CHANGED
|
@@ -285,7 +285,8 @@ var _default = exports.default = {
|
|
|
285
285
|
deleteProtectionOnSuccess,
|
|
286
286
|
mode,
|
|
287
287
|
saveSrc,
|
|
288
|
-
globalNamesPrefix
|
|
288
|
+
globalNamesPrefix,
|
|
289
|
+
useGlobalNamesOnModules
|
|
289
290
|
} = finalConfig;
|
|
290
291
|
const {
|
|
291
292
|
accessKey,
|
|
@@ -407,7 +408,8 @@ var _default = exports.default = {
|
|
|
407
408
|
numberOfProtections,
|
|
408
409
|
forceAppEnvironment,
|
|
409
410
|
mode,
|
|
410
|
-
globalNamesPrefix
|
|
411
|
+
globalNamesPrefix,
|
|
412
|
+
useGlobalNamesOnModules
|
|
411
413
|
});
|
|
412
414
|
if (finalConfig.inputSymbolTable) {
|
|
413
415
|
const inputSymbolTableContents = await _fs.default.promises.readFile(finalConfig.inputSymbolTable, 'utf-8');
|
package/package.json
CHANGED