diffend 0.2.28 → 0.2.33

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: 0c100adca589f5e4e22488ecc8d12a865b2ec8a5bb6be4bf15f3b4bf5d5ad089
4
- data.tar.gz: 8e5820badb850ee24606874e8de80a8e19114a08276f9fca3933a54e4fb825bc
3
+ metadata.gz: ca45ede600a1ba9ef22e538d14f4de5be8c662e7b3c39211e52327fbf99b6f92
4
+ data.tar.gz: 5054f7dfa57e79adb3734e30c6cecaa7865fe3b9c0aef345c146cad49019529f
5
5
  SHA512:
6
- metadata.gz: 70b2798f074676511abc75974db24ee116dcbf9fc87983a4cfc6d9e69246c12b0970c376ced03e08a6fb0a9ba09fa9cd11a3da5d728715c6ec676030bd7ebccd
7
- data.tar.gz: fd130a1283b65d6487bab7323eb2a7d7c9d3db6cea7c777e4c7a023f77e9b0d0ee4078cd38c9228fe18b1555ee9e9ec9efd0fa1033a7c8ed5e19859cb8e11970
6
+ metadata.gz: cede14b22f216cdf7c520d1455676dea8d0a911adf2206d59ba6fc4db8e880b38cd846aeb29cd8e82ec27f13db533442c3853433c7032336879eb7c05d5ddd4c
7
+ data.tar.gz: 8f6e842c2b9557e76e7cf09e9ed62a8a9f251a7caa21cc2cae5a488aae928ae006df9f081429116d8df8e46acbf5c62e7e9f0097875813bcd0b8b75ef57a3b7b
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.33] (2020-10-25)
6
+ - fix an exception when configuration file is missing ([#65](https://github.com/diffend-io/diffend-ruby/pull/65))
7
+ - silently exit when configuration file is missing in `Diffend::Monitor` ([#66](https://github.com/diffend-io/diffend-ruby/pull/66))
8
+ - introduce default config ([#67](https://github.com/diffend-io/diffend-ruby/pull/67))
9
+ - handle `SocketError` ([#68](https://github.com/diffend-io/diffend-ruby/pull/68))
10
+
11
+ ## [0.2.32] (2020-10-02)
12
+ - fix how we build platform from `Gem::Platform` ([#56](https://github.com/diffend-io/diffend-ruby/pull/56))
13
+ - introduce `Diffend::LatestVersion` ([#57](https://github.com/diffend-io/diffend-ruby/pull/57))
14
+ - refactor `Diffend::Config` ([#58](https://github.com/diffend-io/diffend-ruby/pull/58))
15
+ - set command in `Diffend::Config` ([#59](https://github.com/diffend-io/diffend-ruby/pull/59))
16
+ - introduce `Diffend::Logger` ([#60](https://github.com/diffend-io/diffend-ruby/pull/60))
17
+ - set severity to `FATAL` in `Diffend::Monitor` ([#61](https://github.com/diffend-io/diffend-ruby/pull/61))
18
+ - handle `Bundler::VersionConflict` ([#62](https://github.com/diffend-io/diffend-ruby/pull/62))
19
+
20
+ ## [0.2.31] (2020-09-24)
21
+ - change request timeout to 15 seconds ([#53](https://github.com/diffend-io/diffend-ruby/pull/53))
22
+ - report request issues as warnings ([#54](https://github.com/diffend-io/diffend-ruby/pull/54))
23
+
24
+ ## [0.2.30] (2020-09-21)
25
+ - handle dependencies resolve issues ([#51](https://github.com/diffend-io/diffend-ruby/pull/51))
26
+ - better detection when to start `Diffend::Monitor` ([#50](https://github.com/diffend-io/diffend-ruby/pull/50))
27
+ - cleanup structure ([#47](https://github.com/diffend-io/diffend-ruby/pull/47))
28
+
29
+ ## [0.2.29] (2020-09-21)
30
+ - fix command reporting on jruby ([#48](https://github.com/diffend-io/diffend-ruby/pull/48))
31
+
5
32
  ## [0.2.28] (2020-09-19)
6
33
  - start `Diffend::Monitor` only if not in development or test ([#44](https://github.com/diffend-io/diffend-ruby/pull/44))
7
34
  - better host command expose ([#45](https://github.com/diffend-io/diffend-ruby/pull/45))
@@ -64,7 +91,12 @@
64
91
 
65
92
  - initial release
66
93
 
67
- [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.28...HEAD
94
+ [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.33...HEAD
95
+ [0.2.33]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.32...v0.2.33
96
+ [0.2.32]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.31...v0.2.32
97
+ [0.2.31]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.30...v0.2.31
98
+ [0.2.30]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.29...v0.2.30
99
+ [0.2.29]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.28...v0.2.29
68
100
  [0.2.28]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.27...v0.2.28
69
101
  [0.2.27]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.26...v0.2.27
70
102
  [0.2.26]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.25...v0.2.26
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,26 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diffend (0.2.28)
4
+ diffend (0.2.33)
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
17
  rspec-expectations (3.9.2)
26
18
  diff-lcs (>= 1.2.0, < 2.0)
@@ -29,8 +21,6 @@ GEM
29
21
  diff-lcs (>= 1.2.0, < 2.0)
30
22
  rspec-support (~> 3.9.0)
31
23
  rspec-support (3.9.3)
32
- spoon (0.0.6)
33
- ffi
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.28'
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