Module: VeracodeApiBase
- Included in:
- VeracodeApiResults, VeracodeApiScan
- Defined in:
- lib/veracodecli/api.rb
Instance Method Summary collapse
- #check_environment_login_variables ⇒ Object
- #veracode_api_request(api_call, api_version: '4.0', **params) ⇒ Object
- #write(data, to_file:) ⇒ Object
- #xml_to_json(string) ⇒ Object
Instance Method Details
#check_environment_login_variables ⇒ Object
6 7 8 |
# File 'lib/veracodecli/api.rb', line 6 def check_environment_login_variables fail 'EnvironmentError: VERACODE_USERNAME, VERACODE_PASSWORD, or VERACODE_TEAM not set.' unless !ENV['VERACODE_USERNAME'].nil? || !ENV['VERACODE_PASSWORD'].nil? || !ENV['VERACODE_TEAM'].nil? end |
#veracode_api_request(api_call, api_version: '4.0', **params) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/veracodecli/api.rb', line 10 def veracode_api_request(api_call, api_version: '4.0', **params) check_environment_login_variables # puts "Making call to #{api_call}" response = RestClient.get "https://#{ENV['VERACODE_USERNAME']}:#{ENV['VERACODE_PASSWORD']}@analysiscenter.veracode.com/api/#{api_version}/#{api_call}", { params: params } response.body end |
#write(data, to_file:) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/veracodecli/api.rb', line 22 def write(data, to_file:) data = xml_to_json data f = File.open "../testdata/#{to_file}.json", 'w' f.write JSON.pretty_generate data f.close end |
#xml_to_json(string) ⇒ Object
17 18 19 20 |
# File 'lib/veracodecli/api.rb', line 17 def xml_to_json(string) json = Hash.from_xml(string).to_json JSON.parse json end |