veracodecli 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/veracodecli/api.rb +28 -14
- data/lib/veracodecli/log.rb +6 -1
- data/veracodecli.gemspec +3 -4
- metadata +2 -3
- data/veracodecli-1.0.9.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b1a71295f50c1b317d7d7d3725479f1a6788daf
|
4
|
+
data.tar.gz: 61cb73f9560e48e6b84bab0327ee0d171b46a187
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e30d4a55f21dba97daceb6fc90605fee934a0ca8fd21aee31d6b477a7d73cdf8765160082b9a434d97e0a5bde806a2e9517e560b21bb8bf01bc1d8f67ab44b63
|
7
|
+
data.tar.gz: 5695acabe10bf20fcfcdab7a912c2442a44e44c62bb8b305364e9b68116694999c3e7cf8d20c45fd96f90d9f9d44c6e371b8ea71d15950f70e9c323c89fe29eb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.11
|
data/lib/veracodecli/api.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'active_support/core_ext/hash'
|
3
3
|
require 'rest-client'
|
4
4
|
require 'yaml'
|
5
|
+
require 'nokogiri'
|
5
6
|
require_relative 'settings'
|
6
7
|
require_relative 'log'
|
7
8
|
|
@@ -9,9 +10,9 @@ module VeracodeApiBase
|
|
9
10
|
def veracode_api_request(api_call, api_version: '4.0', **params)
|
10
11
|
begin
|
11
12
|
response = RestClient.get "https://#{Settings.veracode_username}:#{Settings.veracode_password}@analysiscenter.veracode.com/api/#{api_version}/#{api_call}", { params: params }
|
12
|
-
log = ResponseLogger.new "/
|
13
|
+
log = ResponseLogger.new "/tmp"
|
13
14
|
log.log api_call, response.code, response.body
|
14
|
-
rescue
|
15
|
+
rescue RestClient
|
15
16
|
abort '401: Unauthorized. Veracode API call Failed, please check your veracode credentials or whitelisted IPs'
|
16
17
|
end
|
17
18
|
if [500,501,502,503].any?{|code| response.code == code} then abort 'Internal server error.' end
|
@@ -27,6 +28,28 @@ module VeracodeApiBase
|
|
27
28
|
end
|
28
29
|
`cd /tmp; zip -r sast_upload.zip sast_clone`
|
29
30
|
end
|
31
|
+
|
32
|
+
def response_parse_app_id(response, app_name)
|
33
|
+
app_id = nil
|
34
|
+
doc = Nokogiri::XML response
|
35
|
+
doc.remove_namespaces!
|
36
|
+
if doc.xpath('//app').empty? then return nil end
|
37
|
+
doc.xpath('//app').each do |app|
|
38
|
+
if app.attributes['app_name'].value == app_name then app_id = app.attributes['app_id'].value end
|
39
|
+
end
|
40
|
+
app_id
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse_new_app_id(response)
|
44
|
+
app_id = nil
|
45
|
+
doc = Nokogiri::XML response
|
46
|
+
doc.remove_namespaces!
|
47
|
+
if doc.xpath('//application').empty? then return nil end
|
48
|
+
doc.xpath('//application').each do |application|
|
49
|
+
app_id = application.attributes['app_id'].value
|
50
|
+
end
|
51
|
+
app_id
|
52
|
+
end
|
30
53
|
end
|
31
54
|
|
32
55
|
module VeracodeApiScan
|
@@ -34,22 +57,13 @@ module VeracodeApiScan
|
|
34
57
|
|
35
58
|
def get_app_id(app_name)
|
36
59
|
app_list = veracode_api_request 'getapplist.do', include_user_info: 'true'
|
37
|
-
|
38
|
-
if scan.empty?
|
39
|
-
app_id = scan[0][0]
|
40
|
-
else
|
41
|
-
app_id = nil
|
42
|
-
end
|
60
|
+
app_id = response_parse_app_id app_list.body, app_name
|
43
61
|
end
|
44
62
|
|
45
63
|
def create_app_profile(app_name, business_criticality, business_unit, team)
|
46
64
|
create_app_response = veracode_api_request 'createapp.do', app_name: app_name, business_criticality: business_criticality, business_unit: business_unit, teams: team
|
47
|
-
|
48
|
-
if
|
49
|
-
fail 'createapp failed. Make sure you have supplied the correct parameters.'
|
50
|
-
else
|
51
|
-
app_id = scan[0][0]
|
52
|
-
end
|
65
|
+
app_id = parse_new_app_id create_app_response.body
|
66
|
+
if app_id.nil? then abort 'createapp failed. Check the logs.' end
|
53
67
|
end
|
54
68
|
|
55
69
|
def upload_file(app_id, archive_path)
|
data/lib/veracodecli/log.rb
CHANGED
@@ -7,14 +7,19 @@ class ResponseLogger
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def log(call, code, response)
|
10
|
+
check_log_file "#{@path}/veracodecli.log"
|
10
11
|
log = File.open "#{@path}/veracodecli.log", 'a+'
|
11
12
|
log.write "#{call} called @ #{timestamp}"
|
12
|
-
log.write "HTTP #{code}"
|
13
|
+
log.write "HTTP #{code}\n"
|
13
14
|
log.write response
|
14
15
|
log.write "\n"
|
15
16
|
log.close
|
16
17
|
end
|
17
18
|
|
19
|
+
def check_log_file(file_path)
|
20
|
+
File.open file_path, 'w' unless File.exist? file_path
|
21
|
+
end
|
22
|
+
|
18
23
|
def timestamp
|
19
24
|
`date`
|
20
25
|
end
|
data/veracodecli.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: veracodecli 1.0.
|
5
|
+
# stub: veracodecli 1.0.11 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "veracodecli"
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.11"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["isaiah thiessen"]
|
14
|
-
s.date = "2015-11-
|
14
|
+
s.date = "2015-11-04"
|
15
15
|
s.description = "Ruby based CLI for accessing veracode's api"
|
16
16
|
s.email = "isaiah.thiessen@telus.com"
|
17
17
|
s.executables = ["veracodecli"]
|
@@ -37,7 +37,6 @@ Gem::Specification.new do |s|
|
|
37
37
|
"test/API.rb",
|
38
38
|
"test/helper.rb",
|
39
39
|
"test/test_veracodecli.rb",
|
40
|
-
"veracodecli-1.0.9.gem",
|
41
40
|
"veracodecli.gemspec"
|
42
41
|
]
|
43
42
|
s.homepage = "http://github.com/isand3r/veracodecli"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: veracodecli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- isaiah thiessen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -246,7 +246,6 @@ files:
|
|
246
246
|
- test/API.rb
|
247
247
|
- test/helper.rb
|
248
248
|
- test/test_veracodecli.rb
|
249
|
-
- veracodecli-1.0.9.gem
|
250
249
|
- veracodecli.gemspec
|
251
250
|
homepage: http://github.com/isand3r/veracodecli
|
252
251
|
licenses:
|
data/veracodecli-1.0.9.gem
DELETED
Binary file
|