Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target node change class name #531

Closed
LiadDrori opened this issue Jan 27, 2020 · 9 comments
Closed

target node change class name #531

LiadDrori opened this issue Jan 27, 2020 · 9 comments
Labels

Comments

@LiadDrori
Copy link

Class Name should change when calling static methods

Expected Behavior

  1. As the documentation says

Currently the output of browser and node is identical.

But there is a difference between them.

  1. When a class name change it should change the class name in static method calls

Current Behavior

  1. difference between the target node and browser
  2. when calling static methods class name should also change

Steps to Reproduce

Code exmple:

class A { 
	static async one(){
    	
    }
  
  	static async two(){
    	await A.one()
    }

}

When using target=Brwoser:

class A {
    static async ['one']() {
    }
    static async ['two']() {
        await A['one']();
    }
}

When using target=node:

class _0xd91f5a {
    static async ['one']() {
    }
    static async ['two']() {
        await A['one']();
    }
}

When running with a target node you get error because A is not defined

Your Environment

  • Obfuscator version used: 0.24.0
  • Node version used: 12.4
@sanex3339 sanex3339 added the bug label Jan 27, 2020
@sanex3339
Copy link
Member

Will try to fix soon

@LiadDrori
Copy link
Author

Besides this, are there are any other differences between node and browser?
I run my code on node, so is it safe for now, until you fix the bug, to change to browser?

@sanex3339
Copy link
Member

renameGlobals breaking this code too

@sanex3339
Copy link
Member

@LiadDrori currently Node target should affect only how identifiers are renamed

@sanex3339
Copy link
Member

Should sanitize class scopes like this:

// fast fix of class scopes
        scope.childScopes.filter((scope: eslintScope.Scope) => {
            if (scope.type === 'class') {
                const upperVariable: eslintScope.Variable = <any>scope.upper?.variables.find((variable: eslintScope.Variable) => {
                    return variable.name === scope.variables[0].name;
                });

                upperVariable.references.push(...scope.variables[0].references);

                return false;
            }
        });

@sanex3339
Copy link
Member

After this pr, here should be no difference between Node and Browser targets in terms of variable names.

@sanex3339
Copy link
Member

Released as 0.24.1 please try it

@LiadDrori
Copy link
Author

Seems to work for me to,

Thanks for the help!!!

@sanex3339
Copy link
Member

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants