0

I'm trying to obfuscate a JAR file using the yguard 3.0.0 maven plugin. The obfuscated JAR is as almost as expected, it is shrinked and with all the private methods and variables renamed. I need that package names will be renamed too and this is performed, but the spring XML files needed to start my Tomcat are not being updated with the obfuscated packages.

My ant task is the following:

<configuration>
    <tasks>
        <property name="runtime-classpath" refid="maven.runtime.classpath"/>
        <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="${runtime-classpath}"/>
            <yguard>
                <inoutpair in="C:/test/webapp.jar" out="C:/test/webapp_obfuscated.jar" />
                <shrink>
                    <property name="error-checking" value="pedantic"/>
                </shrink>
                <rename>
                    <adjust replaceContent="true" replaceName="true">
                         <include name="ApplicationContext.xml"/>
                    </adjust>
                </rename>                                                                   
            </yguard>
       </tasks>
</configuration>

Note that here in my example, I'm only trying to deal with the ApplicationContext.xml, but this file remains with the same classnames that the no obfuscated version. I'm sure that the yguard task is doing something into my ApplicationContext.xml because I have a tag in the file and the path to a file is properly obfuscated but the classnames and the other stuff no:

    <!-- Properties ldap -->
    <bean id="ldapProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean" scope="singleton">
      <property name="ignoreResourceNotFound" value="true"/>
      <property name="locations">
            <list>              
              <value>classpath:A/A/B/E/ldap.properties</value>     <--Obfuscated!--> 
            </list>
      </property>
    </bean> 
    
    <bean id="authenticationBO" class="com.grifols.grb.authentication.bo.AuthenticationBO" scope="singleton">
        <property name="dbAccess" ref="dbAccessGRB"/>
        <property name="usersSecurityBO" ref="usersSecurityBO" />   
        <property name="settings" ref="settings" /> 
        <property name="ldapProperties" ref="ldapProperties" />
    </bean>

According to the Yguard documentation I think that I only have to use replaceContent="true" and detail which file but I'm not

Any idea? I really appreciate any help you can provide.

Ivan

Ivan
  • 180
  • 1
  • 2
  • 16

1 Answers1

0

yGuard is able to replace either file/path names or class names in resource files, but not both at once.

I.e.

<adjust replaceContent="true">

will adjust

<example>
  <class>com.yworks.yguard.StringReplacer</class>
  <file>com/yworks/yguard/StringReplacer.properties</file>
</example>

to

<example>
  <class>com.yworks.yguard.StringReplacer</class>
  <file>A/A/A/SR.properties</file>
</example>

With

<adjust replaceContent="true" replaceContentSeparator=".">

the result will be

<example>
  <class>A.A.A.SR</class>
  <file>com/yworks/yguard/StringReplacer.properties</file>
</example>

However, the desired result

<example>
  <class>A.A.A.SR</class>
  <file>A/A/A/SR.properties</file>
</example>

is not (yet) supported.

Thomas Behr
  • 761
  • 4
  • 10