veracode-api 0.4.1

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.
@@ -0,0 +1,93 @@
1
+ require 'veracode/api/types'
2
+ require 'veracode/api/flaws'
3
+
4
+ module Veracode
5
+ module Result
6
+
7
+ class SummaryCategory < Veracode::Common::Base
8
+ api_field :categoryname, :tag => :categoryname
9
+ api_field :severity, :tag => :severity
10
+ api_field :count, :tag => :count
11
+ end
12
+
13
+ class SummarySeverity < Veracode::Common::Base
14
+ api_field :level, :tag => :level
15
+
16
+ def categories
17
+ @categories ||= []
18
+ begin
19
+ if @categories.empty?
20
+ if @xml_hash.category.class == Array
21
+ @categories = @xml_hash.category.map do |sev|
22
+ SummaryCategory.new(sev)
23
+ end
24
+ else
25
+ @categories << SummaryCategory.new(@xml_hash.category)
26
+ end
27
+ end
28
+ rescue NoMethodError
29
+ end
30
+
31
+ return @categories
32
+ end
33
+ end
34
+
35
+ class SummaryReport < Veracode::Common::Base
36
+ api_field :report_format_version, :tag => :report_format_version
37
+ api_field :app_name, :tag => :app_name
38
+ api_field :app_id, :tag => :app_id
39
+ api_field :first_build_submitted_date, :tag => :first_build_submitted_date
40
+ api_field :version, :tag => :version
41
+ api_field :build_id, :tag => :build_id
42
+ api_field :vendor, :tag => :vendor
43
+ api_field :submitter, :tag => :submitter
44
+ api_field :platform, :tag => :platform
45
+ api_field :assurance_level, :tag => :assurance_level
46
+ api_field :business_criticality, :tag => :business_criticality
47
+ api_field :generation_date, :tag => :generation_date
48
+ api_field :veracode_level, :tag => :veracode_level
49
+ api_field :total_flaws, :tag => :total_flaws
50
+ api_field :flaws_not_mitigated, :tag => :flaws_not_mitigated
51
+ api_field :teams, :tag => :teams
52
+ api_field :life_cycle_stage, :tag => :life_cycle_stage
53
+ api_field :planned_deployment_date, :tag => :planned_deployment_date
54
+ api_field :last_update_time, :tag => :last_update_time
55
+ api_field :policy_name, :tag => :policy_name
56
+ api_field :policy_version, :tag => :policy_version
57
+ api_field :policy_compliance_status, :tag => :policy_compliance_status
58
+ api_field :policy_rules_status, :tag => :policy_rules_status
59
+ api_field :scan_overdue, :tag => :scan_overdue
60
+ api_field :any_type_scan_due, :tag => :any_type_scan_due
61
+ api_field :business_owner, :tag => :business_owner
62
+ api_field :business_unit, :tag => :business_unit
63
+ api_field :tags, :tag => :tags
64
+
65
+ api_type_field :static_analysis, :tag => :static_analysis, :as => Analysis
66
+ api_type_field :dynamic_analysis, :tag => :dynamic_analysis, :as => Analysis
67
+ api_type_field :manual_analysis, :tag => :manual_analysis, :as => ManualAnalysis
68
+ api_type_field :flaw_status, :tag => :flaw_status, :as => FlawStatus
69
+
70
+ def is_latest_build?
71
+ @is_latest_build ||= @xml_hash.is_latest_build.to_bool
72
+ end
73
+
74
+ def grace_period_expired?
75
+ @grace_period_expired ||= @xml_hash.grace_period_expired.to_bool
76
+ end
77
+
78
+ def severity
79
+ @severity ||= []
80
+ if @severity.empty?
81
+ if @xml_hash.severity.class == Array
82
+ @severity = @xml_hash.severity.map do |sev|
83
+ SummarySeverity.new(sev)
84
+ end
85
+ else
86
+ @severity << SummarySeverity.new(@xml_hash.severity)
87
+ end
88
+ end
89
+ return @severity
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,205 @@
1
+
2
+ require 'base64'
3
+
4
+ # Veracode API General Types used by Summary and Detailed results as well as Application Build API
5
+ #
6
+ module Veracode
7
+ module Common
8
+ # Base Class for result
9
+ class Base
10
+
11
+ def self.api_field(name, args)
12
+ send(:define_method, name) do
13
+ begin
14
+ return @xml_hash.send(args[:tag].to_sym)
15
+ rescue NoMethodError
16
+ return nil
17
+ end
18
+ end
19
+ end
20
+
21
+ def self.api_type_field(name, args)
22
+ send(:define_method, name) do
23
+ begin
24
+ tmp = eval("@" + name.to_s)
25
+ tmp ||= args[:as].new(@xml_hash.send(args[:tag].to_sym))
26
+ instance_variable_set("@#{name}", tmp)
27
+ return tmp
28
+ rescue NoMethodError
29
+ return nil
30
+ end
31
+ end
32
+ end
33
+ # Takes Hash of XML stores, hash is has addition to allow dot access to components
34
+ def initialize(xml_hash)
35
+ @xml_hash = xml_hash
36
+ end
37
+ end
38
+ end
39
+
40
+ module Result
41
+ class Screenshot < Veracode::Common::Base
42
+ api_field :format, :tag => :format
43
+
44
+ def data
45
+ @scr_data ||= Base64.decode64(@xml_hash.data)
46
+
47
+ return @scr_data
48
+ end
49
+ #xml_reader(:data) {|b64data| Base64.decode64(b64data) }
50
+ end
51
+
52
+ class BulletType < Veracode::Common::Base
53
+ api_field :text, :tag => :text
54
+ end
55
+
56
+ class ParaType < Veracode::Common::Base
57
+ #xml_reader :bulletitem, :as => [BulletType]
58
+ api_field :text, :tag => :text
59
+
60
+ def bulletitem
61
+ @bulletitems ||= []
62
+ begin
63
+ if @bulletitems.empty?
64
+ if @xml_hash.bulletitem.class == Array
65
+ @bulletitems = @xml_hash.bulletitem.map do |item|
66
+ BulletType.new(item)
67
+ end
68
+ else
69
+ @bulletitems << BulletType.new(@xml_hash.bulletitem)
70
+ end
71
+ end
72
+ rescue NoMethodError
73
+ end
74
+ return @bulletitems
75
+ end
76
+ end
77
+
78
+ class TextType < Veracode::Common::Base
79
+ #xml_reader :text, :from => "text/@text"
80
+ end
81
+
82
+ class Para < Veracode::Common::Base
83
+ #xml_reader :para, :as => [ParaType]
84
+ def para
85
+ @paras ||= []
86
+ if @paras.empty?
87
+ if @xml_hash.para.class == Array
88
+ @paras = @xml_hash.para.map do |para|
89
+ ParaType.new(para)
90
+ end
91
+ else
92
+ @paras << ParaType.new(@xml_hash.para)
93
+ end
94
+ end
95
+ return @paras
96
+ end
97
+ end
98
+
99
+ class AppendixType < Veracode::Common::Base
100
+ api_field :description, :tag => :description
101
+ #xml_reader :screenshot, :as => [Screenshot]
102
+ def screenshot
103
+ @screenshots ||= []
104
+ begin
105
+ if @screenshots.empty?
106
+ if @xml_hash.screenshot.class == Array
107
+ @screenshots = @xml_hash.screenshot.map do |screenshot|
108
+ Screenshot.new(screenshot)
109
+ end
110
+ else
111
+ @screenshots << Screenshot.new(@xml_hash.screenshot)
112
+ end
113
+ end
114
+ rescue NoMethodError
115
+ end
116
+ return @screenshots
117
+ end
118
+ api_field :code, :tag => :code
119
+ end
120
+
121
+ class Module < Veracode::Common::Base
122
+ api_field :name, :tag => :name
123
+ api_field :compiler, :tag => :compiler
124
+ api_field :os, :tag => :os
125
+ api_field :architecture, :tag => :architecture
126
+ api_field :score, :tag => :score
127
+ api_field :numflawssev0, :tag => :numflawssev0
128
+ api_field :numflawssev1, :tag => :numflawssev1
129
+ api_field :numflawssev2, :tag => :numflawssev2
130
+ api_field :numflawssev3, :tag => :numflawssev3
131
+ api_field :numflawssev4, :tag => :numflawssev4
132
+ api_field :numflawssev5, :tag => :numflawssev5
133
+ end
134
+
135
+ class Analysis < Veracode::Common::Base
136
+
137
+ api_field :analysis_size_bytes, :tag => :analysis_size_bytes
138
+ api_field :rating, :tag => :rating
139
+ api_field :score, :tag => :score
140
+ api_field :mitigated_rating, :tag => :mitigated_rating
141
+ api_field :mitigated_score, :tag => :mitigated_score
142
+ api_field :submitted_date, :tag => :submitted_date
143
+ api_field :published_date, :tag => :published_date
144
+ api_field :next_scan_due, :tag => :next_scan_due
145
+
146
+ def modules
147
+ @modules ||= []
148
+ if @modules.empty?
149
+ if @xml_hash.modules.class == Array
150
+ @modules = @xml_hash.modules.map do |modules|
151
+ Module.new(modules.module)
152
+ end
153
+ else
154
+ @modules << Module.new(@xml_hash.modules.module)
155
+ end
156
+ end
157
+ return @modules
158
+ end
159
+ end
160
+
161
+ class ManualAnalysis < Veracode::Common::Base
162
+ api_field :rating, :tag => :rating
163
+ api_field :score, :tag => :score
164
+ api_field :mitigated_rating, :tag => :mitigated_rating
165
+ api_field :mitigated_score, :tag => :mitigated_score
166
+ api_field :submitted_date, :tag => :submitted_date
167
+ api_field :published_date, :tag => :published_date
168
+ api_field :next_scan_due, :tag => :next_scan_due
169
+ api_field :cia_adjustment, :tag => :cia_adjustment
170
+ api_field :delivery_consultant, :tag => :delivery_consultant
171
+
172
+ def modules
173
+ @modules ||= []
174
+ if @modules.empty?
175
+ if @xml_hash.modules.class == Array
176
+ @modules = @xml_hash.modules.map do |modules|
177
+ Module.new(modules.module)
178
+ end
179
+ else
180
+ @modules << Module.new(@xml_hash.modules.module)
181
+ end
182
+ end
183
+ return @modules
184
+ end
185
+ end
186
+
187
+ class FlawStatus < Veracode::Common::Base
188
+ api_field :new_flaws, :tag => :new
189
+ api_field :reopen_flaws, :tag => :reopen
190
+ #api_field :open_flaws, :tag => :open
191
+ api_field :fixed_flaws, :tag => :fixed
192
+ api_field :total_flaws, :tag => :total
193
+ api_field :not_mitigated, :tag => :not_mitigated
194
+ api_field :sev_1_change, :tag => :sev_1_change
195
+ api_field :sev_2_change, :tag => :sev_2_change
196
+ api_field :sev_3_change, :tag => :sev_3_change
197
+ api_field :sev_4_change, :tag => :sev_4_change
198
+ api_field :sev_5_change, :tag => :sev_5_change
199
+
200
+ def open_flaws
201
+ return @xml_hash['open']
202
+ end
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,155 @@
1
+ require 'veracode/api/types'
2
+
3
+ module Veracode
4
+ module Upload
5
+ class AnalysisUnit < Veracode::Common::Base
6
+ api_field :analysis_type, :tag => :analysis_type
7
+ api_field :status, :tag => :status
8
+ api_field :published_date, :tag => :published_date
9
+ end
10
+
11
+ class Build < Veracode::Common::Base
12
+ api_field :version, :tag => :version
13
+ api_field :build_id, :tag => :build_id
14
+ api_field :submitter, :tag => :submitter
15
+ api_field :platform, :tag => :platform
16
+ api_field :lifecycle_stage, :tag => :lifecycle_stage
17
+ api_field :policy_name, :tag => :policy_name
18
+ api_field :policy_version, :tag => :policy_version
19
+ api_field :policy_compliance_status, :tag => :policy_compliance_status
20
+ api_field :rules_status, :tag => :rules_status
21
+
22
+ def grace_period_expired?
23
+ @grace_period_expired ||= @xml_hash.grace_period_expired.to_bool
24
+ end
25
+
26
+ def scan_overdue?
27
+ @scan_overdue ||= @xml_hash.scan_overdue.to_bool
28
+ end
29
+
30
+ def results_ready?
31
+ @results_ready ||= @xml_hash.results_ready.to_bool
32
+ end
33
+
34
+ def analysis_units
35
+ @analysis_units ||= []
36
+ if @analysis_units.empty?
37
+ if @xml_hash.analysis_unit.class == Array
38
+ @analysis_units = @xml_hash.analysis_unit.map do |analysis_unit|
39
+ AnalysisUnit.new(analysis_unit)
40
+ end
41
+ else
42
+ @analysis_units << AnalysisUnit.new(@xml_hash.analysis_unit)
43
+ end
44
+ end
45
+ return @analysis_units
46
+ end
47
+ end
48
+
49
+ class BuildInfo < Veracode::Common::Base
50
+ api_field :build_id, :tag => :build_id
51
+ api_field :app_id, :tag => :app_id
52
+ api_field :account_id, :tag => :account_id
53
+
54
+ api_type_field :build, :tag => :build, :as => Build
55
+ end
56
+
57
+ class BuildList < Veracode::Common::Base
58
+ api_field :app_id, :tag => :app_id
59
+ api_field :account_id, :tag => :account_id
60
+ api_field :app_name, :tag => :app_name
61
+
62
+ def build
63
+ @builds ||= []
64
+ begin
65
+ if @builds.empty?
66
+ if @xml_hash.build.class == Array
67
+ @builds = @xml_hash.build.map do |item|
68
+ Build.new(item)
69
+ end
70
+ else
71
+ @builds << Build.new(@xml_hash.build)
72
+ end
73
+ end
74
+ rescue NoMethodError
75
+ end
76
+ return @builds
77
+ end
78
+ end
79
+
80
+ class Application < Veracode::Common::Base
81
+ api_field :app_id, :tag => :app_id
82
+ api_field :app_name, :tag => :app_name
83
+ api_field :vendor, :tag => :vendor
84
+ api_field :description, :tag => :description
85
+ api_field :business_criticality, :tag => :business_criticality
86
+ api_field :policy, :tag => :policy
87
+ api_field :teams, :tag => :teams
88
+ api_field :origin, :tag => :origin
89
+ api_field :industry_vertical, :tag => :industry_vertical
90
+ api_field :app_type, :tag => :app_type
91
+ api_field :deployment_method, :tag => :deployment_method
92
+ api_field :archer_app_name, :tag => :archer_app_name
93
+ api_field :modified_date, :tag => :modified_date
94
+ api_field :vendor_id, :tag => :vendor_id
95
+ api_field :business_unit, :tag => :business_unit
96
+ api_field :business_owner, :tag => :business_owner
97
+ api_field :business_owner_email, :tag => :business_owner_email
98
+ api_field :tags, :tag => :tags
99
+
100
+ def is_web_application?
101
+ @is_web_application ||= @xml_hash.is_web_application.to_bool
102
+ end
103
+
104
+ def cots?
105
+ @cots ||= @xml_hash.cots.to_bool
106
+ end
107
+ end
108
+
109
+ class ApplicationInfo < Veracode::Common::Base
110
+ def application
111
+ @applications ||= []
112
+ begin
113
+ if @applications.empty?
114
+ if @xml_hash.application.class == Array
115
+ @applications = @xml_hash.application.map do |item|
116
+ Application.new(item)
117
+ end
118
+ else
119
+ @applications << Application.new(@xml_hash.application)
120
+ end
121
+ end
122
+ rescue NoMethodError
123
+ end
124
+ return @applications
125
+ end
126
+ end
127
+
128
+ class App < Veracode::Common::Base
129
+ api_field :app_id, :tag => :app_id
130
+ api_field :app_name, :tag => :app_name
131
+ api_field :vendor_name, :tag => :vendor_name
132
+ end
133
+
134
+ class AppList < Veracode::Common::Base
135
+ api_field :account_id, :tag => :account_id
136
+
137
+ def app
138
+ @applications ||= []
139
+ begin
140
+ if @applications.empty?
141
+ if @xml_hash.app.class == Array
142
+ @applications = @xml_hash.app.map do |item|
143
+ App.new(item)
144
+ end
145
+ else
146
+ @applications << App.new(@xml_hash.app)
147
+ end
148
+ end
149
+ rescue NoMethodError
150
+ end
151
+ return @applications
152
+ end
153
+ end
154
+ end
155
+ end