diffend-monitor 0.2.28 → 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: 9042954f4e7d0e9dc7aa2e8553711fe078409db7ebaf4371a5f1a35de587ea5c
4
- data.tar.gz: 2887faa65020fbd0b37b049c3338f540f662ca78869d22636f692d1df3b9447a
3
+ metadata.gz: f1c739e4cbf06a1ef55576728e684ab0bb639b4889748faa1d688ef1406024c0
4
+ data.tar.gz: fe58c9466fe5a532d445e8b5a0a8948b87489fbc9d49974aabb272bfd0ab14ed
5
5
  SHA512:
6
- metadata.gz: f828ca7415cb0713688f1b90f9d806ec3f5369b8cf3f34da097b919dcdcbae13dc45f52f0f248af10cdf754ad302f4c9e3a4435d9b319b258e1e0ca10433b7eb
7
- data.tar.gz: a3fbb0e11aff1cabe4e4f443a069b8209854b651c37eff3a794a4b01bb6e92651c1d0a8c6a897a74b68f5bedf41ab3aaa122283977a68e4744e93bdb71b12ad4
6
+ metadata.gz: e44b5cd37e26197b11cb67dd3703984949a15d372b0623c2cc38ef346b47d14aad76ce1956d093304b3cc5cc6f6f952b7b45bce2808afed2fee76fbc124f0f9c
7
+ data.tar.gz: 28cb79ac18dc1aad9d535ab80d7c665aadea70cc77b35e6a04c63196a6844c7c62418a28bbdaa4a0e3b7c06480d36b4334fb9ad8023bf512faf1b51b74bdc421
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
@@ -2,6 +2,36 @@
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
+
32
+ ## [0.2.29] (2020-09-21)
33
+ - fix command reporting on jruby ([#48](https://github.com/diffend-io/diffend-ruby/pull/48))
34
+
5
35
  ## [0.2.28] (2020-09-19)
6
36
  - start `Diffend::Monitor` only if not in development or test ([#44](https://github.com/diffend-io/diffend-ruby/pull/44))
7
37
  - better host command expose ([#45](https://github.com/diffend-io/diffend-ruby/pull/45))
@@ -64,7 +94,13 @@
64
94
 
65
95
  - initial release
66
96
 
67
- [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.28...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
103
+ [0.2.29]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.28...v0.2.29
68
104
  [0.2.28]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.27...v0.2.28
69
105
  [0.2.27]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.26...v0.2.27
70
106
  [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,36 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diffend (0.2.28)
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
 
@@ -1,25 +1,25 @@
1
1
  -----BEGIN CERTIFICATE-----
2
2
  MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhtYWNp
3
- ZWovREM9bWVuc2ZlbGQvREM9cGwwHhcNMjAwODExMDkxNTM3WhcNMjEwODExMDkx
4
- NTM3WjAjMSEwHwYDVQQDDBhtYWNpZWovREM9bWVuc2ZlbGQvREM9cGwwggGiMA0G
5
- CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDCpXsCgmINb6lHBXXBdyrgsBPSxC4/
6
- 2H+weJ6L9CruTiv2+2/ZkQGtnLcDgrD14rdLIHK7t0o3EKYlDT5GhD/XUVhI15JE
7
- N7IqnPUgexe1fbZArwQ51afxz2AmPQN2BkB2oeQHXxnSWUGMhvcEZpfbxCCJH26w
8
- hS0Ccsma8yxA6hSlGVhFVDuCr7c2L1di6cK2CtIDpfDaWqnVNJEwBYHIxrCoWK5g
9
- sIGekVt/admS9gRhIMaIBg+Mshth5/DEyWO2QjteTodItlxfTctrfmiAl8X8T5JP
10
- VXeLp5SSOJ5JXE80nShMJp3RFnGw5fqjX/ffjtISYh78/By4xF3a25HdWH9+qO2Z
11
- tx0wSGc9/4gqNM0APQnjN/4YXrGZ4IeSjtE+OrrX07l0TiyikzSLFOkZC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PtJ4E/UUKnKaWKqGbjrjHJ0MuShYzHkodox5IOiCXIQg+1+YSzfXUV6WEK
23
+ KJG/fhg1JV5vVDdVy6x+tv5SQ5ctU0feCsVfESi3rE3zRd+nvzE9HcZ5aXeL1UtJ
24
+ nT5Xrioegu2w1jPyVEgyZgTZC5rvD0nNS5sFNQ==
25
25
  -----END CERTIFICATE-----
@@ -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