diffend-monitor 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.coditsu/ci.yml +3 -0
- data/.diffend.yml +3 -0
- data/.github/workflows/ci.yml +64 -0
- data/.gitignore +58 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +75 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.md +57 -0
- data/README.md +25 -0
- data/bin/bundle +114 -0
- data/bin/byebug +29 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/certs/mensfeld.pem +25 -0
- data/certs/tomaszpajor.pem +25 -0
- data/diffend.gemspec +28 -0
- data/lib/diffend.rb +142 -0
- data/lib/diffend/build_bundler_definition.rb +26 -0
- data/lib/diffend/commands.rb +13 -0
- data/lib/diffend/config/fetcher.rb +117 -0
- data/lib/diffend/config/file_finder.rb +38 -0
- data/lib/diffend/config/validator.rb +25 -0
- data/lib/diffend/errors.rb +27 -0
- data/lib/diffend/handle_errors/build_exception_payload.rb +30 -0
- data/lib/diffend/handle_errors/display_to_stdout.rb +17 -0
- data/lib/diffend/handle_errors/messages.rb +29 -0
- data/lib/diffend/handle_errors/report.rb +71 -0
- data/lib/diffend/monitor.rb +28 -0
- data/lib/diffend/request.rb +185 -0
- data/lib/diffend/request_object.rb +6 -0
- data/lib/diffend/track.rb +104 -0
- data/lib/diffend/voting.rb +132 -0
- data/lib/diffend/voting/versions/local.rb +304 -0
- data/lib/diffend/voting/versions/remote.rb +216 -0
- data/plugins.rb +5 -0
- data/scripts/generate_payload_for_file.rb +15 -0
- metadata +138 -0
- metadata.gz.sig +0 -0
data/bin/byebug
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'byebug' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("byebug", "byebug")
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/certs/mensfeld.pem
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIEODCCAqC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Dwzf95efFlGSCFN4t+/dywVIK8
|
23
|
+
9MmF6uCQa1EjK2p8tYT0MnbHrFkoehxdX4VO9y99GAkhZyJNKPYPtyAUFV27sT2V
|
24
|
+
LfCJRk4ifKIN/FUCwDSn8Cz0m6oH265q0p6wdzI6qrWOjP8tGOMBTA==
|
25
|
+
-----END CERTIFICATE-----
|
data/diffend.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'diffend'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'diffend'
|
9
|
+
spec.version = Diffend::VERSION
|
10
|
+
spec.authors = ['Tomasz Pajor']
|
11
|
+
spec.email = ['contact@diffend.io']
|
12
|
+
|
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
|
16
|
+
spec.license = 'Prosperity Public License'
|
17
|
+
|
18
|
+
if $PROGRAM_NAME.end_with?('gem')
|
19
|
+
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.cert_chain = %w[certs/tomaszpajor.pem]
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
24
|
+
spec.require_paths = %w[lib]
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
end
|
data/lib/diffend.rb
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
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
|
+
module Diffend
|
31
|
+
# Current plugin version
|
32
|
+
VERSION = '0.2.27'
|
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
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Builds bundler definition used within the plugin
|
5
|
+
module BuildBundlerDefinition
|
6
|
+
class << self
|
7
|
+
# Build clean instance of bundler definition, as we don't want to pollute the main one
|
8
|
+
#
|
9
|
+
# @param command [String] bundler command that we are executing
|
10
|
+
# @param gemfile [String] path to Gemfile
|
11
|
+
# @param lockfile [String] path to Gemfile.lock
|
12
|
+
#
|
13
|
+
# @return [Bundler::Definition]
|
14
|
+
def call(command, gemfile, lockfile)
|
15
|
+
unlock = command == 'update' ? true : nil
|
16
|
+
|
17
|
+
Bundler.configure
|
18
|
+
Bundler::Fetcher.disable_endpoint = nil
|
19
|
+
|
20
|
+
Bundler::Definition
|
21
|
+
.build(gemfile, lockfile, unlock)
|
22
|
+
.tap(&:validate_runtime!)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Modules grouping supported bundler commands
|
5
|
+
module Commands
|
6
|
+
# Bundler install command
|
7
|
+
INSTALL = 'install'
|
8
|
+
# Bundler update command
|
9
|
+
UPDATE = 'update'
|
10
|
+
# Bundler exec command
|
11
|
+
EXEC = 'exec'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,117 @@
|
|
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 Config
|
8
|
+
# Class responsible for fetching the config from .diffend.yml
|
9
|
+
module Fetcher
|
10
|
+
# All the errors for missing keys in the configuration file
|
11
|
+
MISSING_KEY_ERRORS = [
|
12
|
+
Errors::ProjectIdMissingInConfigurationFile,
|
13
|
+
Errors::ShareableIdMissingInConfigurationFile,
|
14
|
+
Errors::ShareableKeyMissingInConfigurationFile,
|
15
|
+
Errors::BuildPathMissingInConfigurationFile
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
class << self
|
19
|
+
# @param build_path [String] path of the current build
|
20
|
+
#
|
21
|
+
# @return [OpenStruct] open struct with config details
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# details = Fetcher.new.call('./')
|
25
|
+
# details.build_path #=> './'
|
26
|
+
def call(build_path)
|
27
|
+
build(build_path)
|
28
|
+
rescue Errors::MissingConfigurationFile
|
29
|
+
Bundler.ui.error(build_missing_error_message(build_path))
|
30
|
+
|
31
|
+
raise Diffend::Errors::HandledException
|
32
|
+
rescue Errors::EmptyConfigurationFile
|
33
|
+
Bundler.ui.error(build_empty_error_message(build_path))
|
34
|
+
|
35
|
+
raise Diffend::Errors::HandledException
|
36
|
+
rescue Errors::MalformedConfigurationFile
|
37
|
+
Bundler.ui.error(build_malformed_error_message(build_path))
|
38
|
+
|
39
|
+
raise Diffend::Errors::HandledException
|
40
|
+
rescue *MISSING_KEY_ERRORS => e
|
41
|
+
Bundler.ui.error(build_missing_key_error_message(e))
|
42
|
+
|
43
|
+
raise Diffend::Errors::HandledException
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# @param build_path [String] path of the current build
|
49
|
+
#
|
50
|
+
# @return [OpenStruct] open struct with config details
|
51
|
+
def build(build_path)
|
52
|
+
content = ERB.new(
|
53
|
+
File.read(
|
54
|
+
FileFinder.call(build_path)
|
55
|
+
)
|
56
|
+
).result
|
57
|
+
|
58
|
+
raise Errors::EmptyConfigurationFile if content.empty?
|
59
|
+
|
60
|
+
OpenStruct.new(parse_file(content).merge(build_path: build_path))
|
61
|
+
.tap(&Validator.method(:call))
|
62
|
+
end
|
63
|
+
|
64
|
+
def parse_file(content)
|
65
|
+
YAML.safe_load(content)
|
66
|
+
rescue Psych::SyntaxError
|
67
|
+
raise Errors::MalformedConfigurationFile
|
68
|
+
end
|
69
|
+
|
70
|
+
# @param build_path [String] path of the current build
|
71
|
+
#
|
72
|
+
# @return [String] missing configuration file message
|
73
|
+
def build_missing_error_message(build_path)
|
74
|
+
<<~MSG
|
75
|
+
\nWe were unable to locate Diffend configuration file.\n
|
76
|
+
Please make sure that .diffend.yml is present in #{build_path} folder.\n
|
77
|
+
MSG
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [String] empty configuration file message
|
81
|
+
def build_empty_error_message
|
82
|
+
<<~MSG
|
83
|
+
\nYour Diffend configuration file is empty.\n
|
84
|
+
Please re-setup.\n
|
85
|
+
MSG
|
86
|
+
end
|
87
|
+
|
88
|
+
# @return [String] malformed configuration file message
|
89
|
+
def build_malformed_error_message
|
90
|
+
<<~MSG
|
91
|
+
\nYour Diffend configuration file is malformed.\n
|
92
|
+
Please re-setup.\n
|
93
|
+
MSG
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [String] malformed configuration file message
|
97
|
+
def build_missing_key_error_message(exception)
|
98
|
+
missing_key = missing_key_from_exception(exception)
|
99
|
+
|
100
|
+
<<~MSG
|
101
|
+
\nYour Diffend configuration file is missing #{missing_key} key.\n
|
102
|
+
Please re-setup.\n
|
103
|
+
MSG
|
104
|
+
end
|
105
|
+
|
106
|
+
def missing_key_from_exception(exception)
|
107
|
+
case exception
|
108
|
+
when Errors::ProjectIdMissingInConfigurationFile then 'project_id'
|
109
|
+
when Errors::ShareableIdMissingInConfigurationFile then 'shareable_id'
|
110
|
+
when Errors::ShareableKeyMissingInConfigurationFile then 'shareable_key'
|
111
|
+
when Errors::BuildPathMissingInConfigurationFile then 'build_path'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|