mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
fixed tests and codestyle
This commit is contained in:
Vendored
+4
-4
@@ -2413,7 +2413,7 @@ var CatchClauseObfuscator = function (_AbstractNodeObfuscat) {
|
||||
|
||||
NodeUtils_1.NodeUtils.typedReplace(catchClauseNode.param, NodeType_1.NodeType.Identifier, {
|
||||
leave: function leave(node) {
|
||||
_this2.identifierReplacer.storeNames(node.name);
|
||||
return _this2.identifierReplacer.storeNames(node.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2487,7 +2487,7 @@ var FunctionDeclarationObfuscator = function (_AbstractNodeObfuscat) {
|
||||
|
||||
NodeUtils_1.NodeUtils.typedReplace(functionDeclarationNode.id, NodeType_1.NodeType.Identifier, {
|
||||
leave: function leave(node) {
|
||||
_this2.identifierReplacer.storeNames(node.name);
|
||||
return _this2.identifierReplacer.storeNames(node.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2560,7 +2560,7 @@ var FunctionObfuscator = function (_AbstractNodeObfuscat) {
|
||||
functionNode.params.forEach(function (paramsNode) {
|
||||
NodeUtils_1.NodeUtils.typedReplace(paramsNode, NodeType_1.NodeType.Identifier, {
|
||||
leave: function leave(node) {
|
||||
_this2.identifierReplacer.storeNames(node.name);
|
||||
return _this2.identifierReplacer.storeNames(node.name);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -2943,7 +2943,7 @@ var VariableDeclarationObfuscator = function (_AbstractNodeObfuscat) {
|
||||
variableDeclarationNode.declarations.forEach(function (declarationNode) {
|
||||
NodeUtils_1.NodeUtils.typedReplace(declarationNode.id, NodeType_1.NodeType.Identifier, {
|
||||
leave: function leave(node) {
|
||||
_this2.identifierReplacer.storeNames(node.name);
|
||||
return _this2.identifierReplacer.storeNames(node.name);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,9 +50,7 @@ export class CatchClauseObfuscator extends AbstractNodeObfuscator {
|
||||
*/
|
||||
private storeCatchClauseParam (catchClauseNode: ICatchClauseNode): void {
|
||||
NodeUtils.typedReplace(catchClauseNode.param, NodeType.Identifier, {
|
||||
leave: (node: IIdentifierNode) => {
|
||||
this.identifierReplacer.storeNames(node.name)
|
||||
}
|
||||
leave: (node: IIdentifierNode) => this.identifierReplacer.storeNames(node.name)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,7 @@ export class FunctionDeclarationObfuscator extends AbstractNodeObfuscator {
|
||||
*/
|
||||
private storeFunctionName (functionDeclarationNode: IFunctionDeclarationNode): void {
|
||||
NodeUtils.typedReplace(functionDeclarationNode.id, NodeType.Identifier, {
|
||||
leave: (node: IIdentifierNode) => {
|
||||
this.identifierReplacer.storeNames(node.name)
|
||||
}
|
||||
leave: (node: IIdentifierNode) => this.identifierReplacer.storeNames(node.name)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,7 @@ export class FunctionObfuscator extends AbstractNodeObfuscator {
|
||||
functionNode.params
|
||||
.forEach((paramsNode: INode) => {
|
||||
NodeUtils.typedReplace(paramsNode, NodeType.Identifier, {
|
||||
leave: (node: IIdentifierNode) => {
|
||||
this.identifierReplacer.storeNames(node.name)
|
||||
}
|
||||
leave: (node: IIdentifierNode) => this.identifierReplacer.storeNames(node.name)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,9 +60,7 @@ export class VariableDeclarationObfuscator extends AbstractNodeObfuscator {
|
||||
variableDeclarationNode.declarations
|
||||
.forEach((declarationNode: IVariableDeclaratorNode) => {
|
||||
NodeUtils.typedReplace(declarationNode.id, NodeType.Identifier, {
|
||||
leave: (node: IIdentifierNode) => {
|
||||
this.identifierReplacer.storeNames(node.name)
|
||||
}
|
||||
leave: (node: IIdentifierNode) => this.identifierReplacer.storeNames(node.name)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ describe('VariableDeclarationObfuscator', () => {
|
||||
Object.assign({}, NO_CUSTOM_NODES_PRESET)
|
||||
);
|
||||
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /var *_0x([a-z0-9]){6} *= *'\\x61\\x62\\x63';/);
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){6}\);/);
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /var *_0x([a-z0-9]){5,6} *= *'\\x61\\x62\\x63';/);
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){5,6}\);/);
|
||||
});
|
||||
|
||||
it('should obfuscate variable call (`identifier` node) outside of block scope of node in which this variable was declared with `var` kind', () => {
|
||||
@@ -35,7 +35,7 @@ describe('VariableDeclarationObfuscator', () => {
|
||||
Object.assign({}, NO_CUSTOM_NODES_PRESET)
|
||||
);
|
||||
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){6}\);/);
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){5,6}\);/);
|
||||
});
|
||||
|
||||
it('should not obfuscate variable call (`identifier` node) outside of block scope of node in which this variable was declared with `let` kind', () => {
|
||||
@@ -78,7 +78,7 @@ describe('VariableDeclarationObfuscator', () => {
|
||||
});
|
||||
|
||||
it('should obfuscate variable call (`identifier` node) before variable declaration if this call is inside function body', () => {
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){6}\['\\x69\\x74\\x65\\x6d'\]\);/);
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /console\['\\x6c\\x6f\\x67'\]\(_0x([a-z0-9]){5,6}\['\\x69\\x74\\x65\\x6d'\]\);/);
|
||||
});
|
||||
|
||||
it('should not obfuscate variable call (`identifier` node) before variable declaration', () => {
|
||||
@@ -103,7 +103,7 @@ describe('VariableDeclarationObfuscator', () => {
|
||||
Object.assign({}, NO_CUSTOM_NODES_PRESET)
|
||||
);
|
||||
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /var _0x([a-z0-9]){6} *= *\{'\\x74\\x65\\x73\\x74/);
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /var _0x([a-z0-9]){5,6} *= *\{'\\x74\\x65\\x73\\x74/);
|
||||
});
|
||||
|
||||
it('shouldn\'t replace computed member expression identifier', () => {
|
||||
@@ -123,7 +123,7 @@ describe('VariableDeclarationObfuscator', () => {
|
||||
Object.assign({}, NO_CUSTOM_NODES_PRESET)
|
||||
);
|
||||
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /_0x([a-z0-9]){6}\['\\x74\\x65\\x73\\x74'\]/);
|
||||
assert.match(obfuscationResult.getObfuscatedCode(), /_0x([a-z0-9]){5,6}\['\\x74\\x65\\x73\\x74'\]/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user