veracodecli 0.1.1
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 +7 -0
- data/.document +5 -0
- data/.gitignore +49 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +136 -0
- data/LICENSE.txt +20 -0
- data/README.md +43 -0
- data/Rakefile +67 -0
- data/VERSION +1 -0
- data/bin/veracodecli +51 -0
- data/lib/veracodecli/api.rb +91 -0
- data/lib/veracodecli.rb +1 -0
- data/test/API.rb +0 -0
- data/test/helper.rb +34 -0
- data/test/test_veracodecli.rb +7 -0
- data/veracodecli.gemspec +78 -0
- metadata +243 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 0d86671ebe7e7e93e6b99fa5f5721077f83bc914
|
|
4
|
+
data.tar.gz: 0302d869bf676c5a9a13c80f1b9b824c5aa036f4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cce72b0d8a252b2871740809e137cda2f59c55f74ab0a416f69ca53e25d820ddc95c302d7018115f878968b4cb745709a6483172ed8f675e33fc3ca05ecce661
|
|
7
|
+
data.tar.gz: 4fd15c923437ede2bd593d88ad9402ee428752ef6b634e086698426da319079f36a78f666ce695452fea6f11cab8b01e22f1bd51f42b5e1b1cb83d56b7bc61ae
|
data/.document
ADDED
data/.gitignore
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# rcov generated
|
|
2
|
+
coverage
|
|
3
|
+
coverage.data
|
|
4
|
+
|
|
5
|
+
# rdoc generated
|
|
6
|
+
rdoc
|
|
7
|
+
|
|
8
|
+
# yard generated
|
|
9
|
+
doc
|
|
10
|
+
.yardoc
|
|
11
|
+
|
|
12
|
+
# bundler
|
|
13
|
+
.bundle
|
|
14
|
+
|
|
15
|
+
# jeweler generated
|
|
16
|
+
pkg
|
|
17
|
+
|
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
|
19
|
+
#
|
|
20
|
+
# * Create a file at ~/.gitignore
|
|
21
|
+
# * Include files you want ignored
|
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
|
23
|
+
#
|
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
|
26
|
+
#
|
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
|
28
|
+
#
|
|
29
|
+
# For MacOS:
|
|
30
|
+
#
|
|
31
|
+
#.DS_Store
|
|
32
|
+
|
|
33
|
+
# For TextMate
|
|
34
|
+
#*.tmproj
|
|
35
|
+
#tmtags
|
|
36
|
+
|
|
37
|
+
# For emacs:
|
|
38
|
+
#*~
|
|
39
|
+
#\#*
|
|
40
|
+
#.\#*
|
|
41
|
+
|
|
42
|
+
# For vim:
|
|
43
|
+
#*.swp
|
|
44
|
+
|
|
45
|
+
# For redcar:
|
|
46
|
+
#.redcar
|
|
47
|
+
|
|
48
|
+
# For rubinius:
|
|
49
|
+
#*.rbc
|
data/Gemfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem 'json'
|
|
4
|
+
gem 'activesupport'
|
|
5
|
+
gem 'rest-client'
|
|
6
|
+
gem 'commander'
|
|
7
|
+
|
|
8
|
+
group :development do
|
|
9
|
+
gem "shoulda", ">= 0"
|
|
10
|
+
gem "yard", "~> 0.7"
|
|
11
|
+
gem "rdoc", "~> 3.12"
|
|
12
|
+
gem "bundler", "~> 1.0"
|
|
13
|
+
gem "jeweler", "~> 2.0.1"
|
|
14
|
+
gem "simplecov", ">= 0"
|
|
15
|
+
gem "reek", "~> 1.2.8"
|
|
16
|
+
gem "roodi", "~> 2.1.0"
|
|
17
|
+
gem "rubocop", "~> 0.32.1"
|
|
18
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activesupport (4.2.4)
|
|
5
|
+
i18n (~> 0.7)
|
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
|
7
|
+
minitest (~> 5.1)
|
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
9
|
+
tzinfo (~> 1.1)
|
|
10
|
+
addressable (2.3.8)
|
|
11
|
+
ast (2.0.0)
|
|
12
|
+
astrolabe (1.3.1)
|
|
13
|
+
parser (~> 2.2)
|
|
14
|
+
builder (3.2.2)
|
|
15
|
+
commander (4.3.5)
|
|
16
|
+
highline (~> 1.7.2)
|
|
17
|
+
descendants_tracker (0.0.4)
|
|
18
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
19
|
+
docile (1.1.5)
|
|
20
|
+
domain_name (0.5.24)
|
|
21
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
22
|
+
faraday (0.9.1)
|
|
23
|
+
multipart-post (>= 1.2, < 3)
|
|
24
|
+
git (1.2.9.1)
|
|
25
|
+
github_api (0.12.4)
|
|
26
|
+
addressable (~> 2.3)
|
|
27
|
+
descendants_tracker (~> 0.0.4)
|
|
28
|
+
faraday (~> 0.8, < 0.10)
|
|
29
|
+
hashie (>= 3.4)
|
|
30
|
+
multi_json (>= 1.7.5, < 2.0)
|
|
31
|
+
nokogiri (~> 1.6.6)
|
|
32
|
+
oauth2
|
|
33
|
+
hashie (3.4.2)
|
|
34
|
+
highline (1.7.6)
|
|
35
|
+
http-cookie (1.0.2)
|
|
36
|
+
domain_name (~> 0.5)
|
|
37
|
+
i18n (0.7.0)
|
|
38
|
+
jeweler (2.0.1)
|
|
39
|
+
builder
|
|
40
|
+
bundler (>= 1.0)
|
|
41
|
+
git (>= 1.2.5)
|
|
42
|
+
github_api
|
|
43
|
+
highline (>= 1.6.15)
|
|
44
|
+
nokogiri (>= 1.5.10)
|
|
45
|
+
rake
|
|
46
|
+
rdoc
|
|
47
|
+
json (1.8.3)
|
|
48
|
+
jwt (1.5.1)
|
|
49
|
+
mime-types (2.6.2)
|
|
50
|
+
mini_portile (0.6.2)
|
|
51
|
+
minitest (5.8.0)
|
|
52
|
+
multi_json (1.11.2)
|
|
53
|
+
multi_xml (0.5.5)
|
|
54
|
+
multipart-post (2.0.0)
|
|
55
|
+
netrc (0.10.3)
|
|
56
|
+
nokogiri (1.6.6.2)
|
|
57
|
+
mini_portile (~> 0.6.0)
|
|
58
|
+
oauth2 (1.0.0)
|
|
59
|
+
faraday (>= 0.8, < 0.10)
|
|
60
|
+
jwt (~> 1.0)
|
|
61
|
+
multi_json (~> 1.3)
|
|
62
|
+
multi_xml (~> 0.5)
|
|
63
|
+
rack (~> 1.2)
|
|
64
|
+
parser (2.2.2.6)
|
|
65
|
+
ast (>= 1.1, < 3.0)
|
|
66
|
+
powerpack (0.1.1)
|
|
67
|
+
rack (1.6.4)
|
|
68
|
+
rainbow (2.0.0)
|
|
69
|
+
rake (10.4.2)
|
|
70
|
+
rdoc (3.12.2)
|
|
71
|
+
json (~> 1.4)
|
|
72
|
+
reek (1.2.13)
|
|
73
|
+
ripper_ruby_parser (~> 0.0.7)
|
|
74
|
+
ruby2ruby (~> 1.2.5)
|
|
75
|
+
ruby_parser (~> 2.0)
|
|
76
|
+
sexp_processor (~> 3.0)
|
|
77
|
+
rest-client (1.8.0)
|
|
78
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
79
|
+
mime-types (>= 1.16, < 3.0)
|
|
80
|
+
netrc (~> 0.7)
|
|
81
|
+
ripper_ruby_parser (0.0.8)
|
|
82
|
+
sexp_processor (~> 3.0)
|
|
83
|
+
roodi (2.1.0)
|
|
84
|
+
ruby_parser
|
|
85
|
+
rubocop (0.32.1)
|
|
86
|
+
astrolabe (~> 1.3)
|
|
87
|
+
parser (>= 2.2.2.5, < 3.0)
|
|
88
|
+
powerpack (~> 0.1)
|
|
89
|
+
rainbow (>= 1.99.1, < 3.0)
|
|
90
|
+
ruby-progressbar (~> 1.4)
|
|
91
|
+
ruby-progressbar (1.7.5)
|
|
92
|
+
ruby2ruby (1.2.5)
|
|
93
|
+
ruby_parser (~> 2.0)
|
|
94
|
+
sexp_processor (~> 3.0)
|
|
95
|
+
ruby_parser (2.3.1)
|
|
96
|
+
sexp_processor (~> 3.0)
|
|
97
|
+
sexp_processor (3.2.0)
|
|
98
|
+
shoulda (3.5.0)
|
|
99
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
|
100
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
|
101
|
+
shoulda-context (1.2.1)
|
|
102
|
+
shoulda-matchers (2.8.0)
|
|
103
|
+
activesupport (>= 3.0.0)
|
|
104
|
+
simplecov (0.10.0)
|
|
105
|
+
docile (~> 1.1.0)
|
|
106
|
+
json (~> 1.8)
|
|
107
|
+
simplecov-html (~> 0.10.0)
|
|
108
|
+
simplecov-html (0.10.0)
|
|
109
|
+
thread_safe (0.3.5)
|
|
110
|
+
tzinfo (1.2.2)
|
|
111
|
+
thread_safe (~> 0.1)
|
|
112
|
+
unf (0.1.4)
|
|
113
|
+
unf_ext
|
|
114
|
+
unf_ext (0.0.7.1)
|
|
115
|
+
yard (0.8.7.6)
|
|
116
|
+
|
|
117
|
+
PLATFORMS
|
|
118
|
+
ruby
|
|
119
|
+
|
|
120
|
+
DEPENDENCIES
|
|
121
|
+
activesupport
|
|
122
|
+
bundler (~> 1.0)
|
|
123
|
+
commander
|
|
124
|
+
jeweler (~> 2.0.1)
|
|
125
|
+
json
|
|
126
|
+
rdoc (~> 3.12)
|
|
127
|
+
reek (~> 1.2.8)
|
|
128
|
+
rest-client
|
|
129
|
+
roodi (~> 2.1.0)
|
|
130
|
+
rubocop (~> 0.32.1)
|
|
131
|
+
shoulda
|
|
132
|
+
simplecov
|
|
133
|
+
yard (~> 0.7)
|
|
134
|
+
|
|
135
|
+
BUNDLED WITH
|
|
136
|
+
1.10.6
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2015
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# veracodecli
|
|
2
|
+
|
|
3
|
+
A ruby cli gem for interacting with the veracode API
|
|
4
|
+
|
|
5
|
+
## Table of contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [How To Contribute](#how-to-contribute)
|
|
10
|
+
- [License](#license)
|
|
11
|
+
- [Contributors](#contributors)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
gem install veracodecli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
1. Set `VERACODE_USERNAME`, `VERACODE_PASSWORD`, and `VERACODE_TEAM` environment variables to your API credentials for the veracode API.
|
|
22
|
+
2. To run a scan use `veracodecli scan _app\_name_ _archive\_path_
|
|
23
|
+
|
|
24
|
+
- `veracodecli help` to see commands
|
|
25
|
+
- `veracodecli [command] -h` to see command syntax
|
|
26
|
+
|
|
27
|
+
## How To Contribute
|
|
28
|
+
This gem uses [jeweler](https://github.com/technicalpickles/jeweler) for development. Read about relevant commands at that repo.
|
|
29
|
+
|
|
30
|
+
* Fork the project.
|
|
31
|
+
* Start a feature/bugfix branch.
|
|
32
|
+
* Use `rake install` in the main directory to install the gem on your system.
|
|
33
|
+
* Commit and push until you are happy with your contribution.
|
|
34
|
+
* Make a pull request to this repo.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
[MIT](https://tldrlegal.com/license/mit-license)
|
|
39
|
+
|
|
40
|
+
## Contributors
|
|
41
|
+
|
|
42
|
+
* Isaiah Thiessen | [email](mailto:isaiah.thiessen@telus.com)
|
|
43
|
+
* Ben Visser | [email](mailto:benjamin.visser@telus.com)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
begin
|
|
6
|
+
Bundler.setup(:default, :development)
|
|
7
|
+
rescue Bundler::BundlerError => e
|
|
8
|
+
$stderr.puts e.message
|
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
+
exit e.status_code
|
|
11
|
+
end
|
|
12
|
+
require 'rake'
|
|
13
|
+
|
|
14
|
+
require 'jeweler'
|
|
15
|
+
Jeweler::Tasks.new do |gem|
|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
|
17
|
+
gem.name = "veracodecli"
|
|
18
|
+
gem.homepage = "http://github.com/isand3r/veracodecli"
|
|
19
|
+
gem.license = "MIT"
|
|
20
|
+
gem.summary = %Q{Ruby based CLI for accessing veracode's api}
|
|
21
|
+
gem.description = %Q{Ruby based CLI for accessing veracode's api}
|
|
22
|
+
gem.email = "isaiah.thiessen@telus.com"
|
|
23
|
+
gem.authors = ["isaiah thiessen"]
|
|
24
|
+
gem.files = `git ls-files`.split("\n")
|
|
25
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
26
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
27
|
+
gem.require_paths = ['lib']
|
|
28
|
+
# dependencies defined in Gemfile
|
|
29
|
+
end
|
|
30
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
31
|
+
|
|
32
|
+
require 'rake/testtask'
|
|
33
|
+
Rake::TestTask.new(:test) do |test|
|
|
34
|
+
test.libs << 'lib' << 'test'
|
|
35
|
+
test.pattern = 'test/**/test_*.rb'
|
|
36
|
+
test.verbose = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
require 'rubocop/rake_task'
|
|
40
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
41
|
+
task.patterns = ['lib/**/*.rb']
|
|
42
|
+
task.fail_on_error = false
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
desc "Code coverage detail"
|
|
46
|
+
task :simplecov do
|
|
47
|
+
ENV['COVERAGE'] = "true"
|
|
48
|
+
Rake::Task['test'].execute
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
require 'reek/rake/task'
|
|
52
|
+
Reek::Rake::Task.new do |t|
|
|
53
|
+
t.fail_on_error = true
|
|
54
|
+
t.verbose = false
|
|
55
|
+
t.source_files = 'lib/**/*.rb'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
require 'roodi'
|
|
59
|
+
require 'roodi_task'
|
|
60
|
+
RoodiTask.new do |t|
|
|
61
|
+
t.verbose = false
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
task :default => :test
|
|
65
|
+
|
|
66
|
+
require 'yard'
|
|
67
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.1
|
data/bin/veracodecli
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'commander'
|
|
4
|
+
require 'veracodecli'
|
|
5
|
+
include VeracodeApiResults
|
|
6
|
+
|
|
7
|
+
Commander.configure do
|
|
8
|
+
program :name, 'veracodecli'
|
|
9
|
+
program :version, '0.1.0'
|
|
10
|
+
program :description, 'CLI for automating veracode api requests'
|
|
11
|
+
program :help, 'Author', 'Isaiah Thiessen <isaiah.thiessen@telus.com>'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
command :scan do |c|
|
|
15
|
+
c.syntax = 'veracodecli scan [hostname] [archive_path]'
|
|
16
|
+
c.description = 'Submits a scan request to Veracode.'
|
|
17
|
+
c.action do |args|
|
|
18
|
+
fail 'Specify application Name.' if args.first.nil?
|
|
19
|
+
fail 'Specify path to code archive.' if args[1].nil?
|
|
20
|
+
VeracodeApiScan.submit_scan args[0], args[1]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
command :get_prescan_results do |c|
|
|
25
|
+
c.syntax = 'veracodecli get-prescan-results [app_id]'
|
|
26
|
+
c.description = 'Downloads the prescan results from Veracode.'
|
|
27
|
+
c.action do |args|
|
|
28
|
+
fail 'Specify app_id.' if args.first.nil?
|
|
29
|
+
VeracodeApiResults.get_prescan_results args.first
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
command :get_status do |c|
|
|
34
|
+
c.syntax = 'veracodecli get-status [app_id]'
|
|
35
|
+
c.description = 'Gets scan state of current build from Veracode.'
|
|
36
|
+
c.action do |args|
|
|
37
|
+
fail 'Specify app_id.' if args.first.nil?
|
|
38
|
+
VeracodeApiResults.get_build_status args.first
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
command :get_report do |c|
|
|
43
|
+
c.syntax = 'veracodecli get-report [app_id]'
|
|
44
|
+
c.description = 'Downloads the final scan report from Veracode.'
|
|
45
|
+
c.action do |args|
|
|
46
|
+
fail 'Specify app_id.' if args.first.nil?
|
|
47
|
+
VeracodeApiResults.get_scan_report args.first
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'active_support/core_ext/hash'
|
|
3
|
+
require 'rest-client'
|
|
4
|
+
|
|
5
|
+
module VeracodeApiBase
|
|
6
|
+
def check_environment_login_variables
|
|
7
|
+
fail 'EnvironmentError: VERACODE_USERNAME, VERACODE_PASSWORD, or VERACODE_TEAM not set.' unless !ENV['VERACODE_USERNAME'].nil? || !ENV['VERACODE_PASSWORD'].nil? || !ENV['VERACODE_TEAM'].nil?
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def veracode_api_request(api_call, api_version: '4.0', **params)
|
|
11
|
+
check_environment_login_variables
|
|
12
|
+
# puts "Making call to #{api_call}"
|
|
13
|
+
response = RestClient.get "https://#{ENV['VERACODE_USERNAME']}:#{ENV['VERACODE_PASSWORD']}@analysiscenter.veracode.com/api/#{api_version}/#{api_call}", { params: params }
|
|
14
|
+
response.body
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def xml_to_json(string)
|
|
18
|
+
json = Hash.from_xml(string).to_json
|
|
19
|
+
JSON.parse json
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def write(data, to_file:)
|
|
23
|
+
data = xml_to_json data
|
|
24
|
+
f = File.open "../testdata/#{to_file}.json", 'w'
|
|
25
|
+
f.write JSON.pretty_generate data
|
|
26
|
+
f.close
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
module VeracodeApiScan
|
|
31
|
+
include VeracodeApiBase
|
|
32
|
+
|
|
33
|
+
def validate_existance(of:)
|
|
34
|
+
puts "Validating records for #{of}"
|
|
35
|
+
app_list = veracode_api_request 'getapplist.do', include_user_info: 'true'
|
|
36
|
+
if app_list.include? "#{of}"
|
|
37
|
+
puts 'Record found, submitting'
|
|
38
|
+
return app_list.scan(/app_id=\"(.+)\" app_name=\"#{of}\"/)[0][0]
|
|
39
|
+
else
|
|
40
|
+
puts 'Record not found, creating one'
|
|
41
|
+
create_app_result = veracode_api_request 'createapp.do', app_name: of, description: "Static Scanning profile for #{of}.", business_criticality: 'High', business_unit: 'TELUS Digital', web_application: 'true', teams: "#{ENV['VERACODE_TEAM']}"
|
|
42
|
+
app_id = create_app_result.scan(/app_id=\"(.+)\" app_name=\"#{of}\"/)[0][0]
|
|
43
|
+
puts "Record successfully created, app_id is #{app_id}"
|
|
44
|
+
return app_id
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def submit_scan(hostname, archive_path)
|
|
49
|
+
app_id = validate_existance of: hostname
|
|
50
|
+
# NOTE: curl must be used here because of a bug in the Veracode api. Ruby cannot be used while this bug is present.
|
|
51
|
+
# NOTE: preferred code: upload_result = veracode_api_request 'uploadfile.do', app_id: app_id, file: "#{archive_path}"
|
|
52
|
+
upload_result = `curl --url "https://#{ENV['VERACODE_USERNAME']}:#{ENV['VERACODE_PASSWORD']}@analysiscenter.veracode.com/api/4.0/uploadfile.do" -F 'app_id=#{app_id}' -F 'file=@#{archive_path}'`
|
|
53
|
+
puts upload_result
|
|
54
|
+
# write upload_result, to_file: "#{app_id}_upload_result"
|
|
55
|
+
prescan_submission_result = veracode_api_request 'beginprescan.do', app_id: app_id, auto_scan: 'true'
|
|
56
|
+
puts prescan_submission_result
|
|
57
|
+
puts "Submit complete for #{app_id}"
|
|
58
|
+
# File.write 'VERACODE_SCAN_RESULT_CHECK_QUEUE', app_id
|
|
59
|
+
# write prescan_submission_result, to_file: "#{app_id}_prescan_submission_result"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
module VeracodeApiResults
|
|
64
|
+
include VeracodeApiBase
|
|
65
|
+
|
|
66
|
+
def get_most_recent_build_id(using:)
|
|
67
|
+
build_list = veracode_api_request 'getbuildlist.do', app_id: using
|
|
68
|
+
# write build_list, to_file: "#{using}_build_list"
|
|
69
|
+
build_list.scan(/build_id="(.*?)"/).last[0]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def get_build_status(app_id)
|
|
73
|
+
build_info = veracode_api_request 'getbuildinfo.do', app_id: app_id
|
|
74
|
+
build_id = build_info.scan(/build_id="(.*?)"/)[0][0]
|
|
75
|
+
build_status = build_info.scan(/status="(.*?)"/).last[0]
|
|
76
|
+
puts build_status
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def get_prescan_results(app_id)
|
|
80
|
+
results = veracode_api_request 'getprescanresults.do', app_id: app_id
|
|
81
|
+
puts "Fetched prescan results for #{app_id}"
|
|
82
|
+
# write results, to_file: "#{app_id}_prescan_results"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def get_scan_report(app_id)
|
|
86
|
+
build_id = get_most_recent_build_id using: app_id
|
|
87
|
+
report = veracode_api_request 'detailedreport.do', api_version: '3.0', build_id: build_id
|
|
88
|
+
puts "Fetched report for #{app_id}, build #{build_id}"
|
|
89
|
+
# write report, to_file: "#{app_id}_report"
|
|
90
|
+
end
|
|
91
|
+
end
|
data/lib/veracodecli.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative 'veracodecli/api'
|
data/test/API.rb
ADDED
|
File without changes
|
data/test/helper.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'simplecov'
|
|
2
|
+
|
|
3
|
+
module SimpleCov::Configuration
|
|
4
|
+
def clean_filters
|
|
5
|
+
@filters = []
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
SimpleCov.configure do
|
|
10
|
+
clean_filters
|
|
11
|
+
load_adapter 'test_frameworks'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
|
15
|
+
add_filter "/.rvm/"
|
|
16
|
+
end
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'bundler'
|
|
19
|
+
begin
|
|
20
|
+
Bundler.setup(:default, :development)
|
|
21
|
+
rescue Bundler::BundlerError => e
|
|
22
|
+
$stderr.puts e.message
|
|
23
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
24
|
+
exit e.status_code
|
|
25
|
+
end
|
|
26
|
+
require 'test/unit'
|
|
27
|
+
require 'shoulda'
|
|
28
|
+
|
|
29
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
30
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
31
|
+
require 'veracodecli'
|
|
32
|
+
|
|
33
|
+
class Test::Unit::TestCase
|
|
34
|
+
end
|
data/veracodecli.gemspec
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
# stub: veracodecli 0.1.1 ruby lib
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = "veracodecli"
|
|
9
|
+
s.version = "0.1.1"
|
|
10
|
+
|
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
+
s.require_paths = ["lib"]
|
|
13
|
+
s.authors = ["isaiah thiessen"]
|
|
14
|
+
s.date = "2015-09-22"
|
|
15
|
+
s.description = "Ruby based CLI for accessing veracode's api"
|
|
16
|
+
s.email = "isaiah.thiessen@telus.com"
|
|
17
|
+
s.executables = ["veracodecli"]
|
|
18
|
+
s.extra_rdoc_files = [
|
|
19
|
+
"LICENSE.txt",
|
|
20
|
+
"README.md"
|
|
21
|
+
]
|
|
22
|
+
s.files = [
|
|
23
|
+
"bin/veracodecli",
|
|
24
|
+
"lib/veracodecli.rb",
|
|
25
|
+
"lib/veracodecli/api.rb"
|
|
26
|
+
]
|
|
27
|
+
s.homepage = "http://github.com/isand3r/veracodecli"
|
|
28
|
+
s.licenses = ["MIT"]
|
|
29
|
+
s.rubygems_version = "2.4.6"
|
|
30
|
+
s.summary = "Ruby based CLI for accessing veracode's api"
|
|
31
|
+
s.test_files = ["test/API.rb", "test/helper.rb", "test/test_veracodecli.rb"]
|
|
32
|
+
|
|
33
|
+
if s.respond_to? :specification_version then
|
|
34
|
+
s.specification_version = 4
|
|
35
|
+
|
|
36
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
37
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
|
38
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
|
39
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
|
40
|
+
s.add_runtime_dependency(%q<commander>, [">= 0"])
|
|
41
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
|
42
|
+
s.add_development_dependency(%q<yard>, ["~> 0.7"])
|
|
43
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
|
44
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
|
45
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
|
46
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
|
47
|
+
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
|
48
|
+
s.add_development_dependency(%q<roodi>, ["~> 2.1.0"])
|
|
49
|
+
else
|
|
50
|
+
s.add_dependency(%q<json>, [">= 0"])
|
|
51
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
|
52
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
|
53
|
+
s.add_dependency(%q<commander>, [">= 0"])
|
|
54
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
|
55
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
|
56
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
57
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
|
58
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
|
59
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
60
|
+
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
|
61
|
+
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
s.add_dependency(%q<json>, [">= 0"])
|
|
65
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
|
66
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
|
67
|
+
s.add_dependency(%q<commander>, [">= 0"])
|
|
68
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
|
69
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
|
70
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
71
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
|
73
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
74
|
+
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
|
75
|
+
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
metadata
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: veracodecli
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- isaiah thiessen
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: json
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: activesupport
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rest-client
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: commander
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: shoulda
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: yard
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0.7'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0.7'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rdoc
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '3.12'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '3.12'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: bundler
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '1.0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '1.0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: jeweler
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 2.0.1
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 2.0.1
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: simplecov
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: reek
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - "~>"
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: 1.2.8
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - "~>"
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: 1.2.8
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: roodi
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - "~>"
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: 2.1.0
|
|
174
|
+
type: :development
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - "~>"
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: 2.1.0
|
|
181
|
+
- !ruby/object:Gem::Dependency
|
|
182
|
+
name: rubocop
|
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
|
184
|
+
requirements:
|
|
185
|
+
- - "~>"
|
|
186
|
+
- !ruby/object:Gem::Version
|
|
187
|
+
version: 0.32.1
|
|
188
|
+
type: :development
|
|
189
|
+
prerelease: false
|
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
191
|
+
requirements:
|
|
192
|
+
- - "~>"
|
|
193
|
+
- !ruby/object:Gem::Version
|
|
194
|
+
version: 0.32.1
|
|
195
|
+
description: Ruby based CLI for accessing veracode's api
|
|
196
|
+
email: isaiah.thiessen@telus.com
|
|
197
|
+
executables:
|
|
198
|
+
- veracodecli
|
|
199
|
+
extensions: []
|
|
200
|
+
extra_rdoc_files:
|
|
201
|
+
- LICENSE.txt
|
|
202
|
+
- README.md
|
|
203
|
+
files:
|
|
204
|
+
- ".document"
|
|
205
|
+
- ".gitignore"
|
|
206
|
+
- Gemfile
|
|
207
|
+
- Gemfile.lock
|
|
208
|
+
- LICENSE.txt
|
|
209
|
+
- README.md
|
|
210
|
+
- Rakefile
|
|
211
|
+
- VERSION
|
|
212
|
+
- bin/veracodecli
|
|
213
|
+
- lib/veracodecli.rb
|
|
214
|
+
- lib/veracodecli/api.rb
|
|
215
|
+
- test/API.rb
|
|
216
|
+
- test/helper.rb
|
|
217
|
+
- test/test_veracodecli.rb
|
|
218
|
+
- veracodecli.gemspec
|
|
219
|
+
homepage: http://github.com/isand3r/veracodecli
|
|
220
|
+
licenses:
|
|
221
|
+
- MIT
|
|
222
|
+
metadata: {}
|
|
223
|
+
post_install_message:
|
|
224
|
+
rdoc_options: []
|
|
225
|
+
require_paths:
|
|
226
|
+
- lib
|
|
227
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
|
+
requirements:
|
|
229
|
+
- - ">="
|
|
230
|
+
- !ruby/object:Gem::Version
|
|
231
|
+
version: '0'
|
|
232
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
|
+
requirements:
|
|
234
|
+
- - ">="
|
|
235
|
+
- !ruby/object:Gem::Version
|
|
236
|
+
version: '0'
|
|
237
|
+
requirements: []
|
|
238
|
+
rubyforge_project:
|
|
239
|
+
rubygems_version: 2.4.8
|
|
240
|
+
signing_key:
|
|
241
|
+
specification_version: 4
|
|
242
|
+
summary: Ruby based CLI for accessing veracode's api
|
|
243
|
+
test_files: []
|