veracode-api 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+
6
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :test do
4
+ gem 'webmock'
5
+ gem 'vcr'
6
+ gem 'turn'
7
+ gem 'minitest'
8
+ gem 'rake'
9
+ end
10
+
11
+ # Specify your gem's dependencies in veracode.gemspec
12
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012 Stephen Kapp
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,36 @@
1
+ Veracode API Gem
2
+ ================
3
+
4
+ Ruby Wrapper for the Veracode API
5
+
6
+ About
7
+ -----
8
+
9
+ This Gem puts a wrapper around the Veracode API to allow access to API functionality to view reports, perform uploads and administer accounts.
10
+
11
+ How to use it
12
+ -------------
13
+
14
+ Install with Rubygems
15
+
16
+ gem install veracode-api
17
+
18
+ If you use bundler, add it to your 'Gemfile'
19
+
20
+ gem 'veracode-api'
21
+
22
+ TODO
23
+ ----
24
+
25
+ * Better Documentation
26
+ * Upload Functionality
27
+ * User Admin Functionality
28
+
29
+ Issues
30
+ ------
31
+
32
+ Found an issue, please report it on Github
33
+
34
+ https://github.com/mort666/veracode-api
35
+
36
+ Copyright (c) 2012 Stephen Kapp, released under the Apache License, Version 2.0
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.test_files = FileList['spec/lib/veracode/*_spec.rb']
6
+ t.verbose = true
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ require "httparty"
2
+
3
+ require "veracode/version"
4
+ require "veracode/config"
5
+ require "veracode/base"
6
+ require "veracode/upload"
7
+ require "veracode/admin"
8
+ require "veracode/results"
9
+
10
+ module Veracode
11
+ module API
12
+ extend Veracode::API::Config
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ module Veracode
2
+ module API
3
+ class Admin < Veracode::API::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,95 @@
1
+ require 'veracode/api/types'
2
+
3
+ module Veracode
4
+ module Result
5
+ module Builds
6
+ class AnalysisUnit < Veracode::Common::Base
7
+ api_field :analysis_type, :tag => :analysis_type
8
+ api_field :status, :tag => :status
9
+ api_field :published_date, :tag => :published_date
10
+ end
11
+
12
+ class Build < Veracode::Common::Base
13
+ api_field :version, :tag => :version
14
+ api_field :build_id, :tag => :build_id
15
+ api_field :submitter, :tag => :submitter
16
+ api_field :platform, :tag => :platform
17
+ api_field :lifecycle_stage, :tag => :lifecycle_stage
18
+ api_field :policy_name, :tag => :policy_name
19
+ api_field :policy_version, :tag => :policy_version
20
+ api_field :policy_compliance_status, :tag => :policy_compliance_status
21
+ api_field :rules_status, :tag => :rules_status
22
+
23
+ def grace_period_expired?
24
+ @grace_period_expired ||= @xml_hash.grace_period_expired.to_bool
25
+ end
26
+
27
+ def scan_overdue?
28
+ @scan_overdue ||= @xml_hash.scan_overdue.to_bool
29
+ end
30
+
31
+ def results_ready?
32
+ @results_ready ||= @xml_hash.results_ready.to_bool
33
+ end
34
+
35
+ def analysis_units
36
+ @analysis_units ||= []
37
+ if @analysis_units.empty?
38
+ if @xml_hash.analysis_unit.class == Array
39
+ @analysis_units = @xml_hash.analysis_unit.map do |analysis_unit|
40
+ AnalysisUnit.new(analysis_unit)
41
+ end
42
+ else
43
+ @analysis_units << AnalysisUnit.new(@xml_hash.analysis_unit)
44
+ end
45
+ end
46
+ return @analysis_units
47
+ end
48
+ end
49
+
50
+ class Application < Veracode::Common::Base
51
+ api_field :app_name, :tag => :app_name
52
+ api_field :app_id, :tag => :app_id
53
+ api_field :industry_vertical, :tag => :industry_vertical
54
+ api_field :assurance_level, :tag => :assurance_level
55
+ api_field :business_criticality, :tag => :business_criticality
56
+ api_field :origin, :tag => :origin
57
+ api_field :business_unit, :tag => :business_unit
58
+ api_field :business_owner, :tag => :business_owner
59
+ api_field :modified_date, :tag => :modified_date
60
+ api_field :vendor, :tag => :vendor
61
+ api_field :tags, :tag => :tags
62
+
63
+ def cots?
64
+ @cots ||= @xml_hash.cots.to_bool
65
+ end
66
+
67
+ def builds
68
+ @builds ||= []
69
+ if @builds.empty?
70
+ if @xml_hash.build.class == Array
71
+ @builds = @xml_hash.build.map do |build|
72
+ Build.new(build)
73
+ end
74
+ else
75
+ @builds << Build.new(@xml_hash.build)
76
+ end
77
+ end
78
+ return @builds
79
+ end
80
+ end
81
+
82
+ class Applications < Veracode::Common::Base
83
+ def applications
84
+ @applications ||= []
85
+ if @applications.empty?
86
+ @applications = @xml_hash.applicationbuilds.application.map do |application|
87
+ Application.new(application)
88
+ end
89
+ end
90
+ end
91
+ end
92
+
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,59 @@
1
+ require 'veracode/api/types'
2
+
3
+ module Veracode
4
+ module Result
5
+ class Call < Veracode::Common::Base
6
+ api_field :data_path, :tag => :data_path
7
+ api_field :file_path, :tag => :file_path
8
+ api_field :function_name, :tag => :function_name
9
+ api_field :line_number, :tag => :line_number
10
+ end
11
+
12
+ class CallStack < Veracode::Common::Base
13
+ api_field :module_name, :tag => :module_name
14
+ api_field :steps, :tag => :steps
15
+ api_field :local_path, :tag => :local_path
16
+ api_field :function_name, :tag => :function_name
17
+ api_field :line_number, :tag => :line_number
18
+
19
+ def calls
20
+ @calls ||= []
21
+ begin
22
+ if @calls.empty?
23
+ if @xml_hash.call.class == Array
24
+ @calls = @xml_hash.call.map do |item|
25
+ Call.new(item)
26
+ end
27
+ else
28
+ @calls << Call.new(@xml_hash.call)
29
+ end
30
+ end
31
+ rescue NoMethodError
32
+ end
33
+ return @calls
34
+ end
35
+ end
36
+
37
+ class CallStacks < Veracode::Common::Base
38
+ api_field :build_id, :tag => :build_id
39
+ api_field :flaw_id, :tag => :flaw_id
40
+
41
+ def callstack
42
+ @callstacks ||= []
43
+ begin
44
+ if @callstacks.empty?
45
+ if @xml_hash.callstack.class == Array
46
+ @callstacks = @xml_hash.callstack.map do |item|
47
+ CallStack.new(item)
48
+ end
49
+ else
50
+ @callstacks << CallStack.new(@xml_hash.callstack)
51
+ end
52
+ end
53
+ rescue NoMethodError
54
+ end
55
+ return @callstacks
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,169 @@
1
+ require 'veracode/api/types'
2
+ require 'veracode/api/flaws'
3
+
4
+ module Veracode
5
+ module Result
6
+ class CWE < Veracode::Common::Base
7
+ api_field :cweid, :tag => :cweid
8
+ api_field :cwename, :tag => :cwename
9
+
10
+ def pcirelated?
11
+ @pcirelated ||= @xml_hash.pcirelated.to_bool
12
+ end
13
+
14
+ def description
15
+ @xml_hash.description.text.text
16
+ end
17
+
18
+ api_type_field :manualflaws, :tag => :manualflaws, :as => Flaws
19
+ api_type_field :dynamicflaws, :tag => :dynamicflaws, :as => Flaws
20
+ api_type_field :staticflaws, :tag => :staticflaws, :as => Flaws
21
+
22
+ end
23
+
24
+ class Category < Veracode::Common::Base
25
+ api_field :categoryid, :tag => :categoryid
26
+ api_field :categoryname, :tag => :categoryname
27
+ api_type_field :desc, :tag => :desc, :as => Para
28
+ api_type_field :recommendations, :tag => :recommendations, :as => Para
29
+
30
+ def pcirelated?
31
+ @pcirelated ||= @xml_hash.pcirelated.to_bool
32
+ end
33
+
34
+ def description
35
+ temp = self.desc.para.map do |para|
36
+ para.text
37
+ end
38
+
39
+ self.desc.para.map do |para|
40
+ if !para.bulletitem.nil?
41
+ x = para.bulletitem.each.map do |item|
42
+ "* " + item.text + "\r\n"
43
+ end
44
+ end
45
+ temp << x.join
46
+ end
47
+
48
+ return temp.join("\r\n\r\n").strip
49
+ end
50
+
51
+ def recommendation
52
+ temp = self.recommendations.para.map do |para|
53
+ para.text
54
+ end
55
+
56
+ self.recommendations.para.map do |para|
57
+ if !para.bulletitem.nil?
58
+ x = para.bulletitem.each.map do |item|
59
+ "* " + item.text + "\r\n"
60
+ end
61
+ end
62
+ temp << x.join
63
+ end
64
+
65
+ return temp.join("\r\n\r\n").strip
66
+ end
67
+
68
+ def cwe
69
+ @cwe ||= []
70
+ begin
71
+ if @cwe.empty?
72
+ if @xml_hash.cwe.class == Array
73
+ @cwe = @xml_hash.cwe.map do |c|
74
+ CWE.new(c)
75
+ end
76
+ else
77
+ @cwe << CWE.new(@xml_hash.cwe)
78
+ end
79
+ end
80
+ rescue NoMethodError
81
+ end
82
+
83
+ return @cwe
84
+ end
85
+ end
86
+
87
+ class Severity < Veracode::Common::Base
88
+ api_field :level, :tag => :level
89
+
90
+ def categories
91
+ @categories ||= []
92
+ begin
93
+ if @categories.empty?
94
+ if @xml_hash.category.class == Array
95
+ @categories = @xml_hash.category.map do |sev|
96
+ Category.new(sev)
97
+ end
98
+ else
99
+ @categories << Category.new(@xml_hash.category)
100
+ end
101
+ end
102
+ rescue NoMethodError
103
+ end
104
+
105
+ return @categories
106
+ end
107
+ end
108
+
109
+ class DetailedReport < Veracode::Common::Base
110
+
111
+ api_field :report_format_version, :tag => :report_format_version
112
+ api_field :app_name, :tag => :app_name
113
+ api_field :app_id, :tag => :app_id
114
+ api_field :first_build_submitted_date, :tag => :first_build_submitted_date
115
+ api_field :version, :tag => :version
116
+ api_field :build_id, :tag => :build_id
117
+ api_field :submitter, :tag => :submitter
118
+ api_field :vendor, :tag => :vendor
119
+ api_field :platform, :tag => :platform
120
+ api_field :assurance_level, :tag => :assurance_level
121
+ api_field :business_criticality, :tag => :business_criticality
122
+ api_field :generation_date, :tag => :generation_date
123
+ api_field :veracode_level, :tag => :veracode_level
124
+ api_field :total_flaws, :tag => :total_flaws
125
+ api_field :flaws_not_mitigated, :tag => :flaws_not_mitigated
126
+ api_field :teams, :tag => :teams
127
+ api_field :life_cycle_stage, :tag => :life_cycle_stage
128
+ api_field :planned_deployment_date, :tag => :planned_deployment_date
129
+ api_field :last_update_time, :tag => :last_update_time
130
+ api_field :policy_name, :tag => :policy_name
131
+ api_field :policy_version, :tag => :policy_version
132
+ api_field :policy_compliance_status, :tag => :policy_compliance_status
133
+ api_field :policy_rules_status, :tag => :policy_rules_status
134
+ api_field :scan_overdue, :tag => :scan_overdue
135
+ api_field :any_type_scan_due, :tag => :any_type_scan_due
136
+ api_field :business_owner, :tag => :business_owner
137
+ api_field :business_unit, :tag => :business_unit
138
+ api_field :tags, :tag => :tags
139
+
140
+ api_type_field :static_analysis, :tag => :static_analysis, :as => Analysis
141
+ api_type_field :dynamic_analysis, :tag => :dynamic_analysis, :as => Analysis
142
+ api_type_field :manual_analysis, :tag => :manual_analysis, :as => ManualAnalysis
143
+ api_type_field :flaw_status, :tag => :flaw_status, :as => FlawStatus
144
+
145
+ def is_latest_build?
146
+ @is_latest_build ||= @xml_hash.is_latest_build.to_bool
147
+ end
148
+
149
+ def grace_period_expired?
150
+ @grace_period_expired ||= @xml_hash.grace_period_expired.to_bool
151
+ end
152
+
153
+ def severity
154
+ @severity ||= []
155
+ if @severity.empty?
156
+ if @xml_hash.severity.class == Array
157
+ @severity = @xml_hash.severity.map do |sev|
158
+ Severity.new(sev)
159
+ end
160
+ else
161
+ @severity << Severity.new(@xml_hash.severity)
162
+ end
163
+ end
164
+ return @severity
165
+ end
166
+ end
167
+
168
+ end
169
+ end
@@ -0,0 +1,154 @@
1
+ require 'veracode/api/types'
2
+
3
+ module Veracode
4
+ module Result
5
+ class AnnotationType < Veracode::Common::Base
6
+ api_field :action, :tag => :action
7
+ api_field :description, :tag => :description
8
+ api_field :user, :tag => :user
9
+ api_field :date, :tag => :date
10
+ end
11
+
12
+ class Annotations < Veracode::Common::Base
13
+ def annotation
14
+ @annotations ||= []
15
+ begin
16
+ if @annotations.empty?
17
+ if @xml_hash.annotation.class == Array
18
+ @annotations = @xml_hash.annotation.map do |annotation|
19
+ AnnotationType.new(annotation)
20
+ end
21
+ else
22
+ @annotations << AnnotationType.new(@xml_hash.annotation)
23
+ end
24
+ end
25
+ rescue NoMethodError
26
+ end
27
+
28
+ return @annotations
29
+ end
30
+ end
31
+
32
+ class MitigationType < Veracode::Common::Base
33
+ api_field :action, :tag => :action
34
+ api_field :description, :tag => :description
35
+ api_field :user, :tag => :user
36
+ api_field :date, :tag => :date
37
+ end
38
+
39
+ class Mitigations < Veracode::Common::Base
40
+ def mitigation
41
+ @mitigations ||= []
42
+ begin
43
+ if @mitigations.empty?
44
+ if @xml_hash.mitigation.class == Array
45
+ @mitigations = @xml_hash.mitigation.map do |mitigation|
46
+ MitigationType.new(mitigation)
47
+ end
48
+ else
49
+ @mitigations << MitigationType.new(@xml_hash.mitigation)
50
+ end
51
+ end
52
+ rescue NoMethodError
53
+ end
54
+
55
+ return @mitigations
56
+ end
57
+ end
58
+
59
+ class ExploitabilityAdjustment < Veracode::Common::Base
60
+ api_field :note, :tag => :note
61
+ api_field :score_adjustment, :tag => :score_adjustment
62
+ end
63
+
64
+ class ExploitAdjustment < Veracode::Common::Base
65
+ def exploitability_adjustment
66
+ @exploitability_adjustments ||= []
67
+ begin
68
+ if @exploitability_adjustments.empty?
69
+ if @xml_hash.exploitability_adjustment.class == Array
70
+ @exploitability_adjustments = @xml_hash.exploitability_adjustment.map do |exploitability_adjustment|
71
+ ExploitabilityAdjustment.new(exploitability_adjustment)
72
+ end
73
+ else
74
+ @exploitability_adjustments << ExploitabilityAdjustment.new(@xml_hash.exploitability_adjustment)
75
+ end
76
+ end
77
+ rescue NoMethodError
78
+ end
79
+
80
+ return @exploitability_adjustments
81
+ end
82
+ end
83
+
84
+ class Flaw < Veracode::Common::Base
85
+ api_field :severity, :tag => :severity
86
+ api_field :categoryname, :tag => :categoryname
87
+ api_field :count, :tag => :count
88
+ api_field :issueid, :tag => :issueid
89
+ api_field :module, :tag => :module
90
+ api_field :type, :tag => :type
91
+ api_field :description, :tag => :description
92
+ api_field :note, :tag => :note
93
+ api_field :cweid, :tag => :cweid
94
+ api_field :remediationeffort, :tag => :remediationeffort
95
+ api_field :exploitlevel, :tag => :exploitLevel
96
+ api_field :categoryid, :tag => :categoryid
97
+ api_field :date_first_occurrence, :tag => :date_first_occurrence
98
+ api_field :remediation_status, :tag => :remediation_status
99
+ api_field :sourcefile, :tag => :sourcefile
100
+ api_field :line, :tag => :line
101
+ api_field :sourcefilepath, :tag => :sourcefilepath
102
+ api_field :scope, :tag => :scope
103
+ api_field :functionprototype, :tag => :functionprototype
104
+ api_field :functionrelativelocation, :tag => :functionrelativelocation
105
+ api_field :url, :tag => :url
106
+ api_field :vuln_parameter, :tag => :vuln_parameter
107
+ api_field :location, :tag => :location
108
+ api_field :cvss, :tag => :cvss
109
+ api_field :capecid, :tag => :capecid
110
+ api_field :exploitdifficulty, :tag => :exploitdifficulty
111
+ api_field :inputvector, :tag => :inputvector
112
+ api_field :cia_impact, :tag => :cia_impact
113
+ api_field :grace_period_expires, :tag => :grace_period_expires
114
+
115
+ def pcirelated?
116
+ @pcirelated ||= @xml_hash.pcirelated.to_bool
117
+ end
118
+
119
+ def affects_policy_compliance?
120
+ @affects_policy_compliance ||= @xml_hash.affects_policy_compliance.to_bool
121
+ end
122
+
123
+ api_field :exploit_desc, :tag => :exploit_desc
124
+ api_field :severity_desc, :tag => :severity_desc
125
+ api_field :remediation_desc, :tag => :remediation_desc
126
+
127
+ api_type_field :exploitability_adjustments, :tag => :exploitability_adjustments, :as => ExploitAdjustment
128
+ api_type_field :appendix, :tag => :appendix, :as => AppendixType
129
+ api_type_field :mitigations, :tag => :mitigations, :as => Mitigations
130
+ api_type_field :annotations, :tag => :annotations, :as => Annotations
131
+ end
132
+
133
+ class Flaws < Veracode::Common::Base
134
+ def flaws
135
+ @flaws ||= []
136
+ begin
137
+ if @flaws.empty?
138
+ if @xml_hash.flaw.class == Array
139
+ @flaws = @xml_hash.flaw.map do |flaw|
140
+ Flaw.new(flaw)
141
+ end
142
+ else
143
+ @flaws << Flaw.new(@xml_hash.flaw)
144
+ end
145
+ end
146
+ rescue NoMethodError
147
+ end
148
+
149
+ return @flaws
150
+ end
151
+ end
152
+ end
153
+ end
154
+