veracodecli 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38a85c2a0d02935e016488510c19cfe2d3d34fcc
4
- data.tar.gz: e46ceafd154bfb498b2f20dcb0c629ffb77f811b
3
+ metadata.gz: 827da5c760675286fc6a2401713dbd844237d54d
4
+ data.tar.gz: e231f9e7dc2f4f7d034314ead5edba8e50d2b860
5
5
  SHA512:
6
- metadata.gz: 2f6b49907d5d2920f734c8dcf1c34dab1332ef24a4c578377152f1fa7011bc1456419cd00052839acd13646c8711b99ad6b26552f573659a7269219dab264c86
7
- data.tar.gz: 7164c3bea8001f0c235c5cb852c9c488248c47868f6e55241af8314132de12e9a5f0db015038bc896093e95adff7309b1c05dc816313cf8396acf9c5d5ddefbe
6
+ metadata.gz: d42ba6d8ecd48ec4303bb8191f02b5ad65ee5ec90993d2285809ae13fb0a33f76367ad1a42a7f47990bb6f97b2867211d8409df8c003d5f755ec9bab57016f79
7
+ data.tar.gz: ca77d8f24973a65401fb23ac514980eb43ec1dd34fc4f5d159f4e56bf4c62f371d928665ef7d3458b42e49c67907fffa8fc265d3081fcc7c46bc8c20f9870308
@@ -10,7 +10,6 @@ module VeracodeApiBase
10
10
  def veracode_api_request(api_call, api_version: '4.0', **params)
11
11
  check_environment_login_variables
12
12
  response = RestClient.get "https://#{ENV['VERACODE_USERNAME']}:#{ENV['VERACODE_PASSWORD']}@analysiscenter.veracode.com/api/#{api_version}/#{api_call}", { params: params }
13
- response.body
14
13
  end
15
14
  end
16
15
 
@@ -21,11 +20,12 @@ module VeracodeApiScan
21
20
  app_list = veracode_api_request 'getapplist.do', include_user_info: 'true'
22
21
  scan = app_list.scan(/app_id=\"(.+)\" app_name=\"#{app_name}\"/)
23
22
  if !scan.nil? then app_id = scan[0][0] else app_id = nil end
23
+ app_id
24
24
  end
25
25
 
26
26
  def create_app_profile(app_name, business_criticality, business_unit, teams)
27
27
  create_app_response = veracode_api_request 'createapp.do', app_name: app_name, business_criticality: business_criticality, business_unit: business_unit, teams: teams
28
- app_id = create_app_response.scan(/app_id=\"(.+)\" app_name=\"#{of}\"/)[0][0]
28
+ app_id = create_app_response.body.scan(/app_id=\"(.+)\" app_name=\"#{app_name}\"/)[0][0]
29
29
  end
30
30
 
31
31
  def upload_file(app_id, archive_path)
@@ -44,24 +44,27 @@ module VeracodeApiResults
44
44
 
45
45
  def get_most_recent_build_id(app_id)
46
46
  build_list = veracode_api_request 'getbuildlist.do', app_id: app_id
47
- build_list.scan(/build_id="(.*?)"/).last[0]
47
+ build_list.body.scan(/build_id="(.*?)"/).last[0]
48
48
  end
49
49
 
50
50
  def get_build_status(app_id)
51
51
  build_info = veracode_api_request 'getbuildinfo.do', app_id: app_id
52
- build_id = build_info.scan(/build_id="(.*?)"/)[0][0]
53
- build_status = build_info.scan(/status="(.*?)"/).last[0]
52
+ build_id = build_info.body.scan(/build_id="(.*?)"/)[0][0]
53
+ build_status = build_info.body.scan(/status="(.*?)"/).last[0]
54
54
  puts build_status
55
+ build_status
55
56
  end
56
57
 
57
58
  def get_prescan_results(app_id)
58
59
  results = veracode_api_request 'getprescanresults.do', app_id: app_id
59
60
  puts "Fetched prescan results for #{app_id}"
60
- puts results
61
+ puts results.body
62
+ results
61
63
  end
62
64
 
63
- def get_scan_report(app_id)
65
+ def get_scan_report(build_id)
64
66
  report = veracode_api_request 'detailedreport.do', api_version: '3.0', build_id: build_id
67
+ report = report.body
65
68
  end
66
69
  end
67
70
 
@@ -2,19 +2,46 @@ require 'test/unit'
2
2
  require 'shoulda/context'
3
3
  require_relative '../lib/veracodecli/api'
4
4
  include VeracodeApiScan
5
+ include VeracodeApiResults
5
6
 
6
7
  class TestVeracodecli < Test::Unit::TestCase
7
8
  context 'VeracodeApi' do
8
9
 
9
10
  setup do
10
- ENV['VERACODE_USERNAME'] = 'foo'
11
- ENV['VERACODE_PASSWORD'] = 'bar'
12
- ENV['VERACODE_TEAM'] = 'foobar'
11
+ ENV['VERACODE_USERNAME'] = 'telusdigitalapi'
12
+ ENV['VERACODE_PASSWORD'] = 'OSJ939q4'
13
13
  end
14
14
 
15
- should 'Return HTTP 401' do
16
- assert_kind_of String, veracode_api_request('getapplist.do')
15
+ should 'Return existing application profile ID' do
16
+ assert_equal '12379', get_app_id('Test1')
17
17
  end
18
18
 
19
+ should 'Return HTTP 200 for createapp.do' do
20
+ assert_equal 200, veracode_api_request('createapp.do', app_name: 'Test1', business_criticality: 'Low', business_unit: 'TELUS Digital', teams: 'TELUS Digital').code
21
+ end
22
+
23
+ should 'Return HTTP 200 from beginprescan.do' do
24
+ assert_equal 200, veracode_api_request('beginprescan.do', app_id:'12379').code
25
+ end
26
+
27
+ # should 'Return XML response for uploadfile.do' do
28
+ # assert_boolean upload_file('12379', '/home/zaya/Documents/test.php.tar').include?('Uploaded')
29
+ # end
30
+
31
+ should 'Return HTTP from get_prescan_results function' do
32
+ assert_equal 200, get_prescan_results('12379').code
33
+ end
34
+
35
+ should 'Return XML response' do
36
+ assert_boolean get_scan_report('12379').include?('<detailedreport')
37
+ end
38
+
39
+ should 'Return Application Scan Status' do
40
+ assert_kind_of String, get_build_status('12379')
41
+ end
42
+
43
+ should 'Return Most recent Build ID' do
44
+ assert_match /\d+/, get_most_recent_build_id('12379')
45
+ end
19
46
  end
20
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veracodecli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - isaiah thiessen