🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

javascript-obfuscator

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

javascript-obfuscator - npm Package Compare versions

Comparing version

to
2.10.4

Change Log
v2.10.4
---
* Fixed invalid behaviour of `numbersToExpressions` option for float numbers. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/882
v2.10.3

@@ -4,0 +8,0 @@ ---

{
"name": "javascript-obfuscator",
"version": "2.10.3",
"version": "2.10.4",
"description": "JavaScript obfuscator",

@@ -26,3 +26,3 @@ "keywords": [

"@nuxtjs/opencollective": "0.3.2",
"acorn": "8.0.4",
"acorn": "8.0.5",
"assert": "2.0.0",

@@ -32,3 +32,3 @@ "chalk": "4.1.0",

"class-validator": "0.13.1",
"commander": "7.0.0",
"commander": "7.1.0",
"eslint-scope": "5.1.1",

@@ -51,3 +51,3 @@ "estraverse": "5.2.0",

"@istanbuljs/nyc-config-typescript": "1.0.1",
"@types/chai": "4.2.14",
"@types/chai": "4.2.15",
"@types/chance": "1.1.1",

@@ -59,7 +59,7 @@ "@types/escodegen": "0.0.6",

"@types/js-string-escape": "1.0.0",
"@types/md5": "2.2.1",
"@types/md5": "2.3.0",
"@types/mkdirp": "1.0.1",
"@types/mocha": "8.2.0",
"@types/mocha": "8.2.1",
"@types/multimatch": "4.0.0",
"@types/node": "14.14.21",
"@types/node": "14.14.31",
"@types/rimraf": "3.0.0",

@@ -69,16 +69,16 @@ "@types/sinon": "9.0.10",

"@types/webpack-env": "1.16.0",
"@typescript-eslint/eslint-plugin": "4.13.0",
"@typescript-eslint/parser": "4.13.0",
"chai": "4.2.0",
"@typescript-eslint/eslint-plugin": "4.15.1",
"@typescript-eslint/parser": "4.15.1",
"chai": "4.3.0",
"chai-exclude": "2.0.2",
"cross-env": "7.0.3",
"eslint": "7.18.0",
"eslint": "7.20.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "31.0.5",
"eslint-plugin-jsdoc": "32.1.0",
"eslint-plugin-no-null": "1.0.2",
"eslint-plugin-prefer-arrow": "1.2.2",
"eslint-plugin-unicorn": "26.0.1",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-unicorn": "28.0.2",
"fork-ts-checker-notifier-webpack-plugin": "3.0.0",
"fork-ts-checker-webpack-plugin": "6.1.0",
"mocha": "8.2.1",
"mocha": "8.3.0",
"nyc": "15.1.0",

@@ -88,9 +88,9 @@ "pjson": "1.0.9",

"rimraf": "3.0.2",
"sinon": "9.2.3",
"sinon": "9.2.4",
"threads": "1.6.3",
"ts-loader": "8.0.14",
"ts-loader": "8.0.17",
"ts-node": "9.1.1",
"typescript": "4.1.3",
"webpack": "5.15.0",
"webpack-cli": "4.3.1",
"typescript": "4.1.5",
"webpack": "5.23.0",
"webpack-cli": "4.5.0",
"webpack-node-externals": "2.5.2"

@@ -97,0 +97,0 @@ },

@@ -34,2 +34,3 @@ <!--

* Malta: [malta-js-obfuscator](https://github.com/fedeghe/malta-js-obfuscator)
* Netlify plugin: [netlify-plugin-js-obfuscator](https://www.npmjs.com/package/netlify-plugin-js-obfuscator)

@@ -446,3 +447,3 @@ [![npm version](https://badge.fury.io/js/javascript-obfuscator.svg)](https://badge.fury.io/js/javascript-obfuscator)

--string-array <boolean>
--string-array-calls-index-type '<list>' (comma separated) [hexadecimal-number, hexadecimal-numeric-string]
--string-array-indexes-type '<list>' (comma separated) [hexadecimal-number, hexadecimal-numeric-string]
--string-array-encoding '<list>' (comma separated) [none, base64, rc4]

@@ -449,0 +450,0 @@ --string-array-index-shift <boolean>

@@ -23,2 +23,7 @@ import { injectable, inject } from 'inversify';

/**
* @type {number}
*/
private static readonly delta: number = 10000;
/**
* @type {Map<number, number[]>}

@@ -74,4 +79,4 @@ */

const from: number = Math.min(-10000, -upperNumberLimit);
const to: number = Math.max(10000, upperNumberLimit);
const from: number = Math.min(-NumberNumericalExpressionAnalyzer.delta, -upperNumberLimit);
const to: number = Math.max(NumberNumericalExpressionAnalyzer.delta, upperNumberLimit);

@@ -78,0 +83,0 @@ let temporarySum = 0;

@@ -19,2 +19,3 @@ import { inject, injectable, } from 'inversify';

import { NumberNumericalExpressionAnalyzer } from '../../analyzers/number-numerical-expression-analyzer/NumberNumericalExpressionAnalyzer';
import { NumberUtils } from '../../utils/NumberUtils';
import { NumericalExpressionDataToNodeConverter } from '../../node/NumericalExpressionDataToNodeConverter';

@@ -90,21 +91,39 @@

const numberNumericalExpressionData: TNumberNumericalExpressionData = this.numberNumericalExpressionAnalyzer.analyze(
literalNode.value,
NumberNumericalExpressionAnalyzer.defaultAdditionalPartsCount
);
const baseNumber: number = literalNode.value;
const [integerPart, decimalPart] = NumberUtils.extractIntegerAndDecimalParts(baseNumber);
const integerNumberNumericalExpressionData: TNumberNumericalExpressionData = this.numberNumericalExpressionAnalyzer
.analyze(
integerPart,
NumberNumericalExpressionAnalyzer.defaultAdditionalPartsCount
);
return NumericalExpressionDataToNodeConverter.convert(
numberNumericalExpressionData,
(number: number, isPositiveNumber: boolean) => {
const numberLiteralNode: ESTree.Literal = NodeFactory.literalNode(number);
if (decimalPart) {
return NumericalExpressionDataToNodeConverter.convertFloatNumberData(
integerNumberNumericalExpressionData,
decimalPart,
this.getNumberNumericalExpressionLiteralNode
);
} else {
return NumericalExpressionDataToNodeConverter.convertIntegerNumberData(
integerNumberNumericalExpressionData,
this.getNumberNumericalExpressionLiteralNode
);
}
}
return isPositiveNumber
? numberLiteralNode
: NodeFactory.unaryExpressionNode(
'-',
numberLiteralNode
);
}
);
/**
* @param {number} number
* @param {boolean} isPositiveNumber
* @returns {Expression}
*/
private getNumberNumericalExpressionLiteralNode (number: number, isPositiveNumber: boolean): ESTree.Expression {
const numberLiteralNode: ESTree.Literal = NodeFactory.literalNode(number);
return isPositiveNumber
? numberLiteralNode
: NodeFactory.unaryExpressionNode(
'-',
numberLiteralNode
);
}
}

@@ -111,9 +111,5 @@ import { inject, injectable, } from 'inversify';

isForceTransformNode = obfuscatingGuardResults
.some((obfuscatingGuardResult: ObfuscatingGuardResult) =>
obfuscatingGuardResult === ObfuscatingGuardResult.ForceTransform
);
.includes(ObfuscatingGuardResult.ForceTransform);
isIgnoredNode = !isForceTransformNode && obfuscatingGuardResults
.some((obfuscatingGuardResult: ObfuscatingGuardResult) =>
obfuscatingGuardResult === ObfuscatingGuardResult.Ignore
);
.includes(ObfuscatingGuardResult.Ignore);
}

@@ -120,0 +116,0 @@

@@ -228,3 +228,3 @@ import { inject, injectable, } from 'inversify';

const comparisonExpressionNode: ESTree.Expression = NumericalExpressionDataToNodeConverter.convert(
const comparisonExpressionNode: ESTree.Expression = NumericalExpressionDataToNodeConverter.convertIntegerNumberData(
comparisonExpressionNumberNumericalExpressionData,

@@ -231,0 +231,0 @@ ((number: number, isPositiveNumber) => {

@@ -18,3 +18,3 @@ import * as ESTree from 'estree';

*/
public static convert (
public static convertIntegerNumberData (
numberNumericalExpressionData: TNumberNumericalExpressionData,

@@ -30,2 +30,26 @@ literalNodeGetter: TNumericalExpressionDataToNodeConverterLiteralNodeGetter

/**
* @param {TNumberNumericalExpressionData} integerNumberNumericalExpressionData
* @param {number} decimalPart
* @param {TNumericalExpressionDataToNodeConverterLiteralNodeGetter} literalNodeGetter
* @returns {Expression}
*/
public static convertFloatNumberData (
integerNumberNumericalExpressionData: TNumberNumericalExpressionData,
decimalPart: number,
literalNodeGetter: TNumericalExpressionDataToNodeConverterLiteralNodeGetter
): ESTree.Expression {
const integerNumberNumericalExpressionNode: ESTree.Expression = NumericalExpressionDataToNodeConverter
.convertNumericalExpressionDataToNode(
integerNumberNumericalExpressionData,
literalNodeGetter
);
return NodeFactory.binaryExpressionNode(
'+',
integerNumberNumericalExpressionNode,
NodeFactory.literalNode(decimalPart)
);
}
/**
* @param {TNumberNumericalExpressionData} numberNumericalExpressionData

@@ -32,0 +56,0 @@ * @param {TNumericalExpressionDataToNodeConverterLiteralNodeGetter} literalNodeGetter

@@ -20,2 +20,15 @@ import { Utils } from './Utils';

* @param {number} number
* @returns {[number, (number | null)]}
*/
public static extractIntegerAndDecimalParts (number: number): [number, number | null] {
const integerPart: number = Math.trunc(number);
const decimalPart: number | null = number !== integerPart
? number % 1
: null;
return [integerPart, decimalPart];
}
/**
* @param {number} number
* @returns {boolean}

@@ -22,0 +35,0 @@ */

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet