chelsea 0.0.16 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require "bundler/gem_tasks"
2
18
  require "rspec/core/rake_task"
3
19
 
@@ -1,4 +1,20 @@
1
1
  #!/usr/bin/env ruby
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
+
2
18
  # frozen_string_literal: true
3
19
  require_relative "../lib/chelsea"
4
20
  require 'slop'
@@ -15,7 +31,7 @@ opts =
15
31
  o.string '-iu', '--iquser', 'Specify the IQ username', default: 'admin'
16
32
  o.string '-it', '--iqpass', 'Specify the IQ auth token', default: 'admin123'
17
33
  o.string '-w', '--whitelist', 'Set path to vulnerability whitelist file'
18
- o.bool '-q', '--quiet', 'Make chelsea only output vulnerable third party dependencies for text output (default: false)', default: false
34
+ o.bool '-v', '--verbose', 'Make chelsea only output vulnerable third party dependencies for text output (default: true)', default: false
19
35
  o.string '-t', '--format', 'Choose what type of format you want your report in (default: text) (options: text, json, xml)', default: 'text'
20
36
  o.bool '-b', '--iq', 'Use Nexus IQ Server to audit your project'
21
37
  o.on '--version', 'Print the version' do
@@ -36,4 +52,4 @@ if opts.arguments.count.positive?
36
52
  exit 1
37
53
  end
38
54
 
39
- Chelsea::CLI.new(opts).process!
55
+ Chelsea::CLI.new(opts).process!
@@ -1,14 +1,23 @@
1
1
  #!/usr/bin/env ruby
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
+
2
18
 
3
19
  require "bundler/setup"
4
20
  require "chelsea"
5
21
 
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
22
  require "irb"
14
23
  IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,4 +1,20 @@
1
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
+
2
18
  set -euo pipefail
3
19
  IFS=$'\n\t'
4
20
  set -vx
data/chelsea CHANGED
@@ -1,2 +1,18 @@
1
1
  #!/bin/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
+
2
18
  ruby ./bin/chelsea "$@"
@@ -5,7 +5,7 @@ require "chelsea/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "chelsea"
8
- spec.license = "MIT"
8
+ spec.license = "Apache-2.0"
9
9
  spec.version = Chelsea::VERSION
10
10
  spec.authors = ["Allister Beharry"]
11
11
  spec.email = ["allister.beharry@gmail.com"]
@@ -17,17 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata["source_code_uri"] = "https://github.com/sonatype-nexus-community/chelsea"
18
18
  spec.metadata["changelog_uri"] = "https://github.com/sonatype-nexus-community/chelsea/CHANGELOG"
19
19
 
20
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
21
- # to allow pushing to a single host or delete this section to allow pushing to any host.
22
- # if spec.respond_to?(:metadata)
23
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
24
- # else
25
- # raise "RubyGems 2.0 or newer is required to protect against " \
26
- # "public gem pushes."
27
- # end
28
-
29
- # Specify which files should be added to the gem when it is released.
30
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
20
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
22
  end
@@ -42,10 +31,12 @@ Gem::Specification.new do |spec|
42
31
  spec.add_dependency "rest-client", "~> 2.0.2"
43
32
  spec.add_dependency "bundler", ">= 1.2.0", "< 3"
44
33
  spec.add_dependency "ox", "~> 2.13.2"
34
+ spec.add_dependency "tty-table", "~> 0.11.0"
45
35
 
46
36
  spec.add_development_dependency "rake", "~> 12.3"
47
37
  spec.add_development_dependency "rspec", "~> 3.0"
48
38
  spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
49
39
  spec.add_development_dependency "webmock", "~> 3.8.3"
50
40
  spec.add_development_dependency "byebug", "~> 11.1.2"
41
+ spec.add_development_dependency 'pry'
51
42
  end
Binary file
@@ -0,0 +1,13 @@
1
+ Copyright 2019-Present Sonatype Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  # frozen_string_literal: true
2
18
 
3
19
  # Lazy loading
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  # frozen_string_literal: true
2
18
 
3
19
  require 'securerandom'
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require 'slop'
2
18
  require 'pastel'
3
19
  require 'tty-font'
@@ -62,7 +78,7 @@ module Chelsea
62
78
  def _process_file
63
79
  gems = Chelsea::Gems.new(
64
80
  file: @opts[:file],
65
- quiet: @opts[:quiet],
81
+ verbose: @opts[:verbose],
66
82
  options: @opts
67
83
  )
68
84
  gems.execute ? (exit 1) : (exit 0)
@@ -71,7 +87,7 @@ module Chelsea
71
87
  def _process_file_iq
72
88
  gems = Chelsea::Gems.new(
73
89
  file: @opts[:file],
74
- quiet: @opts[:quiet],
90
+ verbose: @opts[:verbose],
75
91
  options: @opts
76
92
  )
77
93
  gems.collect_iq
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require 'yaml'
2
18
  require_relative 'oss_index'
3
19
 
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require 'pstore'
2
18
 
3
19
  module Chelsea
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  module Chelsea
2
18
  class DependencyException < StandardError
3
19
  def initialize(msg="This is a custom exception", exception_type="custom")
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require 'bundler'
2
18
  require 'bundler/lockfile_parser'
3
19
  require 'rubygems'
@@ -7,8 +23,8 @@ require 'rest-client'
7
23
 
8
24
  module Chelsea
9
25
  class Deps
10
- def initialize(path:, quiet: false)
11
- @quiet = quiet
26
+ def initialize(path:, verbose: false)
27
+ @verbose = verbose
12
28
  ENV['BUNDLE_GEMFILE'] = File.expand_path(path).chomp('.lock')
13
29
  @lockfile = Bundler::LockfileParser.new(File.read(path))
14
30
  end
@@ -41,7 +57,7 @@ module Chelsea
41
57
  reverse
42
58
  .reverse_dependencies(@lockfile.specs)
43
59
  .to_h
44
- .transform_values do |reverse_dep|
60
+ .transform_values! do |reverse_dep|
45
61
  reverse_dep.select do |name, _dep, _req, _|
46
62
  spec_names.include?(name.split('-')[0])
47
63
  end
@@ -1,19 +1,35 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require_relative 'json'
2
18
  require_relative 'xml'
3
19
  require_relative 'text'
4
20
 
5
21
  # Factory for formatting dependencies
6
22
  class FormatterFactory
7
- def get_formatter(format: 'text', quiet: false)
23
+ def get_formatter(format: 'text', verbose:)
8
24
  case format
9
25
  when 'text'
10
- Chelsea::TextFormatter.new quiet: quiet
26
+ Chelsea::TextFormatter.new verbose: verbose
11
27
  when 'json'
12
- Chelsea::JsonFormatter.new quiet: quiet
28
+ Chelsea::JsonFormatter.new verbose: verbose
13
29
  when 'xml'
14
- Chelsea::XMLFormatter.new quiet: quiet
30
+ Chelsea::XMLFormatter.new verbose: verbose
15
31
  else
16
- Chelsea::TextFormatter.new quiet: quiet
32
+ Chelsea::TextFormatter.new verbose: verbose
17
33
  end
18
34
  end
19
35
  end
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  class Formatter
2
18
  def initialize
3
19
  @pastel = Pastel.new
@@ -1,3 +1,19 @@
1
+ #
2
+ # Copyright 2019-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
1
17
  require 'json'
2
18
  require_relative 'formatter'
3
19