From 4d40d6258ce081e78282cc175c7ce962bfa6a17c Mon Sep 17 00:00:00 2001 From: Ben Jansen Date: Mon, 25 Nov 2019 14:55:23 -0800 Subject: [PATCH 1/3] Add accessor for custom fields in applications --- lib/veracode/api/builds.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/veracode/api/builds.rb b/lib/veracode/api/builds.rb index 01250cd..2254549 100644 --- a/lib/veracode/api/builds.rb +++ b/lib/veracode/api/builds.rb @@ -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 @@ -59,7 +64,14 @@ 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 From ed30a3118da722e8d89197d266b8fea584756205 Mon Sep 17 00:00:00 2001 From: Ben Jansen Date: Mon, 25 Nov 2019 14:56:36 -0800 Subject: [PATCH 2/3] Fix builds() in the case where the application has no build field --- lib/veracode/api/builds.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/veracode/api/builds.rb b/lib/veracode/api/builds.rb index 2254549..af956a1 100644 --- a/lib/veracode/api/builds.rb +++ b/lib/veracode/api/builds.rb @@ -77,18 +77,19 @@ def cots? 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 From cef1959358a1984275ea38f01cf9b468c32d343d Mon Sep 17 00:00:00 2001 From: Ben Jansen Date: Mon, 25 Nov 2019 14:56:56 -0800 Subject: [PATCH 3/3] Remove trailing whitespace --- lib/veracode/api/builds.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/veracode/api/builds.rb b/lib/veracode/api/builds.rb index af956a1..5fc2ef8 100644 --- a/lib/veracode/api/builds.rb +++ b/lib/veracode/api/builds.rb @@ -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 @@ -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? @@ -75,7 +75,7 @@ def custom_fields def cots? @cots ||= @xml_hash.cots.to_bool end - + def builds @builds ||= if @xml_hash.include?('build') @@ -91,7 +91,7 @@ def builds end end end - + class Applications < Veracode::Common::Base def applications @applications ||= [] @@ -102,7 +102,7 @@ def applications end end end - + end end end