veracodecli 1.0.22 → 1.1.0
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 +4 -4
- data/README.md +2 -6
- data/VERSION +1 -1
- data/bin/veracodecli +1 -0
- data/lib/veracodecli/api.rb +19 -9
- data/lib/veracodecli/log.rb +3 -5
- data/veracodecli.gemspec +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 313198e33e2b38505233625eb8d025d41beac504
|
4
|
+
data.tar.gz: 1487b7b9c55c5f56f3110e2e7fe7cf1a712f3657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49db16d2ff4db3bbfbfb9f93cde12a2fc7ff974efa4ab03ff728c3a3c659fb602687a2c94b84010622840b3c86ab1797564b00013da67af53ca390add48a97fd
|
7
|
+
data.tar.gz: 9b30ee9969e1d561e0838d4eea1a2c137dbc8793ce08424ce8bbbe6a19459e06282a79e9af2610491f35fa6bb23642489fcd79f594b646c629e6d43d7dc655c9
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
Support for this gem will soon be dropped in favour of https://github.com/isand3r/apidragon
|
2
|
+
|
1
3
|
# veracodecli
|
2
4
|
|
3
5
|
[](https://codeclimate.com/github/isand3r/veracodecli)
|
@@ -8,7 +10,6 @@ A ruby cli gem for interacting with the veracode API
|
|
8
10
|
|
9
11
|
- [Installation](#installation)
|
10
12
|
- [Usage](#usage)
|
11
|
-
- [Roadmap](#roadmap)
|
12
13
|
- [License](#license)
|
13
14
|
- [Contributors](#contributors)
|
14
15
|
|
@@ -28,11 +29,6 @@ gem install veracodecli
|
|
28
29
|
|
29
30
|
(append `--trace` to the end to see a stack trace if you are encountering errors.)
|
30
31
|
|
31
|
-
## Roadmap
|
32
|
-
Ideas for future development.
|
33
|
-
|
34
|
-
* Config file: Make this cli scanner/tool agnostic. Should work with rest api services from other tools
|
35
|
-
|
36
32
|
## License
|
37
33
|
|
38
34
|
[MIT](https://tldrlegal.com/license/mit-license)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/bin/veracodecli
CHANGED
data/lib/veracodecli/api.rb
CHANGED
@@ -6,7 +6,11 @@ require 'nokogiri'
|
|
6
6
|
require_relative 'settings'
|
7
7
|
require_relative 'log'
|
8
8
|
|
9
|
+
# Base Module. Contains parsing and rest call functions.
|
9
10
|
module VeracodeApiBase
|
11
|
+
# Makes a REST request to analysiscenter.veracode.com/api/[version]/[function], where function is the passed api_call method argument,
|
12
|
+
# api_version is the passed method argument with default value '4.0', and params is any number of json key:value pairs passed in the **params method argument.
|
13
|
+
# The response is logged to /tmp/veracodecli.log as long as the HTTP response code = 200. 5XX or 4XX raise an Error.
|
10
14
|
def veracode_api_request(api_call, api_version: '4.0', **params)
|
11
15
|
begin
|
12
16
|
# RestClient.proxy = Settings.proxy unless !Settings.proxy
|
@@ -20,6 +24,7 @@ module VeracodeApiBase
|
|
20
24
|
response
|
21
25
|
end
|
22
26
|
|
27
|
+
# Clones or updates a git clone of the desired directory (set in the configuration file), then zips the contents to /temp/sast_upload.zip.
|
23
28
|
def get_repo_archive(url)
|
24
29
|
directory = "/tmp/sast_clone"
|
25
30
|
if Dir.exists?(directory)
|
@@ -30,6 +35,7 @@ module VeracodeApiBase
|
|
30
35
|
`cd /tmp; zip -r sast_upload.zip sast_clone`
|
31
36
|
end
|
32
37
|
|
38
|
+
# Returns the passed xml 'response' for the 'app_id' attribute associated with the passed 'app_name' for the 'getapplist' call.
|
33
39
|
def response_parse_app_id(response, app_name)
|
34
40
|
app_id = nil
|
35
41
|
doc = Nokogiri::XML response
|
@@ -41,6 +47,7 @@ module VeracodeApiBase
|
|
41
47
|
app_id
|
42
48
|
end
|
43
49
|
|
50
|
+
# Returns the passed xml 'response' for the 'app_id' attribute for the 'createapp' call.
|
44
51
|
def parse_new_app_id(response)
|
45
52
|
app_id = nil
|
46
53
|
doc = Nokogiri::XML response
|
@@ -53,47 +60,47 @@ module VeracodeApiBase
|
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
63
|
+
# Scan Module. Contains all functions necessary to submit a scan.
|
56
64
|
module VeracodeApiScan
|
57
65
|
include VeracodeApiBase
|
58
66
|
|
67
|
+
# calls getapplist and returns the ''app_id' attribute associated with the passed 'app_name' argument.
|
59
68
|
def get_app_id(app_name)
|
60
69
|
app_list = veracode_api_request 'getapplist.do', include_user_info: 'true'
|
61
70
|
app_id = response_parse_app_id app_list.body, app_name
|
62
71
|
end
|
63
72
|
|
73
|
+
# calls 'createapp' to create an new app profile. All arguments are required and can be specified in the config file.
|
64
74
|
def create_app_profile(app_name, business_criticality, business_unit, team)
|
65
75
|
create_app_response = veracode_api_request 'createapp.do', app_name: app_name, business_criticality: business_criticality, business_unit: business_unit, teams: team
|
66
76
|
app_id = parse_new_app_id create_app_response.body
|
67
77
|
if app_id.nil? then abort 'createapp failed. Check the logs.' end
|
68
78
|
end
|
69
79
|
|
80
|
+
# Calls 'uploadfile' to upload the previously created 'sast_upload.zip'.
|
70
81
|
def upload_file(app_id, archive_path)
|
71
82
|
# NOTE: curl must be used here because of a bug in the Veracode api. rest-client cannot be used while this bug is present.
|
72
83
|
# NOTE: preferred code: upload_result = veracode_api_request 'uploadfile.do', app_id: app_id, file: "#{archive_path}"
|
73
84
|
`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}'`
|
74
85
|
end
|
75
86
|
|
87
|
+
# calls 'beginprescan' for the passed app_id argument. 'auto_scan: 'true'' means that the scan will begin automatically after the prescan unless there are errors.
|
76
88
|
def submit_prescan(app_id)
|
77
89
|
veracode_api_request 'beginprescan.do', app_id: app_id, auto_scan: 'true'
|
78
90
|
end
|
79
91
|
end
|
80
92
|
|
93
|
+
# Results module. Contains all methods necessary to download scan reports.
|
81
94
|
module VeracodeApiResults
|
82
95
|
include VeracodeApiBase
|
83
96
|
|
97
|
+
# calls 'getbuildlist' and returns the last 'build_id' attribute associated with the passed app_id
|
84
98
|
def get_most_recent_build_id(app_id)
|
85
99
|
build_list = veracode_api_request 'getbuildlist.do', app_id: app_id
|
86
100
|
build_list.body.scan(/build_id="(.*?)"/).last[0]
|
87
101
|
end
|
88
|
-
|
89
|
-
#
|
90
|
-
# build_info = veracode_api_request 'getbuildinfo.do', app_id: app_id
|
91
|
-
# build_id = build_info.body.scan(/build_id="(.*?)"/)[0][0]
|
92
|
-
# build_status = build_info.body.scan(/status="(.*?)"/).last[0]
|
93
|
-
# puts build_status
|
94
|
-
# build_status
|
95
|
-
# end
|
96
|
-
|
102
|
+
|
103
|
+
# calls 'getprescanresults'
|
97
104
|
def get_prescan_results(app_id)
|
98
105
|
results = veracode_api_request 'getprescanresults.do', app_id: app_id
|
99
106
|
puts "Fetched prescan results for #{app_id}"
|
@@ -101,17 +108,20 @@ module VeracodeApiResults
|
|
101
108
|
results
|
102
109
|
end
|
103
110
|
|
111
|
+
# calls 'detailedreport' for the passed 'build_id' attribute, returning the xml body of the response. Note that this api is version 3.0 not 4.0.
|
104
112
|
def get_scan_report(build_id)
|
105
113
|
report = veracode_api_request 'detailedreport.do', api_version: '3.0', build_id: build_id
|
106
114
|
report.body
|
107
115
|
end
|
108
116
|
|
117
|
+
# similar to above method, except returns a pdf response instead of xml.
|
109
118
|
def get_scan_report_pdf(build_id)
|
110
119
|
report = veracode_api_request 'detailedreportpdf.do', api_version: '3.0', build_id: build_id
|
111
120
|
report.body
|
112
121
|
end
|
113
122
|
end
|
114
123
|
|
124
|
+
# Macros module. Contains sequenced method calls from above modules to perform actions such as submitting scans, retreiving reports.
|
115
125
|
module VeracodeApiMacros
|
116
126
|
include VeracodeApiScan
|
117
127
|
include VeracodeApiResults
|
data/lib/veracodecli/log.rb
CHANGED
@@ -2,12 +2,13 @@ require 'json'
|
|
2
2
|
|
3
3
|
class ResponseLogger
|
4
4
|
|
5
|
+
# Logger initialization, records the desired log file path.
|
5
6
|
def initialize(log_path)
|
6
7
|
@path = log_path
|
7
8
|
end
|
8
9
|
|
10
|
+
# writes the following information for the passed response string: date & time the call was made, body (response), call name (call), HTTP response code (code).
|
9
11
|
def log(call, code, response)
|
10
|
-
check_log_file "#{@path}/veracodecli.log"
|
11
12
|
log = File.open "#{@path}/veracodecli.log", 'a+'
|
12
13
|
log.write "#{call} called @ #{timestamp}"
|
13
14
|
log.write "HTTP #{code}\n"
|
@@ -16,10 +17,7 @@ class ResponseLogger
|
|
16
17
|
log.close
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
File.open file_path, 'w' unless File.exist? file_path
|
21
|
-
end
|
22
|
-
|
20
|
+
# Returns current system date & time.
|
23
21
|
def timestamp
|
24
22
|
`date`
|
25
23
|
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.1.0 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.1.0"
|
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-
|
14
|
+
s.date = "2015-12-14"
|
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"]
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
|
|
41
41
|
]
|
42
42
|
s.homepage = "http://github.com/isand3r/veracodecli"
|
43
43
|
s.licenses = ["MIT"]
|
44
|
-
s.rubygems_version = "2.
|
44
|
+
s.rubygems_version = "2.5.0"
|
45
45
|
s.summary = "Ruby based CLI for accessing veracode's api"
|
46
46
|
|
47
47
|
if s.respond_to? :specification_version then
|
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.1.0
|
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
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
281
|
version: '0'
|
282
282
|
requirements: []
|
283
283
|
rubyforge_project:
|
284
|
-
rubygems_version: 2.
|
284
|
+
rubygems_version: 2.5.0
|
285
285
|
signing_key:
|
286
286
|
specification_version: 4
|
287
287
|
summary: Ruby based CLI for accessing veracode's api
|