Module: VeracodeApiScan

Includes:
VeracodeApiBase
Included in:
VeracodeApiMacros
Defined in:
lib/veracodecli/api.rb

Instance Method Summary collapse

Methods included from VeracodeApiBase

#get_repo_archive, #veracode_api_request

Instance Method Details

#create_app_profile(app_name, business_criticality, business_unit, team) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/veracodecli/api.rb', line 46

def create_app_profile(app_name, business_criticality, business_unit, team)
  create_app_response = veracode_api_request 'createapp.do', app_name: app_name, business_criticality: business_criticality, business_unit: business_unit, teams: team
  app_id = create_app_response.body.scan(/app_id=\"(.+)\" app_name=\"#{app_name}\"/)
  if app_id.emtpy?
    fail 'createapp failed. Make sure you have supplied the correct parameters.'
  else
    app_id[0][0]
  end
end

#get_app_id(app_name) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/veracodecli/api.rb', line 35

def get_app_id(app_name)
  app_list = veracode_api_request 'getapplist.do', include_user_info: 'true'
  scan = app_list.body.scan(/app_id=\"(.+)\" app_name=\"#{app_name}\"/)
  begin
    app_id = scan[0][0]
  rescue
    app_id = nil
  end
  app_id
end

#submit_prescan(app_id) ⇒ Object



62
63
64
# File 'lib/veracodecli/api.rb', line 62

def submit_prescan(app_id)
  veracode_api_request 'beginprescan.do', app_id: app_id, auto_scan: 'true'
end

#upload_file(app_id, archive_path) ⇒ Object



56
57
58
59
60
# File 'lib/veracodecli/api.rb', line 56

def upload_file(app_id, archive_path)
  # NOTE: curl must be used here because of a bug in the Veracode api. rest-client cannot be used while this bug is present.
  # NOTE: preferred code: upload_result = veracode_api_request 'uploadfile.do', app_id: app_id, file: "#{archive_path}"
  `curl --url "https://#{Settings.veracode_username}:#{Settings.veracode_password}@analysiscenter.veracode.com/api/4.0/uploadfile.do" -F 'app_id=#{app_id}' -F 'file=@#{archive_path}'`
end