veracode 1.0.0.alpha6 → 1.0.0.alpha7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/veracode +21 -15
- data/lib/veracode.rb +153 -132
- data/lib/veracode/schema.rb +55 -37
- data/lib/veracode/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e57a698db0528192fcbd096c38cb4236ef54869f
         | 
| 4 | 
            +
              data.tar.gz: f4b1f130125636850f94bddd03356b35ab6678f6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cbfc1cfc6c98a2dde96540a8f5c2f05baa01f4076e3204c49edcec5db86db752f641bb923b5f998a85e65fabe45cd1b0e05ac5074acdb71658315b1c8459f02c
         | 
| 7 | 
            +
              data.tar.gz: 0935f7c827279516a28e56068e9b00c45c214484316f38e85ab618810dfa29811d368498a0822b8705a92bf22322946645e0bf9873e502db7f032fb294ba3665
         | 
    
        data/bin/veracode
    CHANGED
    
    | @@ -16,12 +16,10 @@ require 'veracode' | |
| 16 16 | 
             
            require 'veracode/version'
         | 
| 17 17 |  | 
| 18 18 | 
             
            $options =  {
         | 
| 19 | 
            -
                          :phase1 => false, 
         | 
| 20 | 
            -
                          :phase2 => false, 
         | 
| 21 | 
            -
                          :phase3 => true,
         | 
| 22 19 | 
             
                          :archive_source => true,
         | 
| 23 20 | 
             
                          :include_inherited => false,
         | 
| 24 21 | 
             
                          :jruby => false,
         | 
| 22 | 
            +
                          :environment => false,
         | 
| 25 23 | 
             
                        }
         | 
| 26 24 |  | 
| 27 25 | 
             
            subcommand = ARGV.shift
         | 
| @@ -34,22 +32,13 @@ case subcommand | |
| 34 32 | 
             
                    $options[:verbose] = true
         | 
| 35 33 | 
             
                  end
         | 
| 36 34 |  | 
| 37 | 
            -
                  opts.on("-a", "--all", "Archive objects at all stages") do
         | 
| 38 | 
            -
                    $options[:phase1] = true
         | 
| 39 | 
            -
                    $options[:phase2] = true
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  opts.on("-f", "--file", "Disassemble .rb files") do
         | 
| 43 | 
            -
                    $options[:disasm] = true
         | 
| 44 | 
            -
                  end
         | 
| 45 | 
            -
             | 
| 46 35 | 
             
                  opts.on("-j", "--jruby", "Force JRuby mode") do
         | 
| 47 36 | 
             
                    $options[:jruby] = true
         | 
| 48 37 | 
             
                  end
         | 
| 49 38 |  | 
| 50 | 
            -
                  opts.on("--[no-]source", "[Don't] Include source code in archive") do |s|
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                  end
         | 
| 39 | 
            +
                  # opts.on("--[no-]source", "[Don't] Include source code in archive") do |s|
         | 
| 40 | 
            +
                  #   $options[:archive_source] = s
         | 
| 41 | 
            +
                  # end
         | 
| 53 42 |  | 
| 54 43 | 
             
                  opts.on("-D", "--debug", "Enable debug output") do
         | 
| 55 44 | 
             
                    $DEBUG = true
         | 
| @@ -73,6 +62,23 @@ case subcommand | |
| 73 62 | 
             
                                "       #{opts.program_name} help"
         | 
| 74 63 | 
             
                end.parse!
         | 
| 75 64 |  | 
| 65 | 
            +
              when "environment", "env"
         | 
| 66 | 
            +
                $options[:environment] = true
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                OptionParser.new do |opts|
         | 
| 69 | 
            +
                  opts.banner = "Usage: veracode environment [options]"
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  opts.on("-v", "--verbose", "Run verbosely") do
         | 
| 72 | 
            +
                    $options[:verbose] = true
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                  opts.on("-D", "--debug", "Enable debug output") do
         | 
| 76 | 
            +
                    $DEBUG = true
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                end.parse!
         | 
| 80 | 
            +
                Veracode.prepare
         | 
| 81 | 
            +
             | 
| 76 82 | 
             
              else
         | 
| 77 83 | 
             
                $stderr.puts "#{subcommand.dump} is not a valid subcommand"
         | 
| 78 84 |  | 
    
        data/lib/veracode.rb
    CHANGED
    
    | @@ -36,6 +36,7 @@ module Veracode | |
| 36 36 | 
             
              @archive_filename = nil
         | 
| 37 37 | 
             
              @archive_dirname = nil
         | 
| 38 38 |  | 
| 39 | 
            +
             | 
| 39 40 | 
             
              def self.init
         | 
| 40 41 | 
             
                @run_id = Time.now.strftime("%Y%m%d%H%M%S")
         | 
| 41 42 | 
             
                @archive_dirname = File.join("tmp","veracode-#{@run_id}")
         | 
| @@ -152,28 +153,47 @@ module Veracode | |
| 152 153 | 
             
                    }
         | 
| 153 154 | 
             
                  }
         | 
| 154 155 | 
             
                rescue Exception => e
         | 
| 155 | 
            -
                  log_error e.message
         | 
| 156 | 
            -
                   | 
| 156 | 
            +
                  log_error "Unable to write manifest file #{@manifest_filename}: #{e.message}"
         | 
| 157 | 
            +
                  puts "Unable to write manifest file #{@manifest_filename}: #{e.message}"
         | 
| 157 158 | 
             
                end
         | 
| 158 159 |  | 
| 159 160 | 
             
                @errorlog.flush
         | 
| 160 161 |  | 
| 161 162 | 
             
                begin
         | 
| 162 | 
            -
                   | 
| 163 | 
            -
                     | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
                         | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 163 | 
            +
                  if Gem.loaded_specs.keys.include?("zipruby")
         | 
| 164 | 
            +
                    log_error "zipruby gem detected, using it instead of rubyzip for creating archive"
         | 
| 165 | 
            +
                    @errorlog.flush
         | 
| 166 | 
            +
                    Zip::Archive.open(@archive_filename, Zip::CREATE) { |ar|
         | 
| 167 | 
            +
                      @manifest.each { |file|
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                        if file.start_with?(@archive_dirname)
         | 
| 170 | 
            +
                          name_in_archive = file.sub(/^#{@archive_dirname + File::SEPARATOR}/,"")
         | 
| 171 | 
            +
                        else
         | 
| 172 | 
            +
                          name_in_archive = File.join(APP_NAME, file)
         | 
| 173 | 
            +
                        end        
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                        puts "Adding #{file} to archive as #{name_in_archive}" if $options[:verbose]
         | 
| 176 | 
            +
                        ar.add_file(name_in_archive, file)
         | 
| 177 | 
            +
                      }
         | 
| 178 | 
            +
                    }
         | 
| 179 | 
            +
                  else
         | 
| 180 | 
            +
                    Zip::File.open(@archive_filename, Zip::File::CREATE) { |zf|
         | 
| 181 | 
            +
                      @manifest.each { |file|
         | 
| 182 | 
            +
             | 
| 183 | 
            +
                        if file.start_with?(@archive_dirname)
         | 
| 184 | 
            +
                          name_in_archive = file.sub(/^#{@archive_dirname + File::SEPARATOR}/,"")
         | 
| 185 | 
            +
                        else
         | 
| 186 | 
            +
                          name_in_archive = File.join(APP_NAME, file)
         | 
| 187 | 
            +
                        end        
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                        puts "Adding #{file} to archive as #{name_in_archive}" if $options[:verbose]
         | 
| 190 | 
            +
                        zf.add(name_in_archive, file)
         | 
| 191 | 
            +
                      }
         | 
| 173 192 | 
             
                    }
         | 
| 174 | 
            -
                   | 
| 193 | 
            +
                  end
         | 
| 175 194 | 
             
                rescue Exception => e
         | 
| 176 | 
            -
                   | 
| 195 | 
            +
                  log_error "Unable to create archive #{@manifest_filename}: #{e.message}"
         | 
| 196 | 
            +
                  puts "Unable to create archive #{@manifest_filename}: #{e.message}"
         | 
| 177 197 | 
             
                  exit
         | 
| 178 198 | 
             
                end
         | 
| 179 199 |  | 
| @@ -233,20 +253,24 @@ module Veracode | |
| 233 253 |  | 
| 234 254 | 
             
              def self.glob_require(files)
         | 
| 235 255 | 
             
                any_new = false
         | 
| 256 | 
            +
                total, count = 0, 0
         | 
| 236 257 | 
             
                Dir.glob(files) do |f|
         | 
| 237 258 | 
             
                  print "Requiring #{f.to_s} " if $options[:verbose]
         | 
| 238 259 |  | 
| 239 260 | 
             
                  begin
         | 
| 240 | 
            -
                     | 
| 261 | 
            +
                    required = require File.expand_path(f)
         | 
| 241 262 | 
             
                  rescue Exception => e
         | 
| 242 263 | 
             
                    puts "(failed: #{e.message})" if $options[:verbose]
         | 
| 243 264 | 
             
                    log_error "Unable to require #{File.expand_path(f).to_s.dump} (#{e.message})"
         | 
| 244 265 | 
             
                  else
         | 
| 245 | 
            -
                    puts "(OK)" if $options[:verbose]
         | 
| 266 | 
            +
                    puts "(OK: #{(required ? "required" : "already required")})" if $options[:verbose]
         | 
| 246 267 | 
             
                  end
         | 
| 247 | 
            -
             | 
| 268 | 
            +
                  any_new |= required
         | 
| 269 | 
            +
                  total += 1
         | 
| 270 | 
            +
                  count += 1 if required
         | 
| 248 271 | 
             
                end
         | 
| 249 | 
            -
                 | 
| 272 | 
            +
                puts "#{count}/#{total} files were required" if $options[:verbose]
         | 
| 273 | 
            +
                any_new
         | 
| 250 274 | 
             
              end
         | 
| 251 275 |  | 
| 252 276 | 
             
              def self.safe_name(o)
         | 
| @@ -254,7 +278,11 @@ module Veracode | |
| 254 278 | 
             
                when o == ActiveSupport::TimeWithZone
         | 
| 255 279 | 
             
                  "ActiveSupport::TimeWithZone"
         | 
| 256 280 | 
             
                when o.is_a?(Module)
         | 
| 257 | 
            -
                   | 
| 281 | 
            +
                  begin
         | 
| 282 | 
            +
                    ( o.name.nil? ? o.to_s : o.name.to_s )
         | 
| 283 | 
            +
                  rescue
         | 
| 284 | 
            +
                    o.to_s
         | 
| 285 | 
            +
                  end
         | 
| 258 286 | 
             
                when o.is_a?(Method), o.is_a?(UnboundMethod)
         | 
| 259 287 | 
             
                  o.name.to_s
         | 
| 260 288 | 
             
                else
         | 
| @@ -319,7 +347,13 @@ module Veracode | |
| 319 347 | 
             
              def self.prepare_archive
         | 
| 320 348 | 
             
                @disasmlog = Zlib::GzipWriter.new(File.open(@disasmlog_filename, "wb"), nil, nil)
         | 
| 321 349 | 
             
                @disasmlog.puts "#{RUBY_ENGINE}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
         | 
| 322 | 
            -
                 | 
| 350 | 
            +
                if $options[:environment]
         | 
| 351 | 
            +
                  @disasmlog.puts "# EnvironmentDef %s-%s_rails-%s" % [RUBY_ENGINE, RUBY_VERSION, Rails.version]
         | 
| 352 | 
            +
                else
         | 
| 353 | 
            +
                  @disasmlog.puts "# Environment %s-%s_rails-%s" % [RUBY_ENGINE, RUBY_VERSION, Rails.version]
         | 
| 354 | 
            +
                end
         | 
| 355 | 
            +
                @disasmlog.puts "# Ruby #{RUBY_ENGINE}-#{RUBY_VERSION}"
         | 
| 356 | 
            +
                @disasmlog.puts "# Rails #{Rails.version}"
         | 
| 323 357 | 
             
                @disasmlog.puts
         | 
| 324 358 | 
             
              end
         | 
| 325 359 |  | 
| @@ -396,7 +430,7 @@ module Veracode | |
| 396 430 | 
             
                    m.included_modules.map {|m| "include #{m.inspect.dump}\n" }.join : 
         | 
| 397 431 | 
             
                    ""
         | 
| 398 432 | 
             
                ) + 
         | 
| 399 | 
            -
                ( m.singleton_class.included_modules.count > 0 ? 
         | 
| 433 | 
            +
                ( m.respond_to?(:singleton_class) && m.singleton_class.included_modules.count > 0 ? 
         | 
| 400 434 | 
             
                    m.singleton_class.included_modules.map {|m| "extend #{m.inspect.dump}\n" }.join : 
         | 
| 401 435 | 
             
                    ""
         | 
| 402 436 | 
             
                )
         | 
| @@ -432,17 +466,20 @@ module Veracode | |
| 432 466 | 
             
                  end
         | 
| 433 467 | 
             
                end
         | 
| 434 468 |  | 
| 435 | 
            -
                 | 
| 436 | 
            -
                  m | 
| 437 | 
            -
                     | 
| 438 | 
            -
                       | 
| 439 | 
            -
             | 
| 440 | 
            -
             | 
| 441 | 
            -
                       | 
| 442 | 
            -
             | 
| 443 | 
            -
             | 
| 444 | 
            -
             | 
| 469 | 
            +
                begin
         | 
| 470 | 
            +
                  if m == Kernel
         | 
| 471 | 
            +
                    m.global_variables.each do |v_symbol|
         | 
| 472 | 
            +
                      begin
         | 
| 473 | 
            +
                        v = eval(v_symbol.to_s)
         | 
| 474 | 
            +
                        formatted_contents += format_variable(v_symbol, v, "global")
         | 
| 475 | 
            +
                      rescue Exception => e
         | 
| 476 | 
            +
                        log_error "Error archiving global variable #{v_symbol.to_s.dump}: #{e.message}"
         | 
| 477 | 
            +
                        formatted_contents += format_variable(v_symbol, :veracode_nil, "global")
         | 
| 478 | 
            +
                      end
         | 
| 479 | 
            +
                    end        
         | 
| 445 480 | 
             
                  end
         | 
| 481 | 
            +
                rescue Exception => e
         | 
| 482 | 
            +
                  # m.respond_to?(:global_variables) was throwing exceptions
         | 
| 446 483 | 
             
                end
         | 
| 447 484 |  | 
| 448 485 | 
             
                %w[ public protected private ].each {|p|
         | 
| @@ -706,7 +743,7 @@ module Veracode | |
| 706 743 |  | 
| 707 744 | 
             
              end
         | 
| 708 745 |  | 
| 709 | 
            -
             | 
| 746 | 
            +
              def self.require_libs(lib_paths)
         | 
| 710 747 | 
             
                for lib_path in lib_paths
         | 
| 711 748 | 
             
                  dirsToProcess = [Pathname(lib_path)]
         | 
| 712 749 | 
             
                  until dirsToProcess.count == 0 || !Dir.exists?(dirsToProcess[0])
         | 
| @@ -714,50 +751,52 @@ module Veracode | |
| 714 751 | 
             
                    for child in currentDir.children
         | 
| 715 752 | 
             
                      if child.directory?
         | 
| 716 753 | 
             
                        dirsToProcess[dirsToProcess.count] = child
         | 
| 717 | 
            -
             | 
| 754 | 
            +
                        base = child.to_s.partition("#{lib_path}/")[2]
         | 
| 718 755 | 
             
                        lib = ""
         | 
| 719 756 | 
             
                        for part in base.split('/').reverse
         | 
| 720 757 | 
             
                          lib = "#{part}/#{lib}"
         | 
| 721 758 | 
             
                          lib = lib[0..lib.length-2] if lib[lib.length-1] == '/'
         | 
| 722 | 
            -
             | 
| 723 | 
            -
             | 
| 724 | 
            -
             | 
| 725 | 
            -
            		end
         | 
| 726 | 
            -
                          rescue Exception => e
         | 
| 759 | 
            +
                        begin
         | 
| 760 | 
            +
                          if cond_require lib
         | 
| 761 | 
            +
                            puts "requiring #{lib}" if $options[:verbose]
         | 
| 727 762 | 
             
                          end
         | 
| 728 | 
            -
             | 
| 763 | 
            +
                        rescue Exception => e
         | 
| 764 | 
            +
                        end
         | 
| 729 765 | 
             
                      end
         | 
| 730 766 | 
             
                    end
         | 
| 731 767 | 
             
                  end
         | 
| 732 768 | 
             
                end
         | 
| 733 769 | 
             
              end
         | 
| 734 | 
            -
             | 
| 735 | 
            -
             | 
| 736 | 
            -
             | 
| 737 | 
            -
             | 
| 738 | 
            -
             | 
| 739 | 
            -
             | 
| 740 | 
            -
             | 
| 741 | 
            -
             | 
| 742 | 
            -
                     | 
| 743 | 
            -
             | 
| 744 | 
            -
             | 
| 745 | 
            -
             | 
| 746 | 
            -
             | 
| 747 | 
            -
             | 
| 748 | 
            -
             | 
| 749 | 
            -
             | 
| 750 | 
            -
             | 
| 751 | 
            -
             | 
| 752 | 
            -
             | 
| 753 | 
            -
             | 
| 754 | 
            -
             | 
| 755 | 
            -
             | 
| 756 | 
            -
             | 
| 770 | 
            +
            end
         | 
| 771 | 
            +
             | 
| 772 | 
            +
            def self.require_rails(gemdir)
         | 
| 773 | 
            +
              dirsToProcess = [Pathname(gemdir)]
         | 
| 774 | 
            +
              until dirsToProcess.count == 0
         | 
| 775 | 
            +
                currentDir = dirsToProcess.delete_at(0)
         | 
| 776 | 
            +
                for child in currentDir.children
         | 
| 777 | 
            +
                  if child.directory?
         | 
| 778 | 
            +
                    dirsToProcess[dirsToProcess.count] = child
         | 
| 779 | 
            +
                  end
         | 
| 780 | 
            +
                  base = child.to_s.partition("#{gemdir}/")[2]
         | 
| 781 | 
            +
                  if base.index("action_controller") != nil || base.index("action_view") != nil || base.index("active_record") != nil
         | 
| 782 | 
            +
                    lib = ""
         | 
| 783 | 
            +
                    for part in base.split('/').reverse
         | 
| 784 | 
            +
                      lib = "#{part}/#{lib}"
         | 
| 785 | 
            +
                      lib = lib[0..lib.length-2] if lib[lib.length-1] == '/'
         | 
| 786 | 
            +
                      lib.chomp!(File.extname(lib))
         | 
| 787 | 
            +
                      begin
         | 
| 788 | 
            +
                        if cond_require lib
         | 
| 789 | 
            +
                          puts "requiring #{lib}" if $options[:verbose]
         | 
| 790 | 
            +
                        end
         | 
| 791 | 
            +
                      rescue Exception => e
         | 
| 792 | 
            +
                      end
         | 
| 757 793 | 
             
                    end
         | 
| 758 794 | 
             
                  end
         | 
| 759 795 | 
             
                end
         | 
| 760 796 | 
             
              end
         | 
| 797 | 
            +
            end
         | 
| 798 | 
            +
             | 
| 799 | 
            +
             | 
| 761 800 |  | 
| 762 801 |  | 
| 763 802 | 
             
            ################################################################################
         | 
| @@ -774,16 +813,6 @@ module Veracode | |
| 774 813 | 
             
                  puts
         | 
| 775 814 | 
             
                end
         | 
| 776 815 |  | 
| 777 | 
            -
                if $options[:disasm]
         | 
| 778 | 
            -
                  rbfiles = File.join("**", "*.rb")
         | 
| 779 | 
            -
                  Dir[rbfiles].each do |f|
         | 
| 780 | 
            -
                    puts RubyVM::InstructionSequence.compile_file(f).disasm
         | 
| 781 | 
            -
                    puts
         | 
| 782 | 
            -
                  end
         | 
| 783 | 
            -
                  exit
         | 
| 784 | 
            -
                end
         | 
| 785 | 
            -
             | 
| 786 | 
            -
                prepare_archive
         | 
| 787 816 |  | 
| 788 817 | 
             
                ################################################################
         | 
| 789 818 | 
             
                ## phase 1 - Create baseline
         | 
| @@ -792,10 +821,6 @@ module Veracode | |
| 792 821 | 
             
                puts "Phase 1 - Initial State" if $options[:verbose]
         | 
| 793 822 | 
             
                self.stats if $options[:verbose]
         | 
| 794 823 |  | 
| 795 | 
            -
                if $options[:phase1]
         | 
| 796 | 
            -
                  puts "Processing and disassembling Ruby standard classes and modules"
         | 
| 797 | 
            -
                  archive(@modules)
         | 
| 798 | 
            -
                end
         | 
| 799 824 | 
             
                ## /phase 1 - Create baseline
         | 
| 800 825 | 
             
                ################################################################
         | 
| 801 826 |  | 
| @@ -806,59 +831,54 @@ module Veracode | |
| 806 831 |  | 
| 807 832 | 
             
                puts "Phase 2 - Load Rails" if $options[:verbose]
         | 
| 808 833 | 
             
                begin
         | 
| 809 | 
            -
                   | 
| 810 | 
            -
                  cond_require 'action_controller'
         | 
| 811 | 
            -
                  cond_require 'action_view'
         | 
| 812 | 
            -
                  cond_require 'active_record'
         | 
| 834 | 
            +
                  require "rails/all"
         | 
| 813 835 | 
             
                rescue Exception => e
         | 
| 814 836 | 
             
                  puts "Unable to require rails: #{e.message}"
         | 
| 815 837 | 
             
                  log_error "Unable to require rails: #{e.message}"
         | 
| 816 838 | 
             
                  exit
         | 
| 817 839 | 
             
                else
         | 
| 840 | 
            +
                  puts "Required rails" if $options[:verbose]
         | 
| 841 | 
            +
                end
         | 
| 842 | 
            +
             | 
| 843 | 
            +
                ## Imitate script/rails
         | 
| 844 | 
            +
                # APP_PATH = File.expand_path('config/application')
         | 
| 845 | 
            +
                  # APP_PATH is already set in bin/veracode
         | 
| 846 | 
            +
                #require File.expand_path('../../config/boot',  __FILE__)
         | 
| 847 | 
            +
                  glob_require "config/boot.rb"
         | 
| 848 | 
            +
                #require 'rails/commands'
         | 
| 849 | 
            +
                  # this will trigger the console to be launched
         | 
| 850 | 
            +
                  # ARGV.clear
         | 
| 851 | 
            +
                  # ARGV << 'console'
         | 
| 852 | 
            +
                  # ARGV << '--sandbox'
         | 
| 853 | 
            +
                  # require 'rails/commands'
         | 
| 854 | 
            +
             | 
| 855 | 
            +
                ## Imitate rails/commands when console
         | 
| 856 | 
            +
                cond_require 'rails/commands/console.rb'
         | 
| 857 | 
            +
                # require APP_PATH # => config/application.rb
         | 
| 858 | 
            +
             | 
| 859 | 
            +
                glob_require "config/application.rb"
         | 
| 860 | 
            +
             | 
| 861 | 
            +
                Rails.application.require_environment! unless $options[:jruby]
         | 
| 862 | 
            +
                # Following line will actually kick off IRB
         | 
| 863 | 
            +
                # Rails::Console.start(Rails.application)
         | 
| 864 | 
            +
                
         | 
| 865 | 
            +
                # Imitate Rails::Console.initialize_console
         | 
| 866 | 
            +
                # require "pp"
         | 
| 867 | 
            +
                cond_require "rails/console/app.rb"
         | 
| 868 | 
            +
                cond_require "rails/console/helpers.rb"
         | 
| 869 | 
            +
             | 
| 870 | 
            +
                if $options[:environment]
         | 
| 818 871 | 
             
                  @stdlib = $:
         | 
| 819 872 | 
             
                  @gemdir = Gem.dir
         | 
| 820 873 |  | 
| 821 | 
            -
                  ## Imitate script/rails
         | 
| 822 | 
            -
                  # APP_PATH = File.expand_path('config/application')
         | 
| 823 | 
            -
                    # APP_PATH is already set in bin/veracode
         | 
| 824 | 
            -
                  #require File.expand_path('../../config/boot',  __FILE__)
         | 
| 825 | 
            -
                    glob_require "config/boot.rb"
         | 
| 826 | 
            -
                  #require 'rails/commands'
         | 
| 827 | 
            -
                    # this will trigger the console to be launched
         | 
| 828 | 
            -
                    # ARGV.clear
         | 
| 829 | 
            -
                    # ARGV << 'console'
         | 
| 830 | 
            -
                    # ARGV << '--sandbox'
         | 
| 831 | 
            -
                    # require 'rails/commands'
         | 
| 832 | 
            -
             | 
| 833 | 
            -
                  ## Imitate rails/commands when console
         | 
| 834 | 
            -
                  glob_require 'rails/commands/console'
         | 
| 835 | 
            -
                  # require APP_PATH # => config/application.rb
         | 
| 836 | 
            -
             | 
| 837 | 
            -
                  glob_require "config/application.rb"
         | 
| 838 | 
            -
             | 
| 839 | 
            -
                  Rails.application.require_environment! unless $options[:jruby]
         | 
| 840 | 
            -
                  begin
         | 
| 841 | 
            -
                    cond_require 'sass'
         | 
| 842 | 
            -
                    cond_require 'sass/rails/importer'
         | 
| 843 | 
            -
                    cond_require 'multi_json/adapters/json_gem'
         | 
| 844 | 
            -
                  rescue Exception => e
         | 
| 845 | 
            -
                  end
         | 
| 846 | 
            -
                
         | 
| 847 874 | 
             
                  require_libs(@stdlib)
         | 
| 848 875 | 
             
                  require_rails(@gemdir)
         | 
| 849 | 
            -
                  puts "Required rails" if $options[:verbose]
         | 
| 850 876 | 
             
                end
         | 
| 851 877 |  | 
| 852 | 
            -
                self. | 
| 878 | 
            +
                self.rebaseline
         | 
| 853 879 |  | 
| 854 880 | 
             
                self.stats if $options[:verbose]
         | 
| 855 881 |  | 
| 856 | 
            -
                if $options[:phase2]
         | 
| 857 | 
            -
                  puts "Processing and disassembling Rails classes and modules"
         | 
| 858 | 
            -
                  archive(@modules)
         | 
| 859 | 
            -
                end
         | 
| 860 | 
            -
                
         | 
| 861 | 
            -
                self.rebaseline
         | 
| 862 882 | 
             
                ## /phase 2 - Require rails
         | 
| 863 883 | 
             
                ################################################################
         | 
| 864 884 |  | 
| @@ -868,19 +888,14 @@ module Veracode | |
| 868 888 | 
             
                # phase 3 - require app
         | 
| 869 889 |  | 
| 870 890 | 
             
                puts "Phase 3 - Imitate Rails" if $options[:verbose]
         | 
| 871 | 
            -
                # Following line will actually kick off IRB
         | 
| 872 | 
            -
                # Rails::Console.start(Rails.application)
         | 
| 873 | 
            -
                
         | 
| 874 | 
            -
                # Imitate Rails::Console.initialize_console
         | 
| 875 | 
            -
                # require "pp"
         | 
| 876 | 
            -
                glob_require "rails/console/app"
         | 
| 877 | 
            -
                glob_require "rails/console/helpers"
         | 
| 878 891 |  | 
| 879 | 
            -
                 | 
| 880 | 
            -
                 | 
| 881 | 
            -
             | 
| 882 | 
            -
             | 
| 883 | 
            -
             | 
| 892 | 
            +
                any_new = true
         | 
| 893 | 
            +
                while any_new
         | 
| 894 | 
            +
                  any_new = false
         | 
| 895 | 
            +
                  any_new |= glob_require "lib/**/*.rb"
         | 
| 896 | 
            +
                  any_new |= glob_require "app/**/*.rb"
         | 
| 897 | 
            +
                  puts "new successful requires? #{any_new.to_s}" if $options[:verbose]
         | 
| 898 | 
            +
                end
         | 
| 884 899 |  | 
| 885 900 | 
             
                compile_templates
         | 
| 886 901 |  | 
| @@ -890,19 +905,25 @@ module Veracode | |
| 890 905 | 
             
                # Ensure compiled templates are fully disassembled in archive
         | 
| 891 906 | 
             
                @baseline_modules.delete(ActionView::CompiledTemplates)
         | 
| 892 907 |  | 
| 893 | 
            -
                if $options[: | 
| 894 | 
            -
                  puts "Processing and disassembling  | 
| 908 | 
            +
                if $options[:environment]
         | 
| 909 | 
            +
                  puts "Processing and disassembling environment"
         | 
| 910 | 
            +
                  archive(@modules.reject  {|o| safe_name(o) =~ /^#<(Class|Module):0x[0-9a-f]+>/i }
         | 
| 911 | 
            +
                                  .reject  {|o| safe_name(o) =~ /^Veracode/ }
         | 
| 912 | 
            +
                                  .reject  {|o| safe_name(o) =~ /^EmptyRails/ }
         | 
| 913 | 
            +
                                  .reject  {|o| safe_name(o) =~ /^ActionView::CompiledTemplates$/ }, false)
         | 
| 914 | 
            +
                else
         | 
| 915 | 
            +
                  puts "Processing Ruby and Rails classes and modules"
         | 
| 895 916 | 
             
                  archive(@baseline_modules, false)
         | 
| 917 | 
            +
                  add_to_archive "\n# Phase 3 - App disassembly\n"
         | 
| 918 | 
            +
                  puts "Processing and disassembling #{APP_NAME} classes and modules"
         | 
| 896 919 | 
             
                  archive(@modules - @baseline_modules, true)
         | 
| 920 | 
            +
                  archive_schema
         | 
| 897 921 | 
             
                end
         | 
| 898 922 |  | 
| 899 | 
            -
                archive_schema
         | 
| 900 | 
            -
             | 
| 901 923 | 
             
                ## /phase 3 - require app
         | 
| 902 924 | 
             
                ################################################################
         | 
| 903 925 |  | 
| 904 926 | 
             
                finalize_archive
         | 
| 905 | 
            -
             | 
| 906 927 | 
             
                pack_manifest
         | 
| 907 928 | 
             
                cleanup
         | 
| 908 929 |  | 
    
        data/lib/veracode/schema.rb
    CHANGED
    
    | @@ -1,61 +1,79 @@ | |
| 1 1 | 
             
            module Veracode
         | 
| 2 2 | 
             
              module ActiveRecord
         | 
| 3 3 | 
             
                class Model
         | 
| 4 | 
            +
             | 
| 4 5 | 
             
                  attr_reader :name, :attributes
         | 
| 6 | 
            +
             | 
| 5 7 | 
             
                  def initialize(name)
         | 
| 6 8 | 
             
                    @name = name
         | 
| 7 9 | 
             
                    @attributes = Array.new
         | 
| 8 10 | 
             
                  end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                   | 
| 13 | 
            -
                     | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                    @attributes << [name, :date]
         | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
                  def datetime(name, *rest)
         | 
| 19 | 
            -
                    @attributes << [name, :datetime]
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                  def decimal(name, *rest)
         | 
| 22 | 
            -
                    @attributes << [name, :decimal]
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                  def float(name, *rest)
         | 
| 25 | 
            -
                    @attributes << [name, :float]
         | 
| 26 | 
            -
                  end
         | 
| 27 | 
            -
                  def integer(name, *rest)
         | 
| 28 | 
            -
                    @attributes << [name, :integer]
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
                  def primary_key(name, *rest)
         | 
| 31 | 
            -
                    @attributes << [name, :primary_key]
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
                  def string(name, *rest)
         | 
| 34 | 
            -
                    @attributes << [name, :string]
         | 
| 35 | 
            -
                  end
         | 
| 36 | 
            -
                  def text(name, *rest)
         | 
| 37 | 
            -
                    @attributes << [name, :text]
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
                  def time(name, *rest)
         | 
| 40 | 
            -
                    @attributes << [name, :time]
         | 
| 41 | 
            -
                  end
         | 
| 42 | 
            -
                  def timestamp(name, *rest)
         | 
| 43 | 
            -
                    @attributes << [name, :timestamp]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  %w(
         | 
| 13 | 
            +
                     binary boolean date datetime decimal float integer primary_key string text time timestamp
         | 
| 14 | 
            +
                  ).map(&:to_sym).each do |meth|
         | 
| 15 | 
            +
                    define_method(meth) do |name, *rest|
         | 
| 16 | 
            +
                      @attributes << [name, meth]
         | 
| 17 | 
            +
                    end
         | 
| 44 18 | 
             
                  end
         | 
| 19 | 
            +
             | 
| 45 20 | 
             
                end
         | 
| 46 21 |  | 
| 47 22 | 
             
                class Schema
         | 
| 23 | 
            +
             | 
| 48 24 | 
             
                  def self.define(info={}, &block)
         | 
| 49 25 | 
             
                    Schema.new.instance_eval(&block)
         | 
| 50 26 | 
             
                  end
         | 
| 27 | 
            +
             | 
| 51 28 | 
             
                  def create_table(name, options={})
         | 
| 52 29 | 
             
                    td = Model.new(name)
         | 
| 53 30 | 
             
                    td.integer('id')
         | 
| 54 31 | 
             
                    yield td if block_given?
         | 
| 55 32 | 
             
                    Veracode.add_to_archive Veracode.format_variable("@@#{td.name}", td.attributes, 'class')
         | 
| 56 33 | 
             
                  end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                   | 
| 34 | 
            +
             | 
| 35 | 
            +
                  # ActiveRecord::ConnectionAdapters::SchemaStatements
         | 
| 36 | 
            +
                  # http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html
         | 
| 37 | 
            +
                  def add_column(table_name, column_name, type, options = {}) ; end
         | 
| 38 | 
            +
                  def add_index(table_name, column_name, options = {}) ; end
         | 
| 39 | 
            +
                  def add_index_options(table_name, column_name, options = {}) ; end
         | 
| 40 | 
            +
                  def add_index_sort_order(option_strings, column_names, options = {}) ; end
         | 
| 41 | 
            +
                  def add_timestamps(table_name) ; end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  # ActiveRecord::ConnectionAdapters::OracleEnhancedSchemaStatementsExt
         | 
| 44 | 
            +
                  # http://rubydoc.info/gems/activerecord-oracle_enhanced-adapter/ActiveRecord/ConnectionAdapters/OracleEnhancedSchemaStatementsExt
         | 
| 45 | 
            +
                  def add_foreign_key(from_table, to_table, options = {})
         | 
| 46 | 
            +
                    Veracode::log_error "schema.rb: ActiveRecord::ConnectionAdapters::OracleEnhancedSchemaStatementsExt#add_foreign_key called"
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                  def add_primary_key_trigger(table_name, options = {})
         | 
| 49 | 
            +
                    Veracode::log_error "schema.rb: ActiveRecord::ConnectionAdapters::OracleEnhancedSchemaStatementsExt#add_primary_key_trigger called"
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                  def add_synonym(name, table_name, options = {})
         | 
| 52 | 
            +
                    Veracode::log_error "schema.rb: ActiveRecord::ConnectionAdapters::OracleEnhancedSchemaStatementsExt#add_synonym called"
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
                  # def disable_referential_integrity(&block) ; end
         | 
| 55 | 
            +
                  # def foreign_key_definition(to_table, options = {}) ; end
         | 
| 56 | 
            +
                  # def foreign_keys(table_name) ; end
         | 
| 57 | 
            +
                  # def remove_foreign_key(from_table, options) ; end
         | 
| 58 | 
            +
                  # def remove_synonym(name) ; end
         | 
| 59 | 
            +
                  # def supports_foreign_keys? ; end
         | 
| 60 | 
            +
                  # def synonyms ; end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  # TODO: Return only if real receiver would respond to method
         | 
| 63 | 
            +
                  # def method_missing(meth, *args, &block)
         | 
| 64 | 
            +
                  #   if ActiveRecord::ConnectionAdapters::AbstractAdapter.instance_methods.include?(meth)
         | 
| 65 | 
            +
                  #     log_error "Unhandled method: #{meth} args: #{args.to_s}"
         | 
| 66 | 
            +
                  #     nil
         | 
| 67 | 
            +
                  #   else
         | 
| 68 | 
            +
                  #     super
         | 
| 69 | 
            +
                  #   end
         | 
| 70 | 
            +
                  # end
         | 
| 71 | 
            +
                  # def respond_to_everything(meth)
         | 
| 72 | 
            +
                  #   log_error "Unhandled respond_to? for: #{meth}" unless really_respond_to?(meth)
         | 
| 73 | 
            +
                  #   true
         | 
| 74 | 
            +
                  # end
         | 
| 75 | 
            +
                  # alias_method :really_respond_to?, :respond_to?
         | 
| 76 | 
            +
                  # alias_method :respond_to?, :respond_to_everything
         | 
| 59 77 | 
             
                end
         | 
| 60 78 | 
             
              end
         | 
| 61 79 |  | 
    
        data/lib/veracode/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: veracode
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0.0. | 
| 4 | 
            +
              version: 1.0.0.alpha7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Veracode
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015- | 
| 11 | 
            +
            date: 2015-12-10 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rubyzip
         | 
| @@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 58 58 | 
             
                  version: 1.3.1
         | 
| 59 59 | 
             
            requirements: []
         | 
| 60 60 | 
             
            rubyforge_project: 
         | 
| 61 | 
            -
            rubygems_version: 2. | 
| 61 | 
            +
            rubygems_version: 2.0.14
         | 
| 62 62 | 
             
            signing_key: 
         | 
| 63 63 | 
             
            specification_version: 4
         | 
| 64 64 | 
             
            summary: Command line tool for preparing your Ruby on Rails app for submission to
         |