-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
187 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require 'veracode/api/types' | ||
|
||
module Veracode | ||
module Result | ||
class Call < Veracode::Common::Base | ||
api_field :data_path, :tag => :data_path | ||
api_field :file_path, :tag => :file_path | ||
api_field :function_name, :tag => :function_name | ||
api_field :line_number, :tag => :line_number | ||
end | ||
|
||
class CallStack < Veracode::Common::Base | ||
api_field :module_name, :tag => :module_name | ||
api_field :steps, :tag => :steps | ||
api_field :local_path, :tag => :local_path | ||
api_field :function_name, :tag => :function_name | ||
api_field :line_number, :tag => :line_number | ||
|
||
def calls | ||
@calls ||= [] | ||
begin | ||
if @calls.empty? | ||
if @xml_hash.call.class == Array | ||
@calls = @xml_hash.call.map do |item| | ||
Call.new(item) | ||
end | ||
else | ||
@calls << Call.new(@xml_hash.call) | ||
end | ||
end | ||
rescue NoMethodError | ||
end | ||
return @calls | ||
end | ||
end | ||
|
||
class CallStacks < Veracode::Common::Base | ||
api_field :build_id, :tag => :build_id | ||
api_field :flaw_id, :tag => :flaw_id | ||
|
||
def callstack | ||
@callstacks ||= [] | ||
begin | ||
if @callstacks.empty? | ||
if @xml_hash.callstack.class == Array | ||
@callstacks = @xml_hash.callstack.map do |item| | ||
CallStack.new(item) | ||
end | ||
else | ||
@callstacks << CallStack.new(@xml_hash.callstack) | ||
end | ||
end | ||
rescue NoMethodError | ||
end | ||
return @callstacks | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Veracode | ||
module API | ||
VERSION = "0.3.1" | ||
VERSION = "0.4.1" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require (File.expand_path('./../../../spec_helper', __FILE__)) | ||
|
||
describe Veracode::API::Results do | ||
describe "GET Call Stack" do | ||
|
||
let(:veracode) { Veracode::API::Results.new(:username => "test", :password => "test") } | ||
|
||
before do | ||
VCR.insert_cassette 'base', :record => :new_episodes | ||
end | ||
|
||
after do | ||
VCR.eject_cassette | ||
end | ||
|
||
it "must have a get_callstacks method" do | ||
veracode.must_respond_to :get_callstacks | ||
end | ||
|
||
it "must parse the api response from XML to Veracode::Result::CallStacks" do | ||
veracode.get_callstacks("44905", "132").must_be_instance_of Veracode::Result::CallStacks | ||
end | ||
end | ||
end |