diff --git a/lib/veracode/admin.rb b/lib/veracode/admin.rb index e9bcd26..28cd645 100644 --- a/lib/veracode/admin.rb +++ b/lib/veracode/admin.rb @@ -1,4 +1,4 @@ module Veracode - class Admin + class Admin < Veracode::Base end end \ No newline at end of file diff --git a/lib/veracode/base.rb b/lib/veracode/base.rb index c155e56..3af13d0 100644 --- a/lib/veracode/base.rb +++ b/lib/veracode/base.rb @@ -1,7 +1,11 @@ +require 'xmlsimple' + module Veracode class Base attr_accessor *Config::VALID_OPTIONS_KEYS + attr_accessor :account_id + include HTTParty base_uri 'https://analysiscenter.veracode.com' @@ -13,6 +17,15 @@ def initialize(options={}) end end + def account_id + if @account_id.nil? + xml = getXML("/api/4.0/getapplist.do") + @account_id ||= XmlSimple.xml_in(xml.body)['account_id'] + else + @account_id + end + end + def getXML(path, debug=false) auth = { :username => @username, :password => @password } diff --git a/lib/veracode/upload.rb b/lib/veracode/upload.rb index 74ed437..b743330 100644 --- a/lib/veracode/upload.rb +++ b/lib/veracode/upload.rb @@ -1,4 +1,29 @@ module Veracode - class Upload + class Upload < Veracode::Base + CREATE_APP_URI = "/api/4.0/createapp.do" + DELETE_APP_URI = "/api/4.0/deleteapp.do" + GET_VENDOR_LIST_URI = "/api/4.0/getvendorlist.do" + CREATE_BUILD_URI = "/api/4.0/createbuild.do" + DELETE_BUILD_URI = "/api/4.0/deletebuild.do" + UPLOAD_FILE_URI = "/api/4.0/uploadfile.do" + REMOVE_FILE_URI = "/api/4.0/removefile.do" + GET_FILE_LIST_URI = "/api/4.0/getfilelist.do" + GET_APP_LIST_URI = "/api/4.0/getapplist.do" + GET_APP_INFO_URI = "/api/4.0/getappinfo.do" + GET_BUILD_LIST_URI = "/api/4.0/getbuildlist.do" + GET_BUILD_INFO_URI = "/api/4.0/getbuildinfo.do" + BEGIN_PRESCAN_URI = "/api/4.0/beginprescan.do" + GET_PRESCAN_RESULTS_URI = "/api/4.0/getprescanresults.do" + BEGIN_SCAN_URI = "/api/4.0/beginscan.do" + + def get_application_list + xml = getXML(GET_APP_LIST_URI) + case xml.code + when 200 + xml.body + else + xml.error! + end + end end end \ No newline at end of file diff --git a/veracode.gemspec b/veracode.gemspec index 7f35ca0..aa37de9 100644 --- a/veracode.gemspec +++ b/veracode.gemspec @@ -3,27 +3,24 @@ $:.push File.expand_path("../lib", __FILE__) require "veracode/version" Gem::Specification.new do |s| - s.name = "veracode" + s.name = "veracode-api" s.version = Veracode::VERSION s.authors = ["Stephen Kapp"] s.email = ["mort666@virus.org"] s.homepage = "" - s.summary = %q{TODO: Write a gem summary} - s.description = %q{TODO: Write a gem description} + s.summary = %q{Veracode Analysis Service API Wrapper} + s.description = %q{Ruby API Wrapper to access Veracode Security Analysis Service API} - s.rubyforge_project = "veracode" + s.rubyforge_project = "veracode-api" s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - - # specify any dependencies here; for example: - # s.add_development_dependency "rspec" - # s.add_runtime_dependency "rest-client" s.add_dependency "httparty" s.add_dependency "nokogiri" + s.add_dependency "xml-simple" s.add_dependency "roxml" s.add_dependency "i18n"