chelsea 0.0.22 → 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e8f55973cc277e40b428bd4024d57ee8faeb9497a9533c5325c4992f347e497
4
- data.tar.gz: 4e131ffd1c73531aaa2e03ada3a7e0c580fae8ffc3c98c5e3db4bc91ee55f899
3
+ metadata.gz: 0f179d743f4810498f2e0edbe787038e2caed8e43af7279c39bf309860a568ae
4
+ data.tar.gz: b20643fbaa0bbc56073a53575b4d3d5ba2d1b4f5b8b1e996dcdc373e2a2bd997
5
5
  SHA512:
6
- metadata.gz: 68126c4c9fa51ffb7e74402eb6649fe4bca546959d03c28e0c3a028fd36e6912d4ceabe87b6ad7688e2a68a200df05cecc188e4f512fca1b31f823b5ff20f977
7
- data.tar.gz: 02e554ba6e20ecea0f5027abf8c72feefa272f1336e458997bbae14000fceacefc14f0237ac78c956328d573f27466455a926c57b351f718de8011d03b3bcab3
6
+ metadata.gz: b44c830f8e38ba6693babade3cb1da853baf545a6839aa79bea41a5821712cf055737e8af349c1c9aa9653bb09c5faa1cad0660ec3806f0add68418dadd36f54
7
+ data.tar.gz: ec6ebcd7e0ac9fb7ebb30349c824187cfc06390fabd40a76a39c4c622a6801c513c5446f89dc3422f703e15cab214a3b1fb72ff7acd4f7ef6e249a27c8331b6e
@@ -35,7 +35,9 @@ jobs:
35
35
  - chelsea-bundle-v2-
36
36
  - run:
37
37
  name: Bundle Install
38
- command: bundle check --path vendor/bundle || bundle install
38
+ command: |
39
+ bundle config set --local path 'vendor/bundle'
40
+ bundle check || bundle install
39
41
  - save_cache:
40
42
  key: chelsea-bundle-v2-{{ checksum "Gemfile.lock" }}
41
43
  paths:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chelsea (0.0.17)
4
+ chelsea (0.0.26)
5
5
  bundler (>= 1.2.0, < 3)
6
6
  ox (~> 2.13.2)
7
7
  pastel (~> 0.7.2)
@@ -31,7 +31,7 @@ GEM
31
31
  mime-types-data (3.2020.0512)
32
32
  necromancer (0.6.0)
33
33
  netrc (0.11.0)
34
- ox (2.13.2)
34
+ ox (2.13.4)
35
35
  pastel (0.7.4)
36
36
  equatable (~> 0.6)
37
37
  tty-color (~> 0.5)
@@ -57,16 +57,16 @@ GEM
57
57
  rspec_junit_formatter (0.4.1)
58
58
  rspec-core (>= 2, < 4, != 2.12.0)
59
59
  safe_yaml (1.0.5)
60
- slop (4.8.1)
60
+ slop (4.8.2)
61
61
  strings (0.1.8)
62
62
  strings-ansi (~> 0.1)
63
63
  unicode-display_width (~> 1.5)
64
64
  unicode_utils (~> 1.4)
65
65
  strings-ansi (0.2.0)
66
- tty-color (0.5.1)
66
+ tty-color (0.5.2)
67
67
  tty-cursor (0.7.1)
68
68
  tty-font (0.5.0)
69
- tty-screen (0.8.0)
69
+ tty-screen (0.8.1)
70
70
  tty-spinner (0.9.3)
71
71
  tty-cursor (~> 0.7)
72
72
  tty-table (0.11.0)
data/README.md CHANGED
@@ -50,7 +50,7 @@ usage: /usr/local/bin/chelsea [options]
50
50
  -iu, --iquser Specify the IQ username
51
51
  -it, --iqpass Specify the IQ auth token
52
52
  -w, --whitelist Set path to vulnerability whitelist file
53
- -v, --verbose Make chelsea only output vulnerable third party dependencies for text output (default: true)
53
+ -v, --verbose For text format, list dependencies, their reverse dependencies (what brought them in to your project), and if they are vulnerable. (default: false)
54
54
  -t, --format Choose what type of format you want your report in (default: text) (options: text, json, xml)
55
55
  -b, --iq Use Nexus IQ Server to audit your project
56
56
  -s, --stage Specify Nexus IQ Stage (default: build) (options: develop, build, stage-release, release, operate)
@@ -135,9 +135,45 @@ Report URL: http://localhost:8070/ui/links/application/testapp/report/0e0f469269
135
135
 
136
136
  ## Development
137
137
 
138
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
138
+ We suggest using [rbenv](https://github.com/rbenv/rbenv) to setup a reliable ruby development environment.
139
139
 
140
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
140
+ Follow the [installation steps](https://github.com/rbenv/rbenv#installation).
141
+ For macos (10.15.7), there was a problem with step 2, with: `$ rbenv init`. The command
142
+ printed suggested editing `~/.bashrc`; however, this did not work in our case (even after an OS reboot),
143
+ and we had to instead edit `~/bash_profile`. To sanity check your installation, you should see the
144
+ `.rbenv` directory early in your PATH, e.g.:
145
+ ```
146
+ $ echo $PATH
147
+ /Users/<username>/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:...
148
+ ```
149
+
150
+ We are using ruby version 2.6.6, but newer versions should also work.
151
+ ```
152
+ rbenv install 2.6.6
153
+ ```
154
+
155
+ Install `bundler`:
156
+ ```
157
+ gem install bundler
158
+ ```
159
+
160
+ Install dependencies:
161
+ ```
162
+ bundle install
163
+ ```
164
+
165
+ Run tests:
166
+ ```
167
+ bundle exec rspec
168
+ ```
169
+
170
+ To install this gem onto your local machine, run `bundle exec rake install`. To manually release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
171
+
172
+ ### Release Process
173
+
174
+ Chelsea is automatically released after a commit to the `master` branch.
175
+
176
+ To avoid performing a release after a commit to the `master` branch, be sure your commit message includes `[skip ci] `.
141
177
 
142
178
  ## Why Chelsea?
143
179
 
@@ -0,0 +1,79 @@
1
+ <!--
2
+
3
+ Copyright (c) 2011-present Sonatype, Inc. All rights reserved.
4
+ Includes the third-party code listed at http://links.sonatype.com/products/clm/attributions.
5
+ "Sonatype" is a trademark of Sonatype, Inc.
6
+
7
+ -->
8
+
9
+ # Reporting Security Vulnerabilities
10
+
11
+ ## When to report
12
+
13
+ First check
14
+ [Important advisories of known security vulnerabilities in Sonatype products](https://support.sonatype.com/hc/en-us/sections/203012668-Security-Advisories)
15
+ to see if this has been previously reported.
16
+
17
+ ## How to report
18
+
19
+ Please email reports regarding security related issues you find to [mailto:security@sonatype.com](security@sonatype.com).
20
+
21
+ Use our public key below to keep your message safe.
22
+
23
+ ## What to include
24
+
25
+ Please use a descriptive subject line in your email report.
26
+
27
+ Your name and/or affiliation.
28
+
29
+ A detailed technical description of the vulnerability, attack scenario and where
30
+ possible, how we can reproduce your findings.
31
+
32
+ Provide us with a secure way to respond.
33
+
34
+ ## What to expect
35
+
36
+ Your email will be acknowledged within 1 - 2 business days, and you'll receive a
37
+ more detailed response to your email within 7 business days.
38
+
39
+ We ask that everyone please follow responsible disclosure practices and allow
40
+ time for us to release a fix prior to public release.
41
+
42
+ Once an issue is reported, Sonatype uses the following disclosure process:
43
+
44
+ When a report is received, we confirm the issue and determine its severity.
45
+
46
+ If third-party services or software require mitigation before publication, those
47
+ projects will be notified.
48
+
49
+ ## Our public key
50
+
51
+ ```console
52
+ -----BEGIN PUBLIC KEY BLOCK-----
53
+ mQENBFF+a9ABCADQWSAAU7w9i71Zn3TQ6k7lT9x57cRdtX7V709oeN/c/1it+gCw
54
+ onmmCyf4ypor6XcPSOasp/x0s3hVuf6YfMbI0tSwJUWWihrmoPGIXtmiSOotQE0Q
55
+ Sav41xs3YyI9LzQB4ngZR/nhp4YhioD1dVorD6LGXk08rvl2ikoqHwTagbEXZJY7
56
+ 3VYhW6JHbZTLwCsfyg6uaSYF1qXfUxHPOiHYKNbhK/tM3giX+9ld/7xi+9f4zEFQ
57
+ eX9wcRTdgdDOAqDOK7MV30KXagSqvW0MgEYtKX6q4KjjRzBYjkiTdFW/yMXub/Bs
58
+ 5UckxHTCuAmvpr5J0HIUeLtXi1QCkijyn8HJABEBAAG0KVNvbmF0eXBlIFNlY3Vy
59
+ aXR5IDxzZWN1cml0eUBzb25hdHlwZS5jb20+iQE4BBMBAgAiBQJRfmvQAhsDBgsJ
60
+ CAcDAgYVCAI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bnf60ZIGgrRbAP
76
+ DU1XMdIrmqmhEEQcXMp4CeflDMksOmaIeAUkZY7eddnXMwQDJTnz5ziCal+1r0R3
77
+ dh0XISRG0NkiLEXeGkrs7Sn7BAAsTsaH/1zU6YbvoWlMlHYT6EarFQ== =sFGt
78
+ -----END PUBLIC KEY BLOCK-----
79
+ ```
@@ -31,7 +31,7 @@ opts =
31
31
  o.string '-iu', '--iquser', 'Specify the IQ username', default: 'admin'
32
32
  o.string '-it', '--iqpass', 'Specify the IQ auth token', default: 'admin123'
33
33
  o.string '-w', '--whitelist', 'Set path to vulnerability whitelist file'
34
- o.bool '-v', '--verbose', 'Make chelsea only output vulnerable third party dependencies for text output (default: true)', default: false
34
+ o.bool '-v', '--verbose', 'For text format, list dependencies, their reverse dependencies (what brought them in to your project), and if they are vulnerable. (default: false)', default: false
35
35
  o.string '-t', '--format', 'Choose what type of format you want your report in (default: text) (options: text, json, xml)', default: 'text'
36
36
  o.bool '-b', '--iq', 'Use Nexus IQ Server to audit your project'
37
37
  o.string '-s', '--stage', 'Specify Nexus IQ Stage (default: build) (options: develop, build, stage-release, release, operate)', default: 'build'
@@ -38,5 +38,4 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
39
39
  spec.add_development_dependency "webmock", "~> 3.8.3"
40
40
  spec.add_development_dependency "byebug", "~> 11.1.2"
41
- spec.add_development_dependency 'pry'
42
41
  end
@@ -39,15 +39,19 @@ module Chelsea
39
39
  _set_config # move to init
40
40
  elsif @opts.clear?
41
41
  require_relative 'db'
42
- Chelsea::DB.new().clear_cache
42
+ Chelsea::DB.new.clear_cache
43
43
  puts "OSS Index cache cleared"
44
44
  elsif @opts.file? && @opts.iq?
45
45
  dependencies = _process_file_iq
46
46
  _submit_sbom(dependencies)
47
+ elsif !@opts.file? && @opts.iq?
48
+ abort "Missing the --file argument. It is required with the --iq argument."
47
49
  elsif @opts.file?
48
50
  _process_file
49
51
  elsif @opts.help? # quit on opts.help earlier
50
52
  puts _cli_flags # this doesn't exist
53
+ else
54
+ abort "Missing arguments! Chelsea did nothing. Try providing the --file <Gemfile.lock> argument."
51
55
  end
52
56
  end
53
57
 
@@ -73,7 +77,26 @@ module Chelsea
73
77
 
74
78
  return unless status_url
75
79
 
76
- iq.poll_status(status_url)
80
+ msg, color, exit_code = iq.poll_status(status_url)
81
+ show_status(msg, color)
82
+ # this may not be very ruby-esque, but `return exit_code` and `exit_code` didn't result in the desired exit status
83
+ exit exit_code
84
+ end
85
+
86
+ def show_status(msg, color)
87
+ case color
88
+ when Chelsea::IQClient::COLOR_FAILURE
89
+ puts @pastel.red.bold(msg)
90
+ when Chelsea::IQClient::COLOR_WARNING
91
+ # want yellow, but that doesn't print
92
+ # puts @pastel.color.bold(msg, color)
93
+ puts @pastel.blue.blue(msg)
94
+ when Chelsea::IQClient::COLOR_NONE
95
+ # want yellow, but that doesn't print
96
+ puts @pastel.green.bold(msg)
97
+ else
98
+ puts @pastel.bold(msg)
99
+ end
77
100
  end
78
101
 
79
102
  def _process_file
@@ -17,6 +17,7 @@
17
17
  require 'rest-client'
18
18
  require 'json'
19
19
  require 'pastel'
20
+ require 'uri'
20
21
 
21
22
  require_relative 'spinner'
22
23
 
@@ -31,6 +32,7 @@ module Chelsea
31
32
  internal_application_id: '',
32
33
  stage: 'build'
33
34
  }
35
+
34
36
  def initialize(options: DEFAULT_OPTIONS)
35
37
  @options = options
36
38
  @pastel = Pastel.new
@@ -46,12 +48,12 @@ module Chelsea
46
48
  password: @options[:auth_token]
47
49
  )
48
50
  res = resource.post sbom.to_s, _headers.merge(content_type: 'application/xml')
49
- unless res.code != 202
50
- spin.success("...done.")
51
- status_url(res)
52
- else
51
+ if res.code != 202
53
52
  spin.stop('...request failed.')
54
53
  nil
54
+ else
55
+ spin.success("...done.")
56
+ status_url(res)
55
57
  end
56
58
  end
57
59
 
@@ -67,8 +69,7 @@ module Chelsea
67
69
  res = _poll_iq_server(url)
68
70
  if res.code == 200
69
71
  spin.success("...done.")
70
- _handle_response(res)
71
- break
72
+ return _handle_response(res)
72
73
  end
73
74
  rescue
74
75
  sleep(1)
@@ -76,18 +77,39 @@ module Chelsea
76
77
  end
77
78
  end
78
79
 
80
+ # colors to use when printing message
81
+ COLOR_FAILURE = 31
82
+ COLOR_WARNING = 33 # want yellow, but doesn't appear to print
83
+ COLOR_NONE = 32
84
+ # Known policy actions
85
+ POLICY_ACTION_FAILURE = 'Failure'
86
+ POLICY_ACTION_WARNING = 'Warning'
87
+ POLICY_ACTION_NONE = 'None'
88
+
79
89
  private
80
90
 
81
91
  def _handle_response(res)
82
92
  res = JSON.parse(res.body)
83
- unless res['policyAction'] == 'Failure'
84
- puts @pastel.white.bold("Hi! Chelsea here, no policy violations for this audit!")
85
- puts @pastel.white.bold("Report URL: #{res['reportHtmlUrl']}")
86
- exit 0
93
+ # get absolute report url
94
+ absolute_report_html_url = URI.join(@options[:server_url], res['reportHtmlUrl'])
95
+
96
+ case res['policyAction']
97
+ when POLICY_ACTION_FAILURE
98
+ return "Hi! Chelsea here, you have some policy violations to clean up!"\
99
+ "\nReport URL: #{absolute_report_html_url}",
100
+ COLOR_FAILURE, 1
101
+ when POLICY_ACTION_WARNING
102
+ return "Hi! Chelsea here, you have some policy warnings to peck at!"\
103
+ "\nReport URL: #{absolute_report_html_url}",
104
+ COLOR_WARNING, 0
105
+ when POLICY_ACTION_NONE
106
+ return "Hi! Chelsea here, no policy violations for this audit!"\
107
+ "\nReport URL: #{absolute_report_html_url}",
108
+ COLOR_NONE, 0
87
109
  else
88
- puts @pastel.red.bold("Hi! Chelsea here, you have some policy violations to clean up!")
89
- puts @pastel.red.bold("Report URL: #{res['reportHtmlUrl']}")
90
- exit 1
110
+ return "Hi! Chelsea here, no policy violations for this audit, but unknown policy action!"\
111
+ "\nReport URL: #{absolute_report_html_url}",
112
+ COLOR_FAILURE, 1
91
113
  end
92
114
  end
93
115
 
@@ -141,7 +163,15 @@ module Chelsea
141
163
  password: @options[:auth_token]
142
164
  )
143
165
  res = resource.get _headers
166
+ if res.code != 200
167
+ puts "failed to get internal application id for IQ application id: #{@options[:public_application_id]}. response status: #{res.code}"
168
+ return
169
+ end
144
170
  body = JSON.parse(res)
171
+ if body['applications'].empty?
172
+ puts "failed to get internal application id for IQ application id: #{@options[:public_application_id]}"
173
+ return
174
+ end
145
175
  body['applications'][0]['id']
146
176
  end
147
177
 
@@ -19,7 +19,7 @@ require 'pastel'
19
19
 
20
20
  module Chelsea
21
21
  class Spinner
22
- def initialize()
22
+ def initialize
23
23
  @pastel = Pastel.new
24
24
  end
25
25
 
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Chelsea
18
- VERSION = '0.0.22'.freeze
18
+ VERSION = '0.0.27'.freeze
19
19
  end
@@ -9,4 +9,5 @@
9
9
  <exclude>src/chelsea.gemspec</exclude>
10
10
  <exclude>src/CODE_OF_CONDUCT.md</exclude>
11
11
  <exclude>src/CONTRIBUTORS.md</exclude>
12
+ <exclude>src/SECURITY.md</exclude>
12
13
  </excludes>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chelsea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allister Beharry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-font
@@ -198,27 +198,12 @@ dependencies:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
200
  version: 11.1.2
201
- - !ruby/object:Gem::Dependency
202
- name: pry
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- version: '0'
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - ">="
213
- - !ruby/object:Gem::Version
214
- version: '0'
215
201
  description:
216
202
  email:
217
203
  - allister.beharry@gmail.com
218
204
  executables:
219
205
  - chelsea
220
206
  - console
221
- - setup
222
207
  extensions: []
223
208
  extra_rdoc_files: []
224
209
  files:
@@ -242,9 +227,9 @@ files:
242
227
  - LICENSE
243
228
  - README.md
244
229
  - Rakefile
230
+ - SECURITY.md
245
231
  - bin/chelsea
246
232
  - bin/console
247
- - bin/setup
248
233
  - chelsea
249
234
  - chelsea.gemspec
250
235
  - docs/images/chelsea.png
data/bin/setup DELETED
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Copyright 2019-Present Sonatype Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- set -euo pipefail
19
- IFS=$'\n\t'
20
- set -vx
21
-
22
- bundle install
23
-
24
- # Do any other automated setup that you need to do here