Skip to content

target node change class name #531

Closed

Description

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

Activity

  1. sanex3339 commented on Jan 27, 2020

    @sanex3339
    Member

    Will try to fix soon

  2. sanex3339 commented on Jan 27, 2020

    @sanex3339
    Member

    renameGlobals breaking this code too

  3. sanex3339 commented on Jan 27, 2020

    @sanex3339
    Member

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

  4. sanex3339 commented on Jan 27, 2020

    @sanex3339
    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;
                }
            });
    
  5. sanex3339 commented on Jan 27, 2020

    @sanex3339
    Member

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

  6. sanex3339 commented on Jan 27, 2020

    @sanex3339
    Member

    Released as 0.24.1 please try it

  7. ghost closed this as completedon Jan 27, 2020
  8. sanex3339 commented on Jan 27, 2020

    @sanex3339
    Member

    Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions