diffend 0.2.29 → 0.2.34

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: 9c978cd44ce6f9c52de63870eea0ccf2534b851a1034318447d60afb08998479
4
- data.tar.gz: 220475fd0f2f47b16ebd3882cd602e45475d0f1dc92cb9cdc21f41996940c305
3
+ metadata.gz: cc45142bb5d879748312afda05037afb9e404bedd0eef6ac22b62222b4877a81
4
+ data.tar.gz: 8fdefc71c114956828319e7b1add646bade02b56447dedb900e22161eec51611
5
5
  SHA512:
6
- metadata.gz: eb0966e3eecffe872a833ad135004ff177fa3d8e1930dec40533fc62fc71af4047f075512b6df9cb1f898d3654ce2303ce9fcee17c55c1dd1d212da3f27d249d
7
- data.tar.gz: 7d2baad903c1425fdfe8f9f64f2cd741f9de01a504333307e82bab6066d36b968177549d23846e3bca66a87532687058ba39c78b802e8cd3bfc0f3406820c644
6
+ metadata.gz: 359a68adcd4a1fd428510a2f9f37469fefca76b4fdd0e02415bf09b1a99b26d0080bb755e98a4a48c8be840f4dbdf13c6f50ed77af3dd2093f321a560835bdc6
7
+ data.tar.gz: a5dcef6929e7d63c2b66e237d790d51de2b17c12461ba3a91b3d4160decb35f79c11111bd4e5322f5e5a4ce748e32d0dd3abb993b7d77efc37792f413100e57a
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
@@ -2,6 +2,33 @@
2
2
 
3
3
  ## [Unreleased][master]
4
4
 
5
+ ## [0.2.34] (2020-10-25)
6
+ - handle `Bundler::GitError` ([#72](https://github.com/diffend-io/diffend-ruby/pull/72))
7
+
8
+ ## [0.2.33] (2020-10-25)
9
+ - fix an exception when configuration file is missing ([#65](https://github.com/diffend-io/diffend-ruby/pull/65))
10
+ - silently exit when configuration file is missing in `Diffend::Monitor` ([#66](https://github.com/diffend-io/diffend-ruby/pull/66))
11
+ - introduce default config ([#67](https://github.com/diffend-io/diffend-ruby/pull/67))
12
+ - handle `SocketError` ([#68](https://github.com/diffend-io/diffend-ruby/pull/68))
13
+
14
+ ## [0.2.32] (2020-10-02)
15
+ - fix how we build platform from `Gem::Platform` ([#56](https://github.com/diffend-io/diffend-ruby/pull/56))
16
+ - introduce `Diffend::LatestVersion` ([#57](https://github.com/diffend-io/diffend-ruby/pull/57))
17
+ - refactor `Diffend::Config` ([#58](https://github.com/diffend-io/diffend-ruby/pull/58))
18
+ - set command in `Diffend::Config` ([#59](https://github.com/diffend-io/diffend-ruby/pull/59))
19
+ - introduce `Diffend::Logger` ([#60](https://github.com/diffend-io/diffend-ruby/pull/60))
20
+ - set severity to `FATAL` in `Diffend::Monitor` ([#61](https://github.com/diffend-io/diffend-ruby/pull/61))
21
+ - handle `Bundler::VersionConflict` ([#62](https://github.com/diffend-io/diffend-ruby/pull/62))
22
+
23
+ ## [0.2.31] (2020-09-24)
24
+ - change request timeout to 15 seconds ([#53](https://github.com/diffend-io/diffend-ruby/pull/53))
25
+ - report request issues as warnings ([#54](https://github.com/diffend-io/diffend-ruby/pull/54))
26
+
27
+ ## [0.2.30] (2020-09-21)
28
+ - handle dependencies resolve issues ([#51](https://github.com/diffend-io/diffend-ruby/pull/51))
29
+ - better detection when to start `Diffend::Monitor` ([#50](https://github.com/diffend-io/diffend-ruby/pull/50))
30
+ - cleanup structure ([#47](https://github.com/diffend-io/diffend-ruby/pull/47))
31
+
5
32
  ## [0.2.29] (2020-09-21)
6
33
  - fix command reporting on jruby ([#48](https://github.com/diffend-io/diffend-ruby/pull/48))
7
34
 
@@ -67,7 +94,12 @@
67
94
 
68
95
  - initial release
69
96
 
70
- [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.29...HEAD
97
+ [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.34...HEAD
98
+ [0.2.34]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.33...v0.2.34
99
+ [0.2.33]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.32...v0.2.33
100
+ [0.2.32]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.31...v0.2.32
101
+ [0.2.31]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.30...v0.2.31
102
+ [0.2.30]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.29...v0.2.30
71
103
  [0.2.29]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.28...v0.2.29
72
104
  [0.2.28]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.27...v0.2.28
73
105
  [0.2.27]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.26...v0.2.27
data/Gemfile CHANGED
@@ -7,7 +7,5 @@ plugin 'diffend'
7
7
  gemspec
8
8
 
9
9
  group :development, :test do
10
- gem 'byebug', platform: :ruby
11
- gem 'pry', platform: :jruby
12
10
  gem 'rspec'
13
11
  end
@@ -1,36 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diffend (0.2.29)
4
+ diffend (0.2.34)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- byebug (11.1.3)
10
- coderay (1.1.3)
11
9
  diff-lcs (1.4.4)
12
- ffi (1.13.1-java)
13
- method_source (1.0.0)
14
- pry (0.13.1-java)
15
- coderay (~> 1.1)
16
- method_source (~> 1.0)
17
- spoon (~> 0.0)
18
10
  rake (13.0.1)
19
11
  rspec (3.9.0)
20
12
  rspec-core (~> 3.9.0)
21
13
  rspec-expectations (~> 3.9.0)
22
14
  rspec-mocks (~> 3.9.0)
23
- rspec-core (3.9.2)
15
+ rspec-core (3.9.3)
24
16
  rspec-support (~> 3.9.3)
25
- rspec-expectations (3.9.2)
17
+ rspec-expectations (3.9.4)
26
18
  diff-lcs (>= 1.2.0, < 2.0)
27
19
  rspec-support (~> 3.9.0)
28
20
  rspec-mocks (3.9.1)
29
21
  diff-lcs (>= 1.2.0, < 2.0)
30
22
  rspec-support (~> 3.9.0)
31
- rspec-support (3.9.3)
32
- spoon (0.0.6)
33
- ffi
23
+ rspec-support (3.9.4)
34
24
 
35
25
  PLATFORMS
36
26
  java
@@ -38,9 +28,7 @@ PLATFORMS
38
28
 
39
29
  DEPENDENCIES
40
30
  bundler
41
- byebug
42
31
  diffend!
43
- pry
44
32
  rake
45
33
  rspec
46
34
 
@@ -0,0 +1,6 @@
1
+ project_id: <%= ENV['DIFFEND_PROJECT_ID'] %>
2
+ shareable_id: <%= ENV['DIFFEND_SHAREABLE_ID'] %>
3
+ shareable_key: <%= ENV['DIFFEND_SHAREABLE_KEY'] %>
4
+ env: <%= ENV['DIFFEND_ENV'] || 'development' %>
5
+ ignore_errors: <%= ENV['DIFFEND_IGNORE_ERRORS'] || 'true' %>
6
+ development: <%= ENV['DIFFEND_DEVELOPMENT'] || 'true' %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'diffend'
5
+ require 'diffend/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'diffend'
@@ -11,8 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['contact@diffend.io']
12
12
 
13
13
  spec.summary = 'OSS supply chain security and management platform'
14
- spec.summary = 'OSS supply chain security and management platform.'
15
- spec.homepage = Diffend::HOMEPAGE
14
+ spec.homepage = 'https://diffend.io'
16
15
  spec.license = 'Prosperity Public License'
17
16
 
18
17
  if $PROGRAM_NAME.end_with?('gem')
@@ -1,142 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[
4
- bundler
5
- ].each(&method(:require))
6
-
7
- %w[
8
- build_bundler_definition
9
- errors
10
- config/fetcher
11
- config/file_finder
12
- config/validator
13
- commands
14
- handle_errors/messages
15
- handle_errors/build_exception_payload
16
- handle_errors/display_to_stdout
17
- handle_errors/report
18
- request_object
19
- request
20
- voting
21
- track
22
- ].each { |file| require "diffend/#{file}" }
23
-
24
- %w[
25
- versions/local
26
- versions/remote
27
- ].each { |file| require "diffend/voting/#{file}" }
28
-
29
- # Diffend main namespace
30
3
  module Diffend
31
- # Current plugin version
32
- VERSION = '0.2.29'
33
- # Diffend homepage
34
- HOMEPAGE = 'https://diffend.io'
35
-
36
- class << self
37
- # Registers the plugin and add before install all hook
38
- def register
39
- Bundler::Plugin.add_hook('before-install-all') do |_|
40
- execute
41
- end
42
- end
43
-
44
- # Execute diffend plugin
45
- def execute
46
- return unless enabled?
47
-
48
- verify_version
49
-
50
- config = fetch_config
51
-
52
- Diffend::Voting.call(
53
- command,
54
- config,
55
- Diffend::BuildBundlerDefinition.call(
56
- command,
57
- Bundler.default_gemfile,
58
- Bundler.default_lockfile
59
- )
60
- )
61
- rescue Diffend::Errors::HandledException
62
- return if ENV['DIFFEND_IGNORE_ERRORS'] == 'true'
63
-
64
- exit 255
65
- rescue StandardError => e
66
- Diffend::HandleErrors::Report.call(
67
- exception: e,
68
- config: config,
69
- message: :unhandled_exception,
70
- report: true,
71
- raise_exception: false
72
- )
73
-
74
- return if ENV['DIFFEND_IGNORE_ERRORS'] == 'true'
75
-
76
- exit 255
77
- end
78
-
79
- def verify_version
80
- return if ENV['DIFFEND_DEVELOPMENT'] == 'true'
81
- return if installed_version == VERSION
82
-
83
- build_outdated_version_message(installed_version)
84
- .tap(&Bundler.ui.method(:error))
85
-
86
- exit 2
87
- end
88
-
89
- # @return [String] installed plugin version
90
- def installed_version
91
- Bundler::Plugin
92
- .index
93
- .plugin_path('diffend')
94
- .basename
95
- .to_s
96
- .split('-')
97
- .last
98
- end
99
-
100
- # Checks if plugin is enabled
101
- #
102
- # @return [Boolean] true if enabled, false otherwise
103
- def enabled?
104
- Bundler
105
- .default_gemfile
106
- .read
107
- .split("\n")
108
- .reject(&:empty?)
109
- .map(&:strip)
110
- .select { |line| line.start_with?('plugin') }
111
- .any? { |line| line.include?('diffend') }
112
- end
113
-
114
- # @param version [Hash] installed version
115
- #
116
- # @return [String]
117
- def build_outdated_version_message(version)
118
- <<~MSG
119
- \nYou are running an outdated version (#{version}) of the plugin, which will lead to issues.
120
- \nPlease upgrade to the latest one (#{VERSION}) by executing "rm -rf .bundle/plugin".\n
121
- MSG
122
- end
123
-
124
- # Command that was run with bundle
125
- #
126
- # @return [String]
127
- def command
128
- ARGV.first || Bundler.feature_flag.default_cli_command.to_s
129
- end
130
-
131
- # Fetch diffend config file
132
- #
133
- # @return [OpenStruct, nil] configuration object
134
- #
135
- # @raise [Errors::MissingConfigurationFile] when no config file
136
- def fetch_config
137
- Config::Fetcher.call(
138
- File.expand_path('..', Bundler.bin_path)
139
- )
140
- end
141
- end
142
4
  end
@@ -6,7 +6,7 @@ module Diffend
6
6
  class << self
7
7
  # Build clean instance of bundler definition, as we don't want to pollute the main one
8
8
  #
9
- # @param command [String] bundler command that we are executing
9
+ # @param command [String] command executed via bundler
10
10
  # @param gemfile [String] path to Gemfile
11
11
  # @param lockfile [String] path to Gemfile.lock
12
12
  #
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Diffend
4
+ # Diffend config object
5
+ class Config
6
+ attr_reader :project_id, :shareable_id, :shareable_key, :build_path, :env, :command
7
+
8
+ # Build diffend config object
9
+ #
10
+ # @return [Diffend::Config]
11
+ def initialize(command: nil, severity: nil, build_path: nil)
12
+ @log_level = severity
13
+ build(command, build_path)
14
+ validate
15
+ end
16
+
17
+ def logger
18
+ @logger ||= Diffend::Logger.new(@log_level)
19
+ end
20
+
21
+ def ignore_errors?
22
+ @ignore_errors
23
+ end
24
+
25
+ def development?
26
+ @development
27
+ end
28
+
29
+ # Provides diffend commands endpoint url
30
+ #
31
+ # @return [String]
32
+ def commands_url
33
+ return ENV['DIFFEND_COMMANDS_URL'] if ENV.key?('DIFFEND_COMMANDS_URL')
34
+
35
+ "https://my.diffend.io/api/projects/#{project_id}/bundle/#{command}"
36
+ end
37
+
38
+ # Provides diffend errors endpoint url
39
+ #
40
+ # @return [String]
41
+ def errors_url
42
+ return ENV['DIFFEND_ERRORS_URL'] if ENV.key?('DIFFEND_ERRORS_URL')
43
+
44
+ "https://my.diffend.io/api/projects/#{project_id}/errors"
45
+ end
46
+
47
+ # @param request_id [String]
48
+ #
49
+ # @return [String]
50
+ def track_url(request_id)
51
+ "https://my.diffend.io/api/projects/#{project_id}/bundle/#{request_id}/track"
52
+ end
53
+
54
+ private
55
+
56
+ def build(command, build_path)
57
+ build_path ||= File.expand_path('..', ::Bundler.bin_path)
58
+ hash = Diffend::Configs::Fetcher.call(logger, plugin_path, build_path)
59
+ hash['build_path'] = build_path
60
+ hash['command'] = command || build_command
61
+
62
+ hash.each { |key, value| instance_variable_set(:"@#{key}", value) }
63
+ end
64
+
65
+ def validate
66
+ Diffend::Configs::Validator.call(self)
67
+ end
68
+
69
+ # Command that was run with bundle
70
+ #
71
+ # @return [String]
72
+ def build_command
73
+ ARGV.first || ::Bundler.feature_flag.default_cli_command.to_s
74
+ end
75
+
76
+ def plugin_path
77
+ Pathname.new(File.expand_path('../..', __dir__))
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Diffend
6
+ # Module for all the components related to setting up the config
7
+ module Configs
8
+ # Class responsible for fetching the config from .diffend.yml
9
+ module Fetcher
10
+ class << self
11
+ # @param logger [Diffend::Logger]
12
+ # @param plugin_path [String] path of the plugin
13
+ # @param build_path [String] path of the current build
14
+ #
15
+ # @return [Hash] details from configuration file
16
+ #
17
+ # @example
18
+ # details = Fetcher.new.call('./')
19
+ # details.build_path #=> './'
20
+ def call(logger, plugin_path, build_path)
21
+ build(plugin_path, build_path)
22
+ rescue Errors::MalformedConfigurationFile
23
+ build_malformed_error_message(build_path)
24
+ .tap(&logger.method(:fatal))
25
+
26
+ raise Diffend::Errors::HandledException
27
+ end
28
+
29
+ private
30
+
31
+ # @param plugin_path [String] path of the plugin
32
+ # @param build_path [String] path of the current build
33
+ #
34
+ # @return [OpenStruct] open struct with config details
35
+ def build(plugin_path, build_path)
36
+ default_config = File.join(plugin_path, 'config', 'diffend.yml')
37
+ project_config = File.join(build_path, '.diffend.yml')
38
+
39
+ hash = read_file(default_config)
40
+
41
+ if File.exist?(project_config)
42
+ hash.merge!(read_file(project_config) || {})
43
+ end
44
+
45
+ hash
46
+ end
47
+
48
+ def read_file(path)
49
+ YAML.safe_load(ERB.new(File.read(path)).result)
50
+ rescue Psych::SyntaxError
51
+ raise Errors::MalformedConfigurationFile
52
+ end
53
+
54
+ # @return [String] malformed configuration file message
55
+ def build_malformed_error_message
56
+ <<~MSG
57
+ \nYour Diffend configuration file is malformed.\n
58
+ Please re-setup.\n
59
+ MSG
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end