Skip to content

Commit

Permalink
Merge pull request #3 from aogail/feature/custom_fields
Browse files Browse the repository at this point in the history
Merging PR from @aogail
  • Loading branch information
mort666 authored Jul 12, 2022
2 parents b6d6a6d + cef1959 commit 98424c6
Showing 1 changed file with 38 additions and 25 deletions.
63 changes: 38 additions & 25 deletions lib/veracode/api/builds.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'veracode/api/types'

module Veracode
module Veracode
module Result
module Builds
class AnalysisUnit < Veracode::Common::Base
module Builds
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 < Veracode::Common::Base

class Build < Veracode::Common::Base
api_field :version, :tag => :version
api_field :build_id, :tag => :build_id
api_field :submitter, :tag => :submitter
Expand All @@ -19,19 +19,19 @@ class Build < Veracode::Common::Base
api_field :policy_version, :tag => :policy_version
api_field :policy_compliance_status, :tag => :policy_compliance_status
api_field :rules_status, :tag => :rules_status

def grace_period_expired?
@grace_period_expired ||= @xml_hash.grace_period_expired.to_bool
end

def scan_overdue?
@scan_overdue ||= @xml_hash.scan_overdue.to_bool
end

def results_ready?
@results_ready ||= @xml_hash.results_ready.to_bool
end

def analysis_units
@analysis_units ||= []
if @analysis_units.empty?
Expand All @@ -46,7 +46,12 @@ def analysis_units
return @analysis_units
end
end


class CustomField < Veracode::Common::Base
api_field :name, :tag => :name
api_field :value, :tag => :value
end

class Application < Veracode::Common::Base
api_field :app_name, :tag => :app_name
api_field :app_id, :tag => :app_id
Expand All @@ -59,26 +64,34 @@ class Application < Veracode::Common::Base
api_field :modified_date, :tag => :modified_date
api_field :vendor, :tag => :vendor
api_field :tags, :tag => :tags


def custom_fields
@custom_fields ||=
@xml_hash.customfield.map do |customfield|
CustomField.new(customfield)
end
end

def cots?
@cots ||= @xml_hash.cots.to_bool
end

def builds
@builds ||= []
if @builds.empty?
if @xml_hash.build.class == Array
@builds = @xml_hash.build.map do |build|
Build.new(build)
@builds ||=
if @xml_hash.include?('build')
if @xml_hash.build.class == Array
@builds = @xml_hash.build.map do |build|
Build.new(build)
end
else
@builds = [Build.new(@xml_hash.build)]
end
else
[]
end
else
@builds << Build.new(@xml_hash.build)
end
end
return @builds
end
end
end

class Applications < Veracode::Common::Base
def applications
@applications ||= []
Expand All @@ -89,7 +102,7 @@ def applications
end
end
end

end
end
end

0 comments on commit 98424c6

Please sign in to comment.