Coder Social home page Coder Social logo

yworks / yguard Goto Github PK

View Code? Open in Web Editor NEW
340.0 15.0 59.0 12.26 MB

The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts

Home Page: https://yworks.github.io/yGuard/

License: MIT License

Java 100.00%
obfuscation java ant bytecode-manipulation gradle-plugin ant-task obfuscator hacktoberfest

yguard's Introduction

yGuard

Continous Integration for yGuard

yGuard is an open-source Java obfuscation tool. With yGuard it is easy as pie (๐Ÿฐ) to configure obfuscation through an extensive ant task.

yGuard is brought to you by yWorks GmbH, creator of the family of graph and diagram visualization frameworks yFiles and other fine products.

Obtaining yGuard

Recent yGuard releases can be downloaded from GitHub, or used from Maven central directly.

Previous releases may still be downloaded from the yWorks download center.

Usage

An online version of this documentation is available.

Additionally, yGuard is distributed with usage instructions. In your distribution, the docs folder contains informtion about yGuard. Browse docs/index.html to view the documentation.

Examples

yGuard comes with a exhaustive set of examples to cover many use cases. Please review the list of examples in the examples directory.

Users of yGuard

Below you will find a list of users relying on yGuard to keep their product secure.

If your product uses yGuard as well and you would like to add it to this list, please contact us.

Development

Building

To build yGuard you will need Java >= 7.

Download the repository and build yGuard using ./gradlew build.

The bundle version (for Ant users) is built using the assembleBundleDist task (e.g ./gradlew assembleBundleDist). The assembleBundleDist task comes with a optional parameter to copy documentation (-Pcopy-docs).

In order to build the documentation you will need mkdocs:

pip3 install mkdocs mkdocs-material # or use a virtual environment if you prefer
mkdocs build

Using IntellIJ with yGuard

yGuard will be loaded without further ado from IntellIJ thanks to the Gradle integration. Opening the yGuard folder will set up Gradle and mark sources, tests and resources accordingly.

yguard's People

Contributors

ao-apps avatar dependabot[bot] avatar fohlen avatar hassan-elseoudy avatar jroessel avatar kyongsik-yoon avatar ptorngren avatar thomasbehr avatar timurdaas avatar vampire avatar wouter-admiraal-sonarsource avatar yguy avatar youreminence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yguard's Issues

Public inheritance of internal classes does not seem to work correctly

Verify if this works:

package p1;

class Base {
protected void foo() {}
}

public class PublicInherited extends Base {
}

###########################################
package p2;

public class Broken extends p1.PublicInherited {
//foo should be accessible here
}

@micschro suggested the following workaround:

<class classes="none" methods="protected" fields="protected">
  <patternset>
    <include  name="y.view.EdgeSplitSupportImpl"/>
  </patternset>
</class&gt;

Propose a flow obfuscation mode

Many obfuscation tools throughout different languages support "flow obfuscation". The process how this can be done is fairly accurately described in this post. yGuard may (or may not) support such a mode. The implementation should try to generate some simple flow obfuscation that can be optionally enabled (during the rename task). One could then enhance these capabilities.

ERROR: Illegal char <:> in jar shrinking

Hello,

I'm using the latest version of yGuard to shrink and rename (obfuscate) a jar archive. I created an ant script (see the file "build.xml" in the attached zip - the user name in the paths is substituted with some asterisks) using the latest version of Eclipse with the JDK11 on Windows 10, but the shrink operation fails with the message reported in the object (see also the file "yshrinklog.xml"). It seems that yguard interprets uncorrectly the Windows path (as a Unix path? - see the prepended slash). For uploading problems the zip is protected with password "password".

Any ideas?

docs.zip
Issue62.zip

Annotation @Obfuscation causes error: package com.yworks.util.annotation does not exist

Based on this documentation page: https://yworks.github.io/yGuard/task_documentation/#controlling-obfuscation-exclusion-with-annotations

...I am trying to exclude the main function of my class from Obfuscation using:

  @com.yworks.util.annotation.Obfuscation( exclude = true, applyToMembers = false)
  public static void main(String[] args) {
    try {
      new Start();
    } catch (SQLException e) {
      LOGGER.error(e, e);
    }
  }

My IDE (Eclipse 2019-14) apparently believes that package path to be valid, since it does not show an error.

However, when I try to Gradle build the project, I get the following error:

...\Start.java:22: error: package com.yworks.util.annotation does not exist
  @com.yworks.util.annotation.Obfuscation( exclude = true, applyToMembers = false)
                             ^

In my build.gradle, I only import the following from yGuard:

	compile 'com.yworks:yguard:2.9.2'

I don't know the dependency tree, or where I would get the com.yworks.util.annotation package from. I have tried various approaches, but most of them made it only worse.

At best, I am doing something wrong, in which case I would be grateful if the documentation about how to use these annotations could be made clearer.

At worst, something is broken right now and the @obfuscation Annotation is not working.

Scala compiler bytecode issue

Interestingly the bytecode produced by the scala compiler indicates that
method MyAction.setEnabled is called - unfortunately there is no such
method, instead the AbstractAction.setEnabled is called. The javac
compiler does not emit this kind of bytecode, but rather inserts the
root definition of the method (MyAction does not override setEnabled and
thus there is no MyActoin.setEnabled). This is not a problem for the
JVM, obviously because this is for keeping backwards compatible if code
changes in the future (an implementation of a method is moved to a super
class), however obviously yGuard cannot deal with this construct and
fails to obfuscate the scala code correctly. Dealing with this case is
not trivial.

scalabytecode.zip

Add Android example

yGuard can be used to obfuscate code that will result in an APK. In order to this one needs to:

  • disable R8 obfuscation and shrinking
  • use yGuard as an extra step in the build file
  • run D8 after yGuard

This has the benefit that yGuard is very extensible and well documented in comparison to R8.
Potentially this should be accompanied with a small Hello World app and Android Studio Project file.

Useful information can be found in the Google documentation.

Inconsistent behavior for conflicting naming rules

if classes are excluded from obfuscation in the <keep> section or by the mainclass attribute, but part of the fully qualified nam of these classes is explicitly mapped using the <map> element, yGuard adheres to the <map> element for the actual renaming, but doesn't reflect this in the output log. Therefore, deobfuscating stacktraces using the logfile doesn't work.

inconsistentconflicting.zip

Dependent files break after obuscation

I am in the situation where I have to obfuscate two related JARS: A main JAR containing the module and a library that contains components that are shared between multiple components. But thus far, everything I've tried has resulted in the module not finding the shared components.

Here is one attempt:

task yGuardObfuscate {
	group 'yGuard'
	description 'Obfuscates existing archives.'
	dependsOn "installDist"

	doLast {
		ant.taskdef(
			name: 'yguard',
			classname: 'com.yworks.yguard.YGuardTask',
				classpath: sourceSets.main.runtimeClasspath.asPath
			)
		
		ant.yguard {
			inoutpairs {
				fileset(dir: "./build/install/module") {
					include(name: "module*.jar")
					include(name: "lib/project-lib*.jar")
					exclude(name: "*_obf.jar")
					exclude(name: "lib/*_obf.jar")
				}
			}
			
			rename(logFile: "./build/install/module/rename.log", annotationClass: "io.company.project.module.annotations.Obfuscation") {
				property(name: "naming-scheme", value: "short")
			}
		}
	}
}

This compiles. However, when I try to run it, I get a variation of the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: A/A/A/A/B
[...]
Caused by: java.lang.ClassNotFoundException: A.A.A.A.B

I have by now also seen this in various variations, the most expressive one was when I manually renamed the project-lib_obf-file:

Exception in thread "main" java.lang.NoClassDefFoundError: com/company/project/api/Settings
[...]
Caused by: java.lang.ClassNotFoundException: com/company/project/api/Settings

...with com.company.project.api being the namespace of the project-lib.

I remember reading something about obfuscation not working with API. Is this a case like that? I really hope not, because the module uses, like, really many classes of the project-lib.

In essence, I feel there should be a way to make this work in a way that the classes and references are obfuscated in a way that allows cross-referencing between them. However, I have read the documentation back and forth and can't figure out how to do this.

Can someone please help me out with this?

Add support for directories in inoutpairs

While creating the processing example I noticed that for certain use cases it is indeed annoying to create a JAR as input or output. It is technically feasible, and reasonably easy to implement directories for input.

I will want to make the file extensions the inoutpair optional. If you do not specify .jar as your file extension yGuard should assume we are reading from a directory.

Other than external usage this greatly simplifies testing efforts (run javac in a directory, obfuscate on that).

Set up Travis for CD

  • Upload obfuscated dist to GitHub releases on tag
  • Upload JavaDoc to GitHub releases on tag

MANIFEST Main-Class attribute is not fully supported

path to a main class has to be in the format com.yworks.MyMainClass for yGuard to replace the name correctly, whereas it is also possible in the jar file format to write it like com/yworks/MyMainClass. Using the latter will lead to an invalid jar file.

yGuard locks jars referenced in externalclasses element

A jar that is referenced in the externalclasses element in the yGuard task is locked even after yGuard has finished and thus cannot be moved/deleted.

The problem is that the URLClassLoader in the classes that implement ClassResolver in obfuscate and shrink are never released. Since Java 7 there is a method URLClassLoader.close() which closes all streams opened by that classloader. Previous versions of Java do not offer that, there an evil hack is needed to expose the private "ucp" field of the URLClassLoader and free them manually.

This change would need to abandon retrotranslator (which should not be a hindrance) since rt is dead since 2009 and does not know Java 7.

java.lang.NoClassDefFoundError: com/yworks/yguard/obf/NoSuchMappingException

Hello,

I've got a spring boot jar I'm attempting to obfuscate and I'm in the early stages. I've tried executing the obfuscation on the plain spring boot jar using version 2.9.1 (retrieved from maven) but I get the following stack trace:

C:\Users\neilb\Documents\GitHub\datapaq5\build.xml:20: java.lang.NoClassDefFoundError: com/yworks/yguard/obf/NoSuchMappingException at com.yworks.yguard.YGuardTask.createRename(YGuardTask.java:157) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.IntrospectionHelper$CreateNestedCreator.create(IntrospectionHelper.java:1427) at org.apache.tools.ant.IntrospectionHelper$Creator.create(IntrospectionHelper.java:1343) at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:574) at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:359) at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:205) at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164) at org.apache.tools.ant.Task.perform(Task.java:351) at org.apache.tools.ant.Target.execute(Target.java:437) at org.apache.tools.ant.Target.performTasks(Target.java:458) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1406) at org.apache.tools.ant.Project.executeTarget(Project.java:1377) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1261) at org.apache.tools.ant.Main.runBuild(Main.java:857) at org.apache.tools.ant.Main.startAnt(Main.java:236) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112) Caused by: java.lang.ClassNotFoundException: com.yworks.yguard.obf.NoSuchMappingException at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1386) at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1335) at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1090) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 22 more

However when running with 2.7.1; it works just fine. For now I'm using the 2.7.1 version because that is what is on the yguard webpage but I thought it might help to report the problem. Please see my build.xml below:

`

<target name="setup-properties">
	<!-- setup properties -->
	<echo>setup properties</echo>
	<property name="target.dir" value="${basedir}/target" />
	<property name="dp5.jar.file" value="etc/yguard/DP5-0.1.jar" />
</target>


<target name="obfuscate-dp5" depends="setup-properties">
	<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="etc/yguard/yguard-2.7.1.jar" />
	<yguard>
		<inoutpair in="${dp5.jar.file}" out="${dp5.jar.file}.obs" />
		<rename mainclass="com.ziath.datapaq5.Datapaq5Application" logfile="renamelog.xml">

			<property name="language-conformity" value="illegal" />
			<property name="naming-scheme" value="mix" />

			<keep>
				<!-- No obfuscate non ziath libraries -->
				<class classes="private" methods="private" fields="private">
					<patternset>
						<include name="**" />
						<exclude name="com.ziath.**" />
					</patternset>
				</class>
			</keep>
		</rename>
	</yguard>
	<copy file="${dp5.jar.file}" tofile="${dp5.jar.file}.original" />
	<copy file="${dp5.jar.file}.obs" tofile="${dp5.jar.deploy.file}" />
</target>
` I'm using JDK 11 and the jar is a spring boot one.

Thanks.

Cheers,

Neil

Cheers,

Neil

fix "digestes" property bug

Reported by @petrsuchomel25

Guys,
I found pretty nasty issue in yGuard.
If you are processing jar files and you do not want to add digest
into manifests (but you want to have manifest updated) and set
property, classes are
omitted from having digests, but all resources will have digests
(both SHA-1and MD5) anyway.
This might be causing serious problems if you do further
manipulation, because it may mean these digest will become invalid
(for example, you bundle the library within jar and add digest for
entire library) and force you to make additional processing.
Here is attached patch which makes behavior unified depending what
value is used for digest property, the algorithm should be also
faster, as long as new instances are not created all over again.
Please review and let me know,
--Petr Suchomel

Yguard Obfuscation in a Spring Boot Project

Let me ask you something. Have a an application that is written on spring boot. To obfuscate the jar via yguard, i have no success that i would like to exclude BOOT-INF/lib folder. Could you help me on it?

Thanks a lot.

JavaFX fxml support

After obsufiaction, my jar does not start due to an error:
caused by: java.lang.ClassNotFoundException: com.example.Controller at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)

Because the name of the old class remains in the fxml file.

invokeDynamic calls being dropped under some circumstances

Minimal example here. This is the java code:


package minimalexample;

import javax.swing.SwingUtilities;

public class MinimalExample {

    boolean changeRequested = false;

    public static void main(String[] args) {
        new MinimalExample().runExample();
    }
    
    public void runExample() {
        
        synchronized(this) {
            MinimalExample that = this;
            if (changeRequested == false) {
                SwingUtilities.invokeLater(() -> {
                    synchronized(that) {
                        changeRequested = false;
                    }
                });
                changeRequested = true;
            }
        }
        System.out.println(changeRequested);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException ex) {
        }
        System.out.println(changeRequested);
    }
}

which compiles and runs as expected.

Running through yguard (first happened to me when I was using 2.6, then updated to 2.9.2, same result):

    <target name="yguard">
      <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="lib/yguard.jar"/>
      <!-- the following can be adjusted to your needs -->
      <yguard>
        <inoutpair in="dist/MinimalExample.jar" out="dist/MinimalExampleYG.jar"/>
        <shrink logfile="dist/shrink.log"/>
        <rename mainclass="minimalexample.MinimalExample" logfile="dist/rename.log">
	</rename>
      </yguard>
    </target>

makes running the obfuscated file result in a crash, tested with oracle jdk 8.201 and openjdk 12.0.1:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    minimalexample/MinimalExample.A()V @23: aload_1
  Reason:
    Current frame's stack size doesn't match stackmap.
  Current Frame:
    bci: @23
    flags: { }
    locals: { 'minimalexample/MinimalExample', 'minimalexample/MinimalExample', 'minimalexample/MinimalExample' }
    stack: { 'minimalexample/MinimalExample' }
  Stackmap Frame:
....

Investigating the class files with javap shows this in the original class file:

  public void runExample();
    Code:
       0: aload_0
       1: dup
       2: astore_1
       3: monitorenter
       4: aload_0
       5: astore_2
       6: aload_0
       7: getfield      #2                  // Field changeRequested:Z
      10: ifne          28
      13: aload_0
      14: aload_2
      15: invokedynamic #6,  0              // InvokeDynamic #0:run:(Lminimalexample/MinimalExample;Lminimalexample/MinimalExample;)Ljava/lang/Runnable;
      20: invokestatic  #7                  // Method javax/swing/SwingUtilities.invokeLater:(Ljava/lang/Runnable;)V
      23: aload_0
      24: iconst_1
      25: putfield      #2                  // Field changeRequested:Z

and this obfuscated:

  public void A();
    Code:
       0: aload_0
       1: dup
       2: astore_1
       3: monitorenter
       4: aload_0
       5: astore_2
       6: aload_0
       7: getfield      #12                 // Field A:Z
      10: ifne          23
      13: aload_0
      14: aload_2
      15: invokestatic  #26                 // Method javax/swing/SwingUtilities.invokeLater:(Ljava/lang/Runnable;)V
      18: aload_0
      19: iconst_1
      20: putfield      #12                 // Field A:Z

The invokeDynamic() line 15 is missing from the obfuscated file, causing invokeLater to be called with a wrong parameter stack.

improve documentation on <attribute>

where should it be placed?
works both as a child of <yguard> and of <keep>, but doesn't work as a child of <rename>.

@micschro suggested:
placing it as a child of <rename> should yield an error message?

Crash when using IntStream

Seems like yGuard has some trouble obfuscating code that uses IntStream. Here's a sample application that fails:

import java.util.Random;

public class Test {
    private Random rng;

    public Test(long seed) {
        this.rng = new Random(seed);
    }
    /*
     * Generates alphanumeric strings of given length
     */
    public String randomAlphaString(int targetStringLength) {
        int leftLimit = 48; // '0'
        int rightLimit = 122; // 'z'

        return rng.ints(leftLimit, rightLimit + 1)
                .filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97))
                .limit(targetStringLength)
                .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
                .toString();
    }

    public static void main(String[] args) {
        Test t = new Test(1337);
        System.out.println(t.randomAlphaString(10));
    }
}

After obfuscating the jar, trying to execute it results in:

> java -jar build/libs/test-1.0-SNAPSHOT_obf.jar
Error: Unable to initialize main class com.example.Test
Caused by: java.lang.VerifyError: Operand stack underflow
Exception Details:
  Location:
    com/example/Test.A(I)Ljava/lang/String; @17: invokeinterface
  Reason:
    Attempt to pop empty stack.
  Current Frame:
    bci: @17
    flags: { }
    locals: { 'com/example/Test', integer, integer, integer }
    stack: { 'java/util/stream/IntStream' }
  Bytecode:
    0000000: 1030 3d10 7a3e 2ab4 0014 1c1d 0460 b600
    0000010: 23b9 0029 0200 1b85 b900 2d03 00b9 0031
    0000020: 0400 c000 33b6 0037 b0

rename: same method inherited from multiple interfaces

The following inheritance diagram:

coincidental-inheritance-bug

Can be reconstructed with the following code:

public class Main {
  public static class NormalClass extends SuperClass implements NormalInterface
  	{
  	}
  	
  	public static class SuperClass extends LibraryClass implements SuperInterface
  	{ 
  		@Override
  		public String testMethod()
  		{
  			return "SUPER CLASS";
  		}
  	}
  
  	
  	public static class LibraryClass
  	{
  		public String testMethod()
  		{
  			return "LIBRARY RESPONSE";
  		}
  	}
  	
  	public static interface NormalInterface extends SuperInterface
  	{
  		public String testMethod();
  	}
  	
  	public static interface SuperInterface
  	{
  
  	}
  
  	public static void main(String[] args)
  	{
  		NormalClass n = new NormalClass();
  		System.out.println("Direct: " +n.testMethod());
  		
  		NormalInterface i = n;
  		System.out.println("Via Interface: " +i.testMethod());
  	}
}

will generate the following obfuscation log

<expose>
  <method class="test.implementstest2.Main" name="void main(java.lang.String[])"/>
</expose>
<map>
  <package name="test" map="A"/>
  <package name="test.implementstest2" map="A"/>
  <class name="test.implementstest2.Main$SuperClass" map="_A"/>
  <method class="test.implementstest2.Main$SuperClass" name="java.lang.String testMethod()" map="B"/>
  <class name="test.implementstest2.Main$SuperInterface" map="_B"/>
  <class name="test.implementstest2.Main$NormalClass" map="_C"/>
  <class name="test.implementstest2.Main$LibraryClass" map="_D"/>
  <method class="test.implementstest2.Main$LibraryClass" name="java.lang.String testMethod()" map="A"/>
  <class name="test.implementstest2.Main$NormalInterface" map="_E"/>
  <method class="test.implementstest2.Main$NormalInterface" name="java.lang.String testMethod()" map="B"/>
  <class name="test.implementstest2.Main" map="A"/>
</map>
</yguard>

and change implementation like this:

NormalClass n = new NormalClass();
System.out.println("Direct: " +n.testMethod());

NormalInterface i = n;
System.out.println("Via Interface: " +i.testMethod());

log:

>java -jar tmp\implementstest2.jar
Direct: SUPER CLASS
Via Interface: SUPER CLASS

>java -jar tmp\implementstest2_obf.jar
Direct: LIBRARY RESPONSE
Via Interface: SUPER CLASS

Rename > Keep > Method causes : java.lang.IllegalArgumentException:

I am trying to create a gradle task for Obfuscating my code, and I've got it to work, basically.

However, I am now trying to make the Obfuscation ignore the main function of my program so I can still run it. Using Annotations for this did not work (see #56), so I am now trying to do this with a keep > method element.

I have created the following code in the build.gradle for that:

task yGuardObfuscate {
	group 'yGuard'
	description 'Obfuscates existing archives.'
	dependsOn "installDist"

	doLast {
		ant.taskdef(
			name: 'yguard',
			classname: 'com.yworks.yguard.YGuardTask',
				classpath: sourceSets.main.runtimeClasspath.asPath
			)
		
		ant.yguard {
			inoutpairs {
				fileset(dir: "./build/install/module") {
					include(name: "module*.jar")
					exclude(name: "*_obf.jar")
				}
			}
			
			rename(logFile: "./build/install/module/rename.log") {
				property(name: "naming-scheme", value: "mix")
				keep {
					method("class": "com.company.project.module.Start", name: "public static void main(String[] args)")
				}
			}
		}
	}
}

Without the keep > method instruction, this works, but ends up obfuscating the main method.

As soon as I added the following lines:

				keep {
					method("class": "com.company.project.module.Start", name: "public static void main(String[] args)")

...the gradle build started failing with the following error message:

: java.lang.IllegalArgumentException: '(' expected but found void
[...]
Caused by: java.lang.IllegalArgumentException: '(' expected but found void
	at com.yworks.yguard.ObfuscatorTask.toNativeMethod(ObfuscatorTask.java:188)
	at com.yworks.yguard.ant.MethodSection.addEntries(MethodSection.java:35)
	at com.yworks.yguard.ant.ExposeSection.createEntries(ExposeSection.java:170)
	at com.yworks.yguard.ObfuscatorTask.execute(ObfuscatorTask.java:745)
	at com.yworks.yguard.YGuardTask.execute(YGuardTask.java:116)
[...]
Root cause: java.lang.IllegalArgumentException: '(' expected but found void
	at com.yworks.yguard.ObfuscatorTask.toNativeMethod(ObfuscatorTask.java:188)
	at com.yworks.yguard.ant.MethodSection.addEntries(MethodSection.java:35)
	at com.yworks.yguard.ant.ExposeSection.createEntries(ExposeSection.java:170)
	at com.yworks.yguard.ObfuscatorTask.execute(ObfuscatorTask.java:745)
	at com.yworks.yguard.YGuardTask.execute(YGuardTask.java:116)

I am aware that this is highly likely a syntax error on my end. However, I have now searched for over an hour, tried out several different things, and still have no idea what that error is. That's why I would expect a more expressive error message at this point, saying exactly what went wrong.

Also, it would probably be really, really helpful to have an example of how this should be written correctly. So far, the best I have found is this stack overflow post (https://stackoverflow.com/questions/20052105/converting-yguard-ant-task-to-gradle) which only gives me very limited insight.

And the relevant page on the documentation (https://yworks.github.io/yGuard/task_documentation/#the-method-element) does regrettably not provide the correct syntax for Gradle. That was the first place I was looking.

Anyway, any help on this issue would be greatly appreciated.

Research obfuscation techniques

There are many possible ways of obfuscation. It would be good to create a table / chart in the documentation which ones exist and are supported by yGuard. Inspiration could be drawn from this paper. The scope of this ticket is to create a new documentation page with mentioned details.

Improve error message when trying to shrink Java 11 class files

Shrinking Java 11 byte code results in

Buildfile: /home/behr/localhg/yguard-all/yguard/build-support.xml

shrink-wmextractor:
    [mkdir] Created dir: /home/behr/localhg/yguard-all/yguard/target/wmextractor
   [shrink] yGuard Shrinker v2.7.2-rc1 - http://www.yworks.com/products/yguard
   [shrink] parsing /home/behr/Downloads/wmextractor.jar
   [shrink] parsing /home/behr/Downloads/wmextractor.jar
   [shrink] writing shrinked /home/behr/Downloads/wmextractor.jar to /home/behr/localhg/yguard-all/yguard/target/wmextractor/wmextractor_shrinked.jar.
   [shrink] ERROR: This feature requires ASM7
   [shrink] This feature requires ASM7

BUILD FAILED
/home/behr/localhg/yguard-all/yguard/build-support.xml:175: yShrink encountered an unknown problem!

Total time: 6 seconds

It would probably be a good idea to configure ASM to accept Java 11 byte code instruction, track the occurrence of such instructions, and after ASM is done have yGuard abort with a sensible error message along the lines of "Shrinking is not supported for Java 11 class files" or "... class files with invokedynamic and/or nest instructions".

yGuard Documentation ~ Broken Link "Task documentation"

I stumbled across a broken link in the yGuard Documentation, leading me to the following partially non-existent page.

https://yworks.github.io/yGuard/task

How I got there:

  1. On the github page of yGuard (https://github.com/yWorks/yGuard), in the README.md section, under "Usage" click on the link "is available" in the sentence "An online version of this documentation is available."
  2. This will open the yGuard Documentation (https://yworks.github.io/yGuard/). There, under "Table of contents" in the main body of the page, click on the link "Task documentation"
  3. This will open the page https://yworks.github.io/yGuard/task . which apart from a navigation only has a 404 error.

Notably, I am able to reach the Task Documentation by using the sidebar navigation, which will take me to the page https://yworks.github.io/yGuard/task_documentation/

I thus suppose that the link in the table of contents should be pointing to
https://yworks.github.io/yGuard/task_documentation/
instead of
https://yworks.github.io/yGuard/task

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.