java - AOT compiling with jRuby to obfuscate Rails code -


we have ror application running in windows server 2012 r2, using iis, jruby, , puma in clients network. production application runs great! problem now, need protect source code in manner through obfuscation. initial thought compile .rb files .class files jruby digest instead of .rb files. tried single file see if work. navigated myapp/app/controllers and...

jruby -s jrubyc application_controller.rb 

that created compiled class file application_controller.class in directory. tried methods mentioned @ link older version of jruby see if work - https://github.com/jruby/jruby/wiki/railsaot

but none of them did, either giving me uninitialized constant applicationcontroller, or unable load file application_controller.

i tried instructions https://www.ruby-forum.com/topic/216572#939791 given lack of java knowledge, im pretty sure not have correct. last state of application_controller.rb -

require 'java' $classpath << 'lib' java_import 'application_controller' 

this gives me 'cannot import application_controller application_controller' im guessing because of underscores in class name.

essentially, trying rails app work .class files in place of .rb files.

update: tried use warbler create compiled war

jruby -s warble compiled war 

i extracted .war tomcat container @ contents of .rb files. looke this:

load __file__.sub(/.rb$/,'.class') 

so tried taking snippet , putting in application_controller.rb running on puma. jruby -s rails server, , got following error-

use 'java_import' load normal java classes: application_controller 

so changed application_controller.rb

require 'java' $classpath << 'app/controllers' java_import 'application_controller' 

that gave me following error -

cannot import class 'application_controller' 'application_controller' 

could it needs camelcase? using jruby 9.0.0.0, think might try , rollback 1.7 , see happens

update: worked! rolled jruby 1.7, ran jrubyc on application_controller.rb , replaced application_controller.rb contents with

load __file__.sub(/.rb$/,'.class') 

and app loaded fine using puma iis.

try warbler compiled feature ... ~ same creates dummy .rb file loads .class version (it's not clear notes or old aot wiki whether tried explicitly)

you should inside generated .war file (it's .zip) how compiled .rb files got updated ...


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -