Skip to content

Commit

Permalink
Mitigation
Browse files Browse the repository at this point in the history
  • Loading branch information
mort666 committed Aug 19, 2014
1 parent ca2697b commit a9c1755
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/veracode/api/mitigation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'veracode/api/types'

module Veracode
module Result
class MitigiationInfo < Veracode::Common::Base

end
end
end
8 changes: 8 additions & 0 deletions lib/veracode/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def account_id
end
end

def postAPI(path, query={}, debug=false)
auth = { :username => @username, :password => @password }

options = { :query => query, :basic_auth => auth }

self.class.post(path, options)
end

def getXML(path, debug=false)
auth = { :username => @username, :password => @password }

Expand Down
58 changes: 58 additions & 0 deletions lib/veracode/mitigation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
require 'nokogiri'
require 'veracode/parser/parser'
require 'veracode/api/mitigation'

module Veracode
module API
class Mitigiation < Veracode::API::Base
GET_MITIGATION_INFO_URI = "/api/getmitigationinfo.do"
UPDATE_MITIGATION_INFO_URI = "/api/updatemitigationinfo.do"

ACTIONS = ["comment", "fp", "appdesign", "osenv", "netenv", "rejected", "accepted"]

def update_mitigation(build_id, comment, action="comment", flaw_list=[])
if flaw_list.class? == Array
flaw_id_list = flaw_list.join(",")
else
flaw_id_list = flaw_list.to_s
end

if ACTIONS.include?(action)
query = { :build_id => build_id, :flaw_id_list => flaw_id_list, :action => action, :comment => comment }

xml = postAPI(UPDATE_MITIGATION_INFO_URI, query)
case xml.code
when 200
clean_xml = xml.body.strip
parsed = Veracode::Parser.parse(clean_xml)
mitigationinfo = Veracode::Result::MitigationInfo.new(parsed)
else
xml.error!
end
else
ArgumentError.new("invalid value for action: \"#{self}\"")
end
end

def get_mitigation(build_id, flaw_list=[])
if flaw_list.class? == Array
flaw_id_list = flaw_list.join(",")
else
flaw_id_list = flaw_list.to_s
end

query = { :build_id => build_id, :flaw_id_list => flaw_id_list }

xml = postAPI(GET_MITIGATION_INFO_URI, query)
case xml.code
when 200
clean_xml = xml.body.strip
parsed = Veracode::Parser.parse(clean_xml)
mitigationinfo = Veracode::Result::MitigationInfo.new(parsed)
else
xml.error!
end
end
end
end
end
Empty file.

0 comments on commit a9c1755

Please sign in to comment.