Module: VeracodeApiBase
- Included in:
- VeracodeApiResults, VeracodeApiScan
- Defined in:
- lib/veracodecli/api.rb
Instance Method Summary collapse
- #get_repo_archive(url) ⇒ Object
- #parse_new_app_id(response) ⇒ Object
- #response_parse_app_id(response, app_name) ⇒ Object
- #veracode_api_request(api_call, api_version: '4.0', **params) ⇒ Object
Instance Method Details
#get_repo_archive(url) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/veracodecli/api.rb', line 22 def get_repo_archive(url) directory = "/tmp/sast_clone" if Dir.exists?(directory) `cd #{directory}; git pull` else `git clone #{url} #{directory}` end `cd /tmp; zip -r sast_upload.zip sast_clone` end |
#parse_new_app_id(response) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/veracodecli/api.rb', line 43 def parse_new_app_id(response) app_id = nil doc = Nokogiri::XML response doc.remove_namespaces! if doc.xpath('//application').empty? then return nil end doc.xpath('//application').each do |application| app_id = application.attributes['app_id'].value end app_id end |
#response_parse_app_id(response, app_name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/veracodecli/api.rb', line 32 def response_parse_app_id(response, app_name) app_id = nil doc = Nokogiri::XML response doc.remove_namespaces! if doc.xpath('//app').empty? then return nil end doc.xpath('//app').each do |app| if app.attributes['app_name'].value == app_name then app_id = app.attributes['app_id'].value end end app_id end |
#veracode_api_request(api_call, api_version: '4.0', **params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/veracodecli/api.rb', line 10 def veracode_api_request(api_call, api_version: '4.0', **params) begin response = RestClient.get "https://#{Settings.veracode_username}:#{Settings.veracode_password}@analysiscenter.veracode.com/api/#{api_version}/#{api_call}", { params: params } log = ResponseLogger.new "/tmp" log.log api_call, response.code, response.body rescue RestClient abort '401: Unauthorized. Veracode API call Failed, please check your veracode credentials or whitelisted IPs' end if [500,501,502,503].any?{|code| response.code == code} then abort 'Internal server error.' end response end |