Skip to content

Commit

Permalink
Added Uploads API Calls and Re-org of Base API result class
Browse files Browse the repository at this point in the history
  • Loading branch information
mort666 committed Dec 28, 2012
1 parent 47002a5 commit e0fbe44
Show file tree
Hide file tree
Showing 13 changed files with 836 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.bundle
Gemfile.lock
pkg/*

.DS_Store
8 changes: 4 additions & 4 deletions lib/veracode/api/builds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
module Veracode
module Result
module Builds
class AnalysisUnit < Base
class AnalysisUnit < Veracode::Common::Base
api_field :analysis_type, :tag => :analysis_type
api_field :status, :tag => :status
api_field :published_date, :tag => :published_date
end

class Build < Base
class Build < Veracode::Common::Base
api_field :version, :tag => :version
api_field :build_id, :tag => :build_id
api_field :submitter, :tag => :submitter
Expand Down Expand Up @@ -47,7 +47,7 @@ def analysis_units
end
end

class Application < Base
class Application < Veracode::Common::Base
api_field :app_name, :tag => :app_name
api_field :app_id, :tag => :app_id
api_field :industry_vertical, :tag => :industry_vertical
Expand Down Expand Up @@ -76,7 +76,7 @@ def builds
end
end

class Applications < Base
class Applications < Veracode::Common::Base
def applications
@applications ||= []
if @applications.empty?
Expand Down
8 changes: 4 additions & 4 deletions lib/veracode/api/detailed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module Veracode
module Result
class CWE < Base
class CWE < Veracode::Common::Base
api_field :cweid, :tag => :cweid
api_field :cwename, :tag => :cwename

Expand All @@ -21,7 +21,7 @@ def description

end

class Category < Base
class Category < Veracode::Common::Base
api_field :categoryid, :tag => :categoryid
api_field :categoryname, :tag => :categoryname
api_type_field :desc, :tag => :desc, :as => Para
Expand Down Expand Up @@ -84,7 +84,7 @@ def cwe
end
end

class Severity < Base
class Severity < Veracode::Common::Base
api_field :level, :tag => :level

def categories
Expand All @@ -106,7 +106,7 @@ def categories
end
end

class DetailedReport < Base
class DetailedReport < Veracode::Common::Base

api_field :report_format_version, :tag => :report_format_version
api_field :app_name, :tag => :app_name
Expand Down
16 changes: 8 additions & 8 deletions lib/veracode/api/flaws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

module Veracode
module Result
class AnnotationType < Base
class AnnotationType < Veracode::Common::Base
api_field :action, :tag => :action
api_field :description, :tag => :description
api_field :user, :tag => :user
api_field :date, :tag => :date
end

class Annotations < Base
class Annotations < Veracode::Common::Base
def annotation
@annotations ||= []
begin
Expand All @@ -29,14 +29,14 @@ def annotation
end
end

class MitigationType < Base
class MitigationType < Veracode::Common::Base
api_field :action, :tag => :action
api_field :description, :tag => :description
api_field :user, :tag => :user
api_field :date, :tag => :date
end

class Mitigations < Base
class Mitigations < Veracode::Common::Base
def mitigation
@mitigations ||= []
begin
Expand All @@ -56,12 +56,12 @@ def mitigation
end
end

class ExploitabilityAdjustment < Base
class ExploitabilityAdjustment < Veracode::Common::Base
api_field :note, :tag => :note
api_field :score_adjustment, :tag => :score_adjustment
end

class ExploitAdjustment < Base
class ExploitAdjustment < Veracode::Common::Base
def exploitability_adjustment
@exploitability_adjustments ||= []
begin
Expand All @@ -81,7 +81,7 @@ def exploitability_adjustment
end
end

class Flaw < Base
class Flaw < Veracode::Common::Base
api_field :severity, :tag => :severity
api_field :categoryname, :tag => :categoryname
api_field :count, :tag => :count
Expand Down Expand Up @@ -130,7 +130,7 @@ def affects_policy_compliance?
api_type_field :annotations, :tag => :annotations, :as => Annotations
end

class Flaws < Base
class Flaws < Veracode::Common::Base
def flaws
@flaws ||= []
begin
Expand Down
6 changes: 3 additions & 3 deletions lib/veracode/api/summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
module Veracode
module Result

class SummaryCategory < Base
class SummaryCategory < Veracode::Common::Base
api_field :categoryname, :tag => :categoryname
api_field :severity, :tag => :severity
api_field :count, :tag => :count
end

class SummarySeverity < Base
class SummarySeverity < Veracode::Common::Base
api_field :level, :tag => :level

def categories
Expand All @@ -32,7 +32,7 @@ def categories
end
end

class SummaryReport < Base
class SummaryReport < Veracode::Common::Base
api_field :report_format_version, :tag => :report_format_version
api_field :app_name, :tag => :app_name
api_field :app_id, :tag => :app_id
Expand Down
33 changes: 20 additions & 13 deletions lib/veracode/api/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
# Veracode API General Types used by Summary and Detailed results as well as Application Build API
#
module Veracode
module Result
module Common
# Base Class for result
class Base

def self.api_field(name, args)
send(:define_method, name) do
return @xml_hash.send(args[:tag].to_sym)
begin
return @xml_hash.send(args[:tag].to_sym)
rescue NoMethodError
return nil
end
end
end

Expand All @@ -22,6 +26,7 @@ def self.api_type_field(name, args)
instance_variable_set("@#{name}", tmp)
return tmp
rescue NoMethodError
return nil
end
end
end
Expand All @@ -30,8 +35,10 @@ def initialize(xml_hash)
@xml_hash = xml_hash
end
end

class Screenshot < Base
end

module Result
class Screenshot < Veracode::Common::Base
api_field :format, :tag => :format

def data
Expand All @@ -42,11 +49,11 @@ def data
#xml_reader(:data) {|b64data| Base64.decode64(b64data) }
end

class BulletType < Base
class BulletType < Veracode::Common::Base
api_field :text, :tag => :text
end

class ParaType < Base
class ParaType < Veracode::Common::Base
#xml_reader :bulletitem, :as => [BulletType]
api_field :text, :tag => :text

Expand All @@ -68,11 +75,11 @@ def bulletitem
end
end

class TextType < Base
class TextType < Veracode::Common::Base
#xml_reader :text, :from => "text/@text"
end

class Para < Base
class Para < Veracode::Common::Base
#xml_reader :para, :as => [ParaType]
def para
@paras ||= []
Expand All @@ -89,7 +96,7 @@ def para
end
end

class AppendixType < Base
class AppendixType < Veracode::Common::Base
api_field :description, :tag => :description
#xml_reader :screenshot, :as => [Screenshot]
def screenshot
Expand All @@ -111,7 +118,7 @@ def screenshot
api_field :code, :tag => :code
end

class Module < Base
class Module < Veracode::Common::Base
api_field :name, :tag => :name
api_field :compiler, :tag => :compiler
api_field :os, :tag => :os
Expand All @@ -125,7 +132,7 @@ class Module < Base
api_field :numflawssev5, :tag => :numflawssev5
end

class Analysis < Base
class Analysis < Veracode::Common::Base

api_field :analysis_size_bytes, :tag => :analysis_size_bytes
api_field :rating, :tag => :rating
Expand All @@ -151,7 +158,7 @@ def modules
end
end

class ManualAnalysis < Base
class ManualAnalysis < Veracode::Common::Base
api_field :rating, :tag => :rating
api_field :score, :tag => :score
api_field :mitigated_rating, :tag => :mitigated_rating
Expand All @@ -177,7 +184,7 @@ def modules
end
end

class FlawStatus < Base
class FlawStatus < Veracode::Common::Base
api_field :new_flaws, :tag => :new
api_field :reopen_flaws, :tag => :reopen
#api_field :open_flaws, :tag => :open
Expand Down
Loading

0 comments on commit e0fbe44

Please sign in to comment.