Skip to content

Commit

Permalink
Added Summary Report and Unit Tests, cleaned up test structure and mo…
Browse files Browse the repository at this point in the history
…ve some types to global type definitions
  • Loading branch information
mort666 committed Jun 6, 2012
1 parent d5181c7 commit 74b7c3a
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 78 deletions.
60 changes: 3 additions & 57 deletions lib/veracode/api/detailed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,6 @@

module Veracode
module Result
class Modules < Base
xml_reader :name, :from => "@name"
xml_reader :compiler, :from => "@compiler"
xml_reader :os, :from => "@os"
xml_reader :architecture, :from => "@architecture"
xml_reader :score, :from => "@score"
xml_reader :numflawssev0, :from => "@numflawssev0"
xml_reader :numflawssev1, :from => "@numflawssev1"
xml_reader :numflawssev2, :from => "@numflawssev2"
xml_reader :numflawssev3, :from => "@numflawssev3"
xml_reader :numflawssev4, :from => "@numflawssev4"
xml_reader :numflawssev5, :from => "@numflawssev5"
end

class Analysis < Base
xml_reader :rating, :from => "@rating"
xml_reader :score, :from => "@score"
xml_reader :submitted_date, :from => "@submitted_date"
xml_reader :published_date, :from => "@published_date"
xml_reader :mitigated_rating, :from => "@mitigated_rating"
xml_reader :mitigated_score, :from => "@mitigated_score"
xml_reader :analysis_size_bytes, :from => "@analysis_size_bytes"
xml_reader :next_scan_due, :from => "@next_scan_due"

xml_reader :modules, :as => [Modules]
end

class ManualAnalysis < Base
xml_reader :rating, :from => "@rating"
xml_reader :score, :from => "@score"
xml_reader :mitigated_rating, :from => "@mitigated_rating"
xml_reader :mitigated_score, :from => "@mitigated_score"
xml_reader :submitted_date, :from => "@submitted_date"
xml_reader :published_date, :from => "@published_date"
xml_reader :next_scan_due, :from => "@next_scan_due"

xml_reader :modules, :as => [Modules]
xml_reader :cia_adjustment
xml_reader :delivery_consultant
end

class CWE < Base
xml_reader :cweid, :from => "@cweid"
xml_reader :cwename, :from => "@cwename"
Expand All @@ -65,20 +24,6 @@ class Category < Base
xml_reader :cwe, :as => [CWE]
end

class FlawStatus < Base
xml_reader :new, :from => :attr
xml_reader :reopen, :from => :attr
xml_reader :open, :from => :attr
xml_reader :fixed, :from => :attr
xml_reader :total, :from => :attr
xml_reader :not_mitigated, :from => :attr
xml_reader :sev_1_change, :from => :attr
xml_reader :sev_2_change, :from => :attr
xml_reader :sev_3_change, :from => :attr
xml_reader :sev_4_change, :from => :attr
xml_reader :sev_5_change, :from => :attr
end

class Severity < Base
xml_reader :level, :from => "@level"

Expand All @@ -95,6 +40,7 @@ class DetailedReport < Base
xml_reader :version, :from => "@version"
xml_reader :build_id, :from => "@build_id"
xml_reader :submitter, :from => "@submitter"
xml_reader :vendor, :from => "@vendor"
xml_reader :platform, :from => "@platform"
xml_reader :assurance_level, :from => "@assurance_level"
xml_reader :business_criticality, :from => "@business_criticality"
Expand All @@ -106,7 +52,7 @@ class DetailedReport < Base
xml_reader :life_cycle_stage, :from => "@life_cycle_stage"
xml_reader :planned_deployment_date, :from => "@planned_deployment_date"
xml_reader :last_update_time, :from => "@last_update_time"
xml_reader :is_latest_build, :from => "@is_latest_build"
xml_reader :is_latest_build?, :from => "@is_latest_build"
xml_reader :policy_name, :from => "@policy_name"
xml_reader :policy_version, :from => "@policy_version"
xml_reader :policy_compliance_status, :from => "@policy_compliance_status"
Expand All @@ -116,7 +62,7 @@ class DetailedReport < Base
xml_reader :business_owner, :from => "@business_owner"
xml_reader :business_unit, :from => "@business_unit"
xml_reader :tags, :from => "@tags"
xml_reader :grace_period_expired, :from => "@grace_period_expired"
xml_reader :grace_period_expired?, :from => "@grace_period_expired"


xml_reader :static_analysis, :as => Analysis
Expand Down
63 changes: 63 additions & 0 deletions lib/veracode/api/summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'veracode/api/types'
require 'veracode/api/flaws'

module Veracode
module Result

class SummaryCategory < Base
xml_reader :categoryname, :from => :attr
xml_reader :severity, :from => :attr
xml_reader :count, :from => :attr
end

class SummarySeverity < Base
xml_reader :level, :from => "@level"

xml_reader :categories, :as => [SummaryCategory]
end

class SummaryReport < Base
xml_convention :dasherize

xml_reader :report_format_version, :from => "@report_format_version"
xml_reader :app_name, :from => "@app_name"
xml_reader :app_id, :from => "@app_id"
xml_reader :first_build_submitted_date, :from => "@first_build_submitted_date"
xml_reader :version, :from => "@version"
xml_reader :build_id, :from => "@build_id"
xml_reader :vendor, :from => "@vendor"
xml_reader :submitter, :from => "@submitter"
xml_reader :platform, :from => "@platform"
xml_reader :assurance_level, :from => "@assurance_level"
xml_reader :business_criticality, :from => "@business_criticality"
xml_reader :generation_date, :from => "@generation_date"
xml_reader :veracode_level, :from => "@veracode_level"
xml_reader :total_flaws, :from => "@total_flaws"
xml_reader :flaws_not_mitigated, :from => "@flaws_not_mitigated"
xml_reader :teams, :from => "@teams"
xml_reader :life_cycle_stage, :from => "@life_cycle_stage"
xml_reader :planned_deployment_date, :from => "@planned_deployment_date"
xml_reader :last_update_time, :from => "@last_update_time"
xml_reader :is_latest_build?, :from => "@is_latest_build"
xml_reader :policy_name, :from => "@policy_name"
xml_reader :policy_version, :from => "@policy_version"
xml_reader :policy_compliance_status, :from => "@policy_compliance_status"
xml_reader :policy_rules_status, :from => "@policy_rules_status"
xml_reader :scan_overdue, :from => "@scan_overdue"
xml_reader :any_type_scan_due, :from => "@any_type_scan_due"
xml_reader :business_owner, :from => "@business_owner"
xml_reader :business_unit, :from => "@business_unit"
xml_reader :tags, :from => "@tags"
xml_reader :grace_period_expired?, :from => "@grace_period_expired"


xml_reader :static_analysis, :as => Analysis
xml_reader :dynamic_analysis, :as => Analysis
xml_reader :manual_analysis, :as => ManualAnalysis

xml_reader :severity, :as => [SummarySeverity]

xml_reader :flaw_status, :as => FlawStatus
end
end
end
55 changes: 55 additions & 0 deletions lib/veracode/api/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,60 @@ class AppendixType < Base
xml_reader :screenshot, :as => [Screenshot]
xml_reader :code
end

class Modules < Base
xml_reader :name, :from => "@name"
xml_reader :compiler, :from => "@compiler"
xml_reader :os, :from => "@os"
xml_reader :architecture, :from => "@architecture"
xml_reader :score, :from => "@score"
xml_reader :numflawssev0, :from => "@numflawssev0"
xml_reader :numflawssev1, :from => "@numflawssev1"
xml_reader :numflawssev2, :from => "@numflawssev2"
xml_reader :numflawssev3, :from => "@numflawssev3"
xml_reader :numflawssev4, :from => "@numflawssev4"
xml_reader :numflawssev5, :from => "@numflawssev5"
end

class Analysis < Base
xml_reader :rating, :from => "@rating"
xml_reader :score, :from => "@score"
xml_reader :submitted_date, :from => "@submitted_date"
xml_reader :published_date, :from => "@published_date"
xml_reader :mitigated_rating, :from => "@mitigated_rating"
xml_reader :mitigated_score, :from => "@mitigated_score"
xml_reader :analysis_size_bytes, :from => "@analysis_size_bytes"
xml_reader :next_scan_due, :from => "@next_scan_due"

xml_reader :modules, :as => [Modules]
end

class ManualAnalysis < Base
xml_reader :rating, :from => "@rating"
xml_reader :score, :from => "@score"
xml_reader :mitigated_rating, :from => "@mitigated_rating"
xml_reader :mitigated_score, :from => "@mitigated_score"
xml_reader :submitted_date, :from => "@submitted_date"
xml_reader :published_date, :from => "@published_date"
xml_reader :next_scan_due, :from => "@next_scan_due"

xml_reader :modules, :as => [Modules]
xml_reader :cia_adjustment
xml_reader :delivery_consultant
end

class FlawStatus < Base
xml_reader :new, :from => :attr
xml_reader :reopen, :from => :attr
xml_reader :open, :from => :attr
xml_reader :fixed, :from => :attr
xml_reader :total, :from => :attr
xml_reader :not_mitigated, :from => :attr
xml_reader :sev_1_change, :from => :attr
xml_reader :sev_2_change, :from => :attr
xml_reader :sev_3_change, :from => :attr
xml_reader :sev_4_change, :from => :attr
xml_reader :sev_5_change, :from => :attr
end
end
end
12 changes: 11 additions & 1 deletion lib/veracode/results.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'nokogiri'
require 'veracode/api/builds'
require 'veracode/api/detailed'
require 'veracode/api/summary'

require 'pp'

module Veracode
class Results < Veracode::Base
Expand All @@ -23,6 +23,16 @@ def get_application_builds
end
end

def get_summary_report(build_id)
xml = getXML(SUMMARY_REPORT_URI + "?build_id=" + build_id)
case xml.code
when 200
report = Veracode::Result::SummaryReport.from_xml(xml.body)
else
xml.error!
end
end

def get_detailed_report(build_id)
xml = getXML(DETAILED_REPORT_URI + "?build_id=" + build_id)
case xml.code
Expand Down
Loading

0 comments on commit 74b7c3a

Please sign in to comment.