veracode 1.0.0.alpha → 1.0.0.alpha6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/veracode +8 -1
- data/lib/veracode.rb +213 -41
- data/lib/veracode/gems.rb +49 -0
- data/lib/veracode/schema.rb +86 -0
- data/lib/veracode/version.rb +2 -1
- metadata +20 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 902b115fab8cb21e15a5bd54aef3246f5380de49
|
4
|
+
data.tar.gz: ca13044ad546a545134ed74b7b7a3a0504329e47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2268ae1531eedcc77c9b21b77d544c06c6a1f8b10f74504b9c616a092a6d95c2966e8f98188d1f40fbba87eb9701511268a9b614c5f2a35911f0c41630770b47
|
7
|
+
data.tar.gz: 66bc411b52c53ff87c5958eb9a6c2dd1b66048d3d5fa3e2beca07798476eb9899fcb0385cf857fbd20a1e48493394a919729de0560efe47fe26d2867ed70c35c
|
data/bin/veracode
CHANGED
@@ -13,6 +13,7 @@ APP_NAME = File.basename(Dir.pwd)
|
|
13
13
|
COMMAND = "#{$0} #{ARGV.join(' ')}"
|
14
14
|
|
15
15
|
require 'veracode'
|
16
|
+
require 'veracode/version'
|
16
17
|
|
17
18
|
$options = {
|
18
19
|
:phase1 => false,
|
@@ -58,12 +59,18 @@ case subcommand
|
|
58
59
|
|
59
60
|
Veracode.prepare
|
60
61
|
|
62
|
+
when "version", "--version", "-v"
|
63
|
+
puts File.basename($0, '.*') + " " + Veracode::VERSION
|
64
|
+
|
61
65
|
when "help", nil
|
62
66
|
ARGV.clear
|
63
67
|
ARGV.unshift "--help"
|
64
68
|
|
65
69
|
OptionParser.new do |opts|
|
66
|
-
opts.banner = "
|
70
|
+
opts.banner = "#{opts.program_name} #{Veracode::VERSION}\n" +
|
71
|
+
"Usage: #{opts.program_name} prepare [options]\n" +
|
72
|
+
" #{opts.program_name} version\n" +
|
73
|
+
" #{opts.program_name} help"
|
67
74
|
end.parse!
|
68
75
|
|
69
76
|
else
|
data/lib/veracode.rb
CHANGED
@@ -1,34 +1,45 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'set'
|
1
3
|
require 'zlib'
|
2
|
-
require 'zip
|
3
|
-
require
|
4
|
+
require 'zip'
|
5
|
+
require 'veracode/version'
|
6
|
+
require 'veracode/schema'
|
7
|
+
require 'veracode/gems'
|
4
8
|
|
5
9
|
module Veracode
|
6
10
|
@run_id = nil
|
11
|
+
@required_libs = Set.new
|
7
12
|
|
8
13
|
# Metadata and method disassemblies for all Modules (.txt.gz)
|
9
14
|
@disasmlog = nil
|
10
|
-
@disasmlog_filename =
|
15
|
+
@disasmlog_filename = 'disasm.txt.gz'
|
11
16
|
|
12
17
|
# Error log including capture of STDERR and any errors generated by the gem (.log)
|
13
18
|
@errorlog = nil
|
14
|
-
@errorlog_filename =
|
19
|
+
@errorlog_filename = 'error.log'
|
15
20
|
|
16
21
|
# Index file containing the names of files present in the application directory (.txt)
|
17
|
-
@index_filename =
|
22
|
+
@index_filename = 'index.txt'
|
18
23
|
|
19
24
|
# Manifest file containing original names of all files in archive (.txt)
|
20
25
|
@manifest = []
|
21
|
-
@manifest_filename =
|
26
|
+
@manifest_filename = 'manifest.txt'
|
27
|
+
|
28
|
+
# XML file containing list of gems used by application
|
29
|
+
@gems_filename = 'gems.xml'
|
30
|
+
|
31
|
+
# Archive version file containing archive format version identifier
|
32
|
+
@version_filename = 'version.txt'
|
22
33
|
|
23
34
|
# The final archive that will be uploaded to Veracode for analysis (.zip)
|
24
35
|
@archive = nil
|
25
36
|
@archive_filename = nil
|
26
37
|
@archive_dirname = nil
|
27
38
|
|
28
|
-
|
29
39
|
def self.init
|
30
40
|
@run_id = Time.now.strftime("%Y%m%d%H%M%S")
|
31
41
|
@archive_dirname = File.join("tmp","veracode-#{@run_id}")
|
42
|
+
@required_libs.merge(["pathname", "set", "zlib", "zip/zip", "veracode"])
|
32
43
|
|
33
44
|
if !Dir.exists?("tmp")
|
34
45
|
begin
|
@@ -57,9 +68,11 @@ module Veracode
|
|
57
68
|
@disasmlog_filename = File.join(@archive_dirname, @disasmlog_filename)
|
58
69
|
@index_filename = File.join(@archive_dirname, @index_filename)
|
59
70
|
@manifest_filename = File.join(@archive_dirname, @manifest_filename)
|
71
|
+
@gems_filename = File.join(@archive_dirname, @gems_filename)
|
72
|
+
@version_filename = File.join(@archive_dirname, @version_filename)
|
60
73
|
|
61
74
|
# Try touching each of the files to be written
|
62
|
-
[@disasmlog_filename, @errorlog_filename, @index_filename, @manifest_filename].each {|f|
|
75
|
+
[@disasmlog_filename, @errorlog_filename, @index_filename, @manifest_filename, @gems_filename, @version_filename].each {|f|
|
63
76
|
begin
|
64
77
|
File.open(f, "wb") {}
|
65
78
|
rescue Exception => e
|
@@ -76,6 +89,7 @@ module Veracode
|
|
76
89
|
log_error "RUBY_DESCRIPTION: #{RUBY_DESCRIPTION}"
|
77
90
|
log_error "RAILS_VERSION: " + `rails --version`.chomp
|
78
91
|
log_error "GEM_VERSION: #{Veracode::VERSION}"
|
92
|
+
log_error "ARCHIVE_VERSION: #{Veracode::ARCHIVE_VERSION}"
|
79
93
|
log_error "PWD: #{Dir.pwd.to_s.dump}"
|
80
94
|
log_error "APP_NAME: #{APP_NAME.dump}"
|
81
95
|
log_error "RUNID: #{@run_id}"
|
@@ -86,6 +100,16 @@ module Veracode
|
|
86
100
|
STDERR.reopen(@errorlog)
|
87
101
|
end
|
88
102
|
|
103
|
+
begin
|
104
|
+
File.open(@version_filename, "wb") {|version_file|
|
105
|
+
version_file.puts Veracode::ARCHIVE_VERSION
|
106
|
+
}
|
107
|
+
rescue Exception => e
|
108
|
+
log_error "Unable to write to archive version file #{@version_filename}: #{e.message}"
|
109
|
+
end
|
110
|
+
|
111
|
+
list_gems
|
112
|
+
|
89
113
|
index_application
|
90
114
|
|
91
115
|
@manifest += Dir.glob("*").keep_if {|f| File.file?(f)}
|
@@ -101,6 +125,8 @@ module Veracode
|
|
101
125
|
@manifest |= Dir[File.join("**","*.rb")]
|
102
126
|
# Add any other erb files not already added
|
103
127
|
@manifest |= Dir[File.join("**","*.erb")]
|
128
|
+
# Add any other builder files not already added
|
129
|
+
@manifest |= Dir[File.join("**","*.builder")]
|
104
130
|
# Add any other haml files not already added
|
105
131
|
@manifest |= Dir[File.join("**","*.haml")]
|
106
132
|
end
|
@@ -133,7 +159,7 @@ module Veracode
|
|
133
159
|
@errorlog.flush
|
134
160
|
|
135
161
|
begin
|
136
|
-
Zip::
|
162
|
+
Zip::File.open(@archive_filename, Zip::File::CREATE) { |zf|
|
137
163
|
@manifest.each {|file|
|
138
164
|
|
139
165
|
if file.start_with?(@archive_dirname)
|
@@ -155,7 +181,7 @@ module Veracode
|
|
155
181
|
end
|
156
182
|
|
157
183
|
def self.cleanup
|
158
|
-
[@disasmlog_filename, @errorlog_filename, @index_filename, @manifest_filename].each {|f|
|
184
|
+
[@disasmlog_filename, @errorlog_filename, @index_filename, @manifest_filename, @gems_filename, @version_filename].each {|f|
|
159
185
|
begin
|
160
186
|
File.delete(f)
|
161
187
|
rescue Exception => e
|
@@ -198,12 +224,20 @@ module Veracode
|
|
198
224
|
|
199
225
|
##############################################################################
|
200
226
|
# Helpers
|
227
|
+
def self.cond_require(lib)
|
228
|
+
if @required_libs.add?(lib)
|
229
|
+
return require lib
|
230
|
+
end
|
231
|
+
return false
|
232
|
+
end
|
233
|
+
|
201
234
|
def self.glob_require(files)
|
235
|
+
any_new = false
|
202
236
|
Dir.glob(files) do |f|
|
203
237
|
print "Requiring #{f.to_s} " if $options[:verbose]
|
204
238
|
|
205
239
|
begin
|
206
|
-
|
240
|
+
any_new |= cond_require File.expand_path(f)
|
207
241
|
rescue Exception => e
|
208
242
|
puts "(failed: #{e.message})" if $options[:verbose]
|
209
243
|
log_error "Unable to require #{File.expand_path(f).to_s.dump} (#{e.message})"
|
@@ -212,6 +246,7 @@ module Veracode
|
|
212
246
|
end
|
213
247
|
|
214
248
|
end
|
249
|
+
return any_new
|
215
250
|
end
|
216
251
|
|
217
252
|
def self.safe_name(o)
|
@@ -412,8 +447,8 @@ module Veracode
|
|
412
447
|
|
413
448
|
%w[ public protected private ].each {|p|
|
414
449
|
get_methods = (p + "_instance_methods").to_sym
|
415
|
-
if m.respond_to?(get_methods) && m.
|
416
|
-
m.
|
450
|
+
if m.respond_to?(get_methods) && m.__send__(get_methods, $options[:include_inherited]).count > 0
|
451
|
+
m.__send__(get_methods, $options[:include_inherited]).each do |m_symbol|
|
417
452
|
begin
|
418
453
|
method = m.instance_method(m_symbol)
|
419
454
|
formatted_contents += format_method(method, "#{p.to_s}_instance", with_disasm)
|
@@ -465,7 +500,12 @@ module Veracode
|
|
465
500
|
# Archiving Objects
|
466
501
|
def self.archive(objects, with_disasm=true)
|
467
502
|
|
468
|
-
objects = objects - [
|
503
|
+
objects = objects - [
|
504
|
+
Veracode,
|
505
|
+
Veracode::ActiveRecord,
|
506
|
+
Veracode::ActiveRecord::Model,
|
507
|
+
Veracode::ActiveRecord::Schema,
|
508
|
+
]
|
469
509
|
|
470
510
|
if $options[:verbose]
|
471
511
|
puts "Archiving #{objects.count.to_s} objects" + (with_disasm ? " with disassembly" : "")
|
@@ -491,6 +531,68 @@ module Veracode
|
|
491
531
|
end
|
492
532
|
|
493
533
|
|
534
|
+
def self.compile_templates
|
535
|
+
|
536
|
+
begin
|
537
|
+
cond_require 'action_view' unless defined? ActionView
|
538
|
+
cond_require 'action_controller' unless defined? ActionController
|
539
|
+
rescue Exception => e
|
540
|
+
log_error "Unable to satisfy haml dependencies (#{e.message})"
|
541
|
+
return
|
542
|
+
end
|
543
|
+
|
544
|
+
types = %w{ erb builder haml }
|
545
|
+
|
546
|
+
view_paths = []
|
547
|
+
view_paths += ActionController::Base.view_paths.to_a.map(&:to_s)
|
548
|
+
view_paths |= [File.expand_path("app/views")]
|
549
|
+
|
550
|
+
puts "Looking for templates in #{view_paths.join(", ")}" if $options[:verbose]
|
551
|
+
|
552
|
+
templates = view_paths.map { |vp|
|
553
|
+
Dir[File.join(vp, "**", "*.erb")] +
|
554
|
+
Dir[File.join(vp, "**", "*.builder")] +
|
555
|
+
Dir[File.join(vp, "**", "*.haml")]
|
556
|
+
}.flatten
|
557
|
+
|
558
|
+
return unless templates.count > 0
|
559
|
+
|
560
|
+
puts "Found #{templates.count} templates" if $options[:verbose]
|
561
|
+
log_error "Found #{templates.count} templates"
|
562
|
+
|
563
|
+
haml_templates = templates.grep(/\.haml$/)
|
564
|
+
if haml_templates.any?
|
565
|
+
begin
|
566
|
+
cond_require 'haml' unless defined? Haml
|
567
|
+
cond_require 'haml/template/plugin' unless defined? Haml::Plugin
|
568
|
+
rescue Exception => e
|
569
|
+
puts "Unable to satisfy haml dependencies"
|
570
|
+
log_error "Unable to satisfy haml dependencies (#{e.message})"
|
571
|
+
templates -= haml_templates
|
572
|
+
puts " #{templates.count} templates" if $options[:verbose]
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
assigns = {}
|
577
|
+
view = ActionView::Base.new(view_paths, assigns)
|
578
|
+
controller_view = ApplicationController.new.view_context
|
579
|
+
|
580
|
+
templates.each { |template|
|
581
|
+
puts "Compiling template #{template}" if $options[:verbose]
|
582
|
+
|
583
|
+
begin
|
584
|
+
# This render will fail, but will trigger compilation of template
|
585
|
+
view.render(:file => template)
|
586
|
+
rescue Exception => e
|
587
|
+
log_error "Compiled template #{template} #{e.message}"
|
588
|
+
end
|
589
|
+
}
|
590
|
+
|
591
|
+
puts "Compiled #{ActionView::CompiledTemplates.instance_methods.count.to_s} templates" if $options[:verbose]
|
592
|
+
log_error "Compiled #{ActionView::CompiledTemplates.instance_methods.count.to_s} templates"
|
593
|
+
log_error "Not all templates were compiled" if ActionView::CompiledTemplates.instance_methods.count < templates.count
|
594
|
+
end
|
595
|
+
|
494
596
|
def self.compile_erb_templates
|
495
597
|
|
496
598
|
# Rails 3 has wrapped Erubis to handle block helpers in ERB templates
|
@@ -563,9 +665,9 @@ module Veracode
|
|
563
665
|
return unless templates.count > 0
|
564
666
|
|
565
667
|
begin
|
566
|
-
|
567
|
-
|
568
|
-
|
668
|
+
cond_require 'action_view'
|
669
|
+
cond_require 'haml'
|
670
|
+
cond_require 'haml/template/plugin'
|
569
671
|
rescue Exception => e
|
570
672
|
log_error "Unable to satisfy haml dependencies (#{e.message})"
|
571
673
|
return
|
@@ -604,7 +706,58 @@ module Veracode
|
|
604
706
|
|
605
707
|
end
|
606
708
|
|
607
|
-
|
709
|
+
def self.require_libs(lib_paths)
|
710
|
+
for lib_path in lib_paths
|
711
|
+
dirsToProcess = [Pathname(lib_path)]
|
712
|
+
until dirsToProcess.count == 0 || !Dir.exists?(dirsToProcess[0])
|
713
|
+
currentDir = dirsToProcess.delete_at(0)
|
714
|
+
for child in currentDir.children
|
715
|
+
if child.directory?
|
716
|
+
dirsToProcess[dirsToProcess.count] = child
|
717
|
+
base = child.to_s.partition("#{lib_path}/")[2]
|
718
|
+
lib = ""
|
719
|
+
for part in base.split('/').reverse
|
720
|
+
lib = "#{part}/#{lib}"
|
721
|
+
lib = lib[0..lib.length-2] if lib[lib.length-1] == '/'
|
722
|
+
begin
|
723
|
+
if cond_require lib
|
724
|
+
puts "requiring #{lib}" if $options[:verbose]
|
725
|
+
end
|
726
|
+
rescue Exception => e
|
727
|
+
end
|
728
|
+
end
|
729
|
+
end
|
730
|
+
end
|
731
|
+
end
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
def self.require_rails(gemdir)
|
736
|
+
dirsToProcess = [Pathname(gemdir)]
|
737
|
+
until dirsToProcess.count == 0
|
738
|
+
currentDir = dirsToProcess.delete_at(0)
|
739
|
+
for child in currentDir.children
|
740
|
+
if child.directory?
|
741
|
+
dirsToProcess[dirsToProcess.count] = child
|
742
|
+
end
|
743
|
+
base = child.to_s.partition("#{gemdir}/")[2]
|
744
|
+
if base.index("action_controller") != nil || base.index("action_view") != nil || base.index("active_record") != nil
|
745
|
+
lib = ""
|
746
|
+
for part in base.split('/').reverse
|
747
|
+
lib = "#{part}/#{lib}"
|
748
|
+
lib = lib[0..lib.length-2] if lib[lib.length-1] == '/'
|
749
|
+
lib.chomp!(File.extname(lib))
|
750
|
+
begin
|
751
|
+
if cond_require lib
|
752
|
+
puts "requiring #{lib}" if $options[:verbose]
|
753
|
+
end
|
754
|
+
rescue Exception => e
|
755
|
+
end
|
756
|
+
end
|
757
|
+
end
|
758
|
+
end
|
759
|
+
end
|
760
|
+
end
|
608
761
|
|
609
762
|
|
610
763
|
################################################################################
|
@@ -653,12 +806,46 @@ module Veracode
|
|
653
806
|
|
654
807
|
puts "Phase 2 - Load Rails" if $options[:verbose]
|
655
808
|
begin
|
656
|
-
|
809
|
+
cond_require "rails"
|
810
|
+
cond_require 'action_controller'
|
811
|
+
cond_require 'action_view'
|
812
|
+
cond_require 'active_record'
|
657
813
|
rescue Exception => e
|
658
814
|
puts "Unable to require rails: #{e.message}"
|
659
815
|
log_error "Unable to require rails: #{e.message}"
|
660
816
|
exit
|
661
817
|
else
|
818
|
+
@stdlib = $:
|
819
|
+
@gemdir = Gem.dir
|
820
|
+
|
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
|
+
require_libs(@stdlib)
|
848
|
+
require_rails(@gemdir)
|
662
849
|
puts "Required rails" if $options[:verbose]
|
663
850
|
end
|
664
851
|
|
@@ -681,26 +868,6 @@ module Veracode
|
|
681
868
|
# phase 3 - require app
|
682
869
|
|
683
870
|
puts "Phase 3 - Imitate Rails" if $options[:verbose]
|
684
|
-
|
685
|
-
## Imitate script/rails
|
686
|
-
# APP_PATH = File.expand_path('config/application')
|
687
|
-
# APP_PATH is already set in bin/veracode
|
688
|
-
#require File.expand_path('../../config/boot', __FILE__)
|
689
|
-
glob_require "config/boot.rb"
|
690
|
-
#require 'rails/commands'
|
691
|
-
# this will trigger the console to be launched
|
692
|
-
# ARGV.clear
|
693
|
-
# ARGV << 'console'
|
694
|
-
# ARGV << '--sandbox'
|
695
|
-
# require 'rails/commands'
|
696
|
-
|
697
|
-
## Imitate rails/commands when console
|
698
|
-
glob_require 'rails/commands/console'
|
699
|
-
# require APP_PATH # => config/application.rb
|
700
|
-
|
701
|
-
glob_require "config/application.rb"
|
702
|
-
|
703
|
-
Rails.application.require_environment! unless $options[:jruby]
|
704
871
|
# Following line will actually kick off IRB
|
705
872
|
# Rails::Console.start(Rails.application)
|
706
873
|
|
@@ -709,23 +876,28 @@ module Veracode
|
|
709
876
|
glob_require "rails/console/app"
|
710
877
|
glob_require "rails/console/helpers"
|
711
878
|
|
879
|
+
glob_require "lib/**/*.rb"
|
712
880
|
glob_require "app/models/**/*.rb"
|
713
881
|
glob_require "app/helpers/**/*.rb"
|
714
882
|
glob_require "app/controllers/application_controller.rb"
|
715
883
|
glob_require "app/controllers/**/*.rb"
|
716
884
|
|
717
|
-
|
718
|
-
compile_haml_templates
|
885
|
+
compile_templates
|
719
886
|
|
720
887
|
self.update
|
721
888
|
self.stats if $options[:verbose]
|
722
889
|
|
890
|
+
# Ensure compiled templates are fully disassembled in archive
|
891
|
+
@baseline_modules.delete(ActionView::CompiledTemplates)
|
892
|
+
|
723
893
|
if $options[:phase3]
|
724
894
|
puts "Processing and disassembling #{APP_NAME} classes and modules"
|
725
895
|
archive(@baseline_modules, false)
|
726
896
|
archive(@modules - @baseline_modules, true)
|
727
897
|
end
|
728
898
|
|
899
|
+
archive_schema
|
900
|
+
|
729
901
|
## /phase 3 - require app
|
730
902
|
################################################################
|
731
903
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Veracode
|
2
|
+
SupportedGems = %w{
|
3
|
+
actionmailer
|
4
|
+
actionpack
|
5
|
+
activemodel
|
6
|
+
activerecord
|
7
|
+
activeresource
|
8
|
+
activesupport
|
9
|
+
arel
|
10
|
+
builder
|
11
|
+
erubis
|
12
|
+
haml
|
13
|
+
haml-rails
|
14
|
+
rails
|
15
|
+
railties
|
16
|
+
veracode
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.list_gems
|
20
|
+
|
21
|
+
gems = `bundle list`.each_line
|
22
|
+
.reject {|line| line !~ /^ \* /}
|
23
|
+
.map {|line| line[4..-1]}
|
24
|
+
.map {|line| line.split.first}
|
25
|
+
|
26
|
+
begin
|
27
|
+
File.open(@gems_filename, "wb") {|gems_file|
|
28
|
+
gems_file.puts '<messages>'
|
29
|
+
gems.each {|gem|
|
30
|
+
gems_file << <<GEMS_XML
|
31
|
+
<message>
|
32
|
+
<platform>ruby</platform>
|
33
|
+
<name>#{gem}</name>
|
34
|
+
<detailed_message>#{gem}</detailed_message>
|
35
|
+
<token>#{gem}</token>
|
36
|
+
<package>rubygem.#{gem}</package>
|
37
|
+
<errorlevel>#{(SupportedGems.include?(gem) ? "info" : "warn" )}</errorlevel>
|
38
|
+
<type>framework_unsupported</type>
|
39
|
+
</message>
|
40
|
+
GEMS_XML
|
41
|
+
}
|
42
|
+
gems_file.puts '</messages>'
|
43
|
+
}
|
44
|
+
rescue Exception => e
|
45
|
+
log_error "Unable to write to gem list to file #{@gems_filename}: #{e.message}"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Veracode
|
2
|
+
module ActiveRecord
|
3
|
+
class Model
|
4
|
+
attr_reader :name, :attributes
|
5
|
+
def initialize(name)
|
6
|
+
@name = name
|
7
|
+
@attributes = Array.new
|
8
|
+
end
|
9
|
+
def binary(name, *rest)
|
10
|
+
@attributes << [name, :binary]
|
11
|
+
end
|
12
|
+
def boolean(name, *rest)
|
13
|
+
@attributes << [name, :boolean]
|
14
|
+
end
|
15
|
+
def date(name, *rest)
|
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]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Schema
|
48
|
+
def self.define(info={}, &block)
|
49
|
+
Schema.new.instance_eval(&block)
|
50
|
+
end
|
51
|
+
def create_table(name, options={})
|
52
|
+
td = Model.new(name)
|
53
|
+
td.integer('id')
|
54
|
+
yield td if block_given?
|
55
|
+
Veracode.add_to_archive Veracode.format_variable("@@#{td.name}", td.attributes, 'class')
|
56
|
+
end
|
57
|
+
def add_index(table_name, column_name, options = {})
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.archive_schema
|
63
|
+
puts "Evaluating and archiving schema information"
|
64
|
+
schema_file = File.join("db", "schema.rb")
|
65
|
+
|
66
|
+
begin
|
67
|
+
schema = 'Veracode::' + File.read(schema_file).each_line.reject {|l| l =~ /^\s*#/}.join
|
68
|
+
rescue Exception => e
|
69
|
+
puts "Unable to retrieve schema information from 'db/schema.rb'. Are your migrations up to date?"
|
70
|
+
log_error "Unable to retrieve schema from 'db/schema.rb' (#{e.message})"
|
71
|
+
add_to_archive %Q|module "Veracode::Schema"\n|
|
72
|
+
add_to_archive %Q|endmodule\n\n|
|
73
|
+
return
|
74
|
+
end
|
75
|
+
|
76
|
+
add_to_archive %Q|module "Veracode::Schema"\n|
|
77
|
+
begin
|
78
|
+
eval(schema)
|
79
|
+
rescue Exception => e
|
80
|
+
puts "Unable to evaluate schema information from 'db/schema.rb'. (#{e.message})"
|
81
|
+
log_error "Unable to evaluate 'db/schema.rb' (#{e.message})"
|
82
|
+
end
|
83
|
+
add_to_archive %Q|endmodule\n\n|
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/lib/veracode/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: veracode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
5
|
-
prerelease: 6
|
4
|
+
version: 1.0.0.alpha6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Veracode
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rubyzip
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
19
|
+
version: '1.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
25
27
|
description: Prepares your Ruby on Rails app for submission to Veracode.
|
26
28
|
email: devcontact@veracode.com
|
27
29
|
executables:
|
@@ -31,30 +33,34 @@ extra_rdoc_files: []
|
|
31
33
|
files:
|
32
34
|
- bin/veracode
|
33
35
|
- lib/veracode.rb
|
36
|
+
- lib/veracode/gems.rb
|
37
|
+
- lib/veracode/schema.rb
|
34
38
|
- lib/veracode/version.rb
|
35
39
|
homepage: http://veracode.com/
|
36
40
|
licenses: []
|
41
|
+
metadata: {}
|
37
42
|
post_install_message:
|
38
43
|
rdoc_options: []
|
39
44
|
require_paths:
|
40
45
|
- lib
|
41
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
47
|
requirements:
|
44
|
-
- -
|
48
|
+
- - '>='
|
45
49
|
- !ruby/object:Gem::Version
|
46
50
|
version: 1.9.3.0
|
51
|
+
- - <
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.2.0
|
47
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
-
none: false
|
49
55
|
requirements:
|
50
|
-
- -
|
56
|
+
- - '>'
|
51
57
|
- !ruby/object:Gem::Version
|
52
58
|
version: 1.3.1
|
53
59
|
requirements: []
|
54
60
|
rubyforge_project:
|
55
|
-
rubygems_version:
|
61
|
+
rubygems_version: 2.4.3
|
56
62
|
signing_key:
|
57
|
-
specification_version:
|
63
|
+
specification_version: 4
|
58
64
|
summary: Command line tool for preparing your Ruby on Rails app for submission to
|
59
65
|
Veracode
|
60
66
|
test_files: []
|