0.0
No commit activity in last 3 years
No release in over 3 years
This gem is designed for transformation of Ruby source code (eiher in the form of files or strings) to the Ruby nodes (syntax trees) used by Ruby MRI internals. Obtained nodes can be serialized to the platform-dependent binary or ASCII strings and restored and launched from serialized format. Such kind of transformation is irreversible and can be used for source code protection; the similar principle is used by RubyEncoder commercial software.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

node-marshal¶ ↑

This gem is designed for transformation of Ruby source code (eiher in the form of files or strings) to the Ruby nodes (syntax trees) used by Ruby MRI internals. Obtained nodes can be serialized to the platform-dependent binary or ASCII strings and restored and launched from serialized format. Such kind of transformation is irreversible and can be used for source code protection; the similar principle is used by RubyEncoder commercial software. It also contains some subroutines that can be useful for code obfuscation by renaming symbols inside the program.

The key features of node-marshal gem:

  • Irreversible conversion of a source code to the Ruby node (abstract syntax tree)

  • Ruby 1.9.3, 2.2.x and 2.3.x support (only MRI)

  • Active usage of Ruby internals (mainly AST) and Ruby standard library (Marshal and Zlib)

  • Set of tests for easy addition of new Ruby versions

  • Result of compilation depends on Ruby version and used platform (x86, x64 etc.)

  • Subroutines for obfuscation

  • 2-clause BSD license suitable for creation of custom source code protection system

Changelog:

  • 01.MAY.2017 - 0.2.2

    - Bugfix: NODE_KW_ARG processing implementation. Allows to use keyword (named) arguments
      in Ruby 2.x. (thanks to Jarosław Salik for bugreport).
    - Bugfix: NODE_LASGN and NODE_DASGN_CURR 2nd child special cases (-1 value). Mainly for
      their usage inside NODE_KW_ARG child trees.
    - test_namedarg.rb test was added (for so called keyword argument)
    - Improved output of dump_tree_short (rb_args_info dump)
  • 16.MAR.2016 - 0.2.1

    - Bugfix: garbage collection of symbols kept in the literals table of the node dump
      is now prohibited. Such GC caused hardly reproducible bugs after code loading.
      (thanks to Gregory Siehień for suitable examples)
    - Bugfix: improved parsing of NODE_ARRAY (correct processing of two cases of
      not documented pointers (instead of longs) in 2nd child. It affects arrays,
      NODE_HASH (hashes) and NODE_DSTR (strings in double quotes with #{} inside) ).
    - Bugfix: now NodeMarshal class methods don't change the state of Ruby 
      garbage collector
    - Improved NodeMarshal#dump_tree_short output (addresses of nodes are shown)
    - Added NodeMarshal#to_h method (alias for NodeMarshal#to_hash)
    - NodeMarshal#to_a and NodeMarshal#to_ary methods added (they show extended information
      about Ruby AST including rb_args_info and ID *tbl internals)
  • 11.JAN.2016 - 0.2.0

    - Bugfix: || and && in NODE_OP_ASGN1 (e.g. in x['a'] ||= 'b' or x['b'] &&= false)
      (this bug caused segfaults in some cases)
    - Bugfix: NodeMarshal#dump_node_short
    - Format version changed to NODEMARSHAL11 (support of symbols not representable in
      the form of String is added)
    - show_offsets property for controlling verbosity of NodeMarshal#dump_node_short output
    - Improved information about licenses
    - Improved rdoc documentation
  • 24.DEC.2015 - 0.1.2

    - Ruby 2.3.x preliminary support (including &. safe navigation operator)
    - Bugfix: NODE_MATCH3 (a =~ /abc/) issue (reported by Gregory Siehień)
    - Bugfix: NODE_BLOCK_PASS (short map syntax) issue (reported by Gregory Siehień)
    - Bugfix: failure in the case of syntax errors in the input data (now ArgumentError
      exception will be generated instead of it)
    - Ability of symbols renaming (for hiding variables and constants name during code obfuscation)
  • 04.MAY.2015 - 0.1.1 - first public version