diffend-monitor 0.2.40 → 0.2.46

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,9 @@
30
30
  request_verdict
31
31
  execute
32
32
  track
33
+ shell
34
+ repository
35
+ integration_repository
33
36
  ].each { |file| require "diffend/#{file}" }
34
37
 
35
38
  module Diffend
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ %w[
4
+ tmpdir
5
+ securerandom
6
+ ].each(&method(:require))
7
+
8
+ module Diffend
9
+ # Repository for specs
10
+ class Repository
11
+ # Repositories path
12
+ REPOSITORIES_PATH = File.join(
13
+ File.expand_path('..', Bundler.bin_path),
14
+ 'repositories'
15
+ ).freeze
16
+ # List of supported repositories split by command
17
+ SUPPORTED = {
18
+ 'install' => %w[
19
+ with_gemfile_lock
20
+ with_gemfile_lock_with_added_gem
21
+ with_gemfile_lock_with_changed_gem_version
22
+ with_gemfile_lock_with_locked_gem_version
23
+ with_gemfile_lock_with_removed_gem
24
+ with_gemfile_lock_with_two_platforms
25
+ with_gemfile_lock_with_two_primary_sources
26
+ with_gemfile_lock_with_two_sources
27
+ without_gemfile_lock
28
+ ].freeze,
29
+ 'update' => %w[
30
+ with_gemfile_lock
31
+ with_gemfile_lock_with_added_gem
32
+ with_gemfile_lock_with_removed_gem
33
+ with_gemfile_lock_with_two_primary_sources
34
+ with_gemfile_lock_with_two_sources
35
+ without_gemfile_lock
36
+ ].freeze
37
+ }.freeze
38
+
39
+ attr_reader :name, :path
40
+
41
+ # @param command [String] command executed via bundler
42
+ # @param name [String] repository name
43
+ def initialize(command, name)
44
+ @command = command
45
+ @name = name
46
+ @path = File.join(Dir.tmpdir, SecureRandom.uuid)
47
+ end
48
+
49
+ # Build repository path
50
+ #
51
+ # @return [String]
52
+ def orig_path
53
+ @orig_path ||= global_file_path(
54
+ File.join(
55
+ bundler_version_string,
56
+ "#{@command}_#{name}"
57
+ )
58
+ )
59
+ end
60
+
61
+ # Setup an isolated instance of a repository
62
+ def setup
63
+ FileUtils.cp_r(orig_path, path)
64
+ end
65
+
66
+ # Clean isolated instance of a repository
67
+ def clean
68
+ FileUtils.rm_rf(path)
69
+ end
70
+
71
+ # Execute tasks in an isolated instance of a repository
72
+ def isolate
73
+ setup
74
+ yield(path)
75
+ clean
76
+ end
77
+
78
+ # Build the path to a specified file within the repository
79
+ #
80
+ # @param file_name [String]
81
+ #
82
+ # @return [String]
83
+ def file_path(file_name)
84
+ File.join(
85
+ path,
86
+ file_name
87
+ )
88
+ end
89
+
90
+ # Build global path
91
+ #
92
+ # @param file_name [String]
93
+ #
94
+ # @return [String]
95
+ def global_file_path(file_name)
96
+ File.join(
97
+ REPOSITORIES_PATH,
98
+ file_name
99
+ )
100
+ end
101
+
102
+ # Build bundler version string
103
+ #
104
+ # @return [String]
105
+ def bundler_version_string
106
+ @bundler_version_string ||= "bundler_#{Bundler::VERSION.tr('.', '_')}"
107
+ end
108
+ end
109
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Diffend
4
4
  # Class responsible for preparing diffend request object
5
- RequestObject = Struct.new(:config, :url, :payload, :request_method, keyword_init: true)
5
+ RequestObject = Struct.new(:config, :url, :payload, :request_method)
6
6
  end
@@ -42,10 +42,10 @@ module Diffend
42
42
  # @return [Diffend::RequestObject]
43
43
  def build_request_object(config, payload)
44
44
  Diffend::RequestObject.new(
45
- config: config,
46
- url: config.commands_url,
47
- payload: payload,
48
- request_method: :post
45
+ config,
46
+ config.commands_url,
47
+ payload,
48
+ :post
49
49
  )
50
50
  end
51
51
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ # Helper commands for running Linux shell commands
6
+ module Diffend
7
+ module Shell
8
+ class << self
9
+ # Allows to execute shell commands and handle errors, etc later
10
+ # (won't raise any errors but instead will catch all things)
11
+ # @param command_with_options [String] command that should be executed with
12
+ # all the arguments and options
13
+ # @param raise_on_invalid_exit [Boolean] raise exception when exit code is not 0
14
+ # @return [Hash] hash with 3 keys describing output
15
+ # (stdout, stderr, exit_code)
16
+ # @example Run ls
17
+ # SupportEngine::Shell.('ls') =>
18
+ # { stdout: "test.rb\n", stderr: '', exit_code: 0}
19
+ def call(command_with_options, raise_on_invalid_exit: true)
20
+ stdout_str, stderr_str, status = Open3.capture3(command_with_options)
21
+
22
+ result = {
23
+ stdout: stdout_str,
24
+ stderr: stderr_str,
25
+ exit_code: status.exitstatus
26
+ }
27
+
28
+ raise Diffend::Errors::FailedShellCommand, result.values.join(': ') \
29
+ if raise_on_invalid_exit && result[:exit_code] != 0
30
+
31
+ result
32
+ end
33
+
34
+ # @param path [String, Pathname] to a place where git repo is
35
+ # @param command [String] that we want to execute in path context
36
+ # @param raise_on_invalid_exit [Boolean] raise exception when exit code is not 0
37
+ # @return [Hash] hash with 3 keys describing output (stdout, stderr, exit_code)
38
+ def call_in_path(path, command, raise_on_invalid_exit: true)
39
+ command = ['cd', path.to_s, '&&', command]
40
+ call(command.join(' '), raise_on_invalid_exit: raise_on_invalid_exit)
41
+ end
42
+ end
43
+ end
44
+ end
data/lib/diffend/track.rb CHANGED
@@ -62,10 +62,10 @@ module Diffend
62
62
  # @return [Diffend::RequestObject]
63
63
  def build_request_object(request_id)
64
64
  Diffend::RequestObject.new(
65
- config: @config,
66
- url: @config.track_url(request_id),
67
- payload: { id: request_id }.freeze,
68
- request_method: :put
65
+ @config,
66
+ @config.track_url(request_id),
67
+ { id: request_id }.freeze,
68
+ :put
69
69
  ).freeze
70
70
  end
71
71
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Diffend
4
4
  # Current version
5
- VERSION = '0.2.40'
5
+ VERSION = '0.2.46'
6
6
  end
metadata CHANGED
@@ -1,40 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffend-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.40
4
+ version: 0.2.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Pajor
8
- autorequire:
8
+ - Maciej Mensfeld
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain:
11
12
  - |
12
13
  -----BEGIN CERTIFICATE-----
13
- MIIERDCCAqygAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBt0b21l
14
- ay9EQz1wb2xpc2hnZWVrcy9EQz1jb20wHhcNMjAwNzA3MTY0NjU0WhcNMjEwNzA3
15
- MTY0NjU0WjAmMSQwIgYDVQQDDBt0b21lay9EQz1wb2xpc2hnZWVrcy9EQz1jb20w
16
- ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDPRTvPuofdtL/wFEPOwPUr
17
- vR0XHzM/ADb2GBuzu6fzgmoxaYXBe8A++0BbgFvK47T04i8bsbXnfkxrkz/nupQ5
18
- SK2DPgS4HWnADuyBuyBY7LT4O1wwlytdlHtJgQV6NIcbprcOs/ZQKnimZpW9uByu
19
- FoN3i94pAEQhuzK0S+wWPvSm22+6XGtCuOzyFGdnCJjGUOkCRno5Nx34MWz0NpJ3
20
- 9Ekkyy8g2cLvBcUdfeSrY7WsJ5cPCNrBs5cMuV426s1dDrhuvsW+sacwwY/4/LBw
21
- JzEX4/zS+lsVIX+iOoIFGJdeGnpEWqKgWoaskxqseFi661td1n9UaMXxgoaYh/oX
22
- 3fJOy2jsZFboZ/eJ5rfciXLiCqSERGkEA+QcA2/jC/d77YJ1FfJW9uwJs3kptf4D
23
- p6h8wuA3T6rN4QrxkGBYzOfUJ2zSQy1cFu0rTZiYdKo9X6BunnxhmUExNng7advu
24
- qo8IDinyRlqA5+sOLXd4W3AS/RfF2nrayZNa3khTmmUCAwEAAaN9MHswCQYDVR0T
25
- BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFHRFOZPwpgOd2m8FIOodOii+OiID
26
- MCAGA1UdEQQZMBeBFXRvbWVrQHBvbGlzaGdlZWtzLmNvbTAgBgNVHRIEGTAXgRV0
27
- b21la0Bwb2xpc2hnZWVrcy5jb20wDQYJKoZIhvcNAQELBQADggGBAKWFwYT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000000000 Z
38
+ date: 2021-05-05 00:00:00.000000000 Z
38
39
  dependencies:
39
40
  - !ruby/object:Gem::Dependency
40
41
  name: bundler
@@ -64,32 +65,17 @@ dependencies:
64
65
  - - ">="
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
- description:
68
+ description:
68
69
  email:
69
70
  - contact@diffend.io
70
71
  executables: []
71
72
  extensions: []
72
73
  extra_rdoc_files: []
73
74
  files:
74
- - ".coditsu/ci.yml"
75
- - ".diffend.yml"
76
- - ".github/workflows/ci.yml"
77
- - ".gitignore"
78
- - ".rspec"
79
- - ".ruby-version"
80
75
  - CHANGELOG.md
81
- - Gemfile
82
- - Gemfile.lock
83
76
  - LICENSE.md
84
77
  - README.md
85
- - bin/bundle
86
- - bin/byebug
87
- - bin/htmldiff
88
- - bin/ldiff
89
- - bin/rake
90
- - bin/rspec
91
78
  - certs/mensfeld.pem
92
- - certs/tomaszpajor.pem
93
79
  - config/diffend.yml
94
80
  - diffend.gemspec
95
81
  - lib/diffend.rb
@@ -107,6 +93,7 @@ files:
107
93
  - lib/diffend/handle_errors/display_to_stdout.rb
108
94
  - lib/diffend/handle_errors/messages.rb
109
95
  - lib/diffend/handle_errors/report.rb
96
+ - lib/diffend/integration_repository.rb
110
97
  - lib/diffend/latest_version.rb
111
98
  - lib/diffend/local_context.rb
112
99
  - lib/diffend/local_context/diffend.rb
@@ -116,18 +103,19 @@ files:
116
103
  - lib/diffend/logger.rb
117
104
  - lib/diffend/monitor.rb
118
105
  - lib/diffend/plugin.rb
106
+ - lib/diffend/repository.rb
119
107
  - lib/diffend/request.rb
120
108
  - lib/diffend/request_object.rb
121
109
  - lib/diffend/request_verdict.rb
110
+ - lib/diffend/shell.rb
122
111
  - lib/diffend/track.rb
123
112
  - lib/diffend/version.rb
124
113
  - plugins.rb
125
- - scripts/generate_payload_for_file.rb
126
114
  homepage: https://diffend.io
127
115
  licenses:
128
116
  - Prosperity Public License
129
117
  metadata: {}
130
- post_install_message:
118
+ post_install_message:
131
119
  rdoc_options: []
132
120
  require_paths:
133
121
  - lib
@@ -135,15 +123,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
123
  requirements:
136
124
  - - ">="
137
125
  - !ruby/object:Gem::Version
138
- version: 2.5.0
126
+ version: '0'
139
127
  required_rubygems_version: !ruby/object:Gem::Requirement
140
128
  requirements:
141
129
  - - ">="
142
130
  - !ruby/object:Gem::Version
143
131
  version: '0'
144
132
  requirements: []
145
- rubygems_version: 3.2.3
146
- signing_key:
133
+ rubygems_version: 3.2.15
134
+ signing_key:
147
135
  specification_version: 4
148
136
  summary: OSS supply chain security and management platform
149
137
  test_files: []
metadata.gz.sig CHANGED
Binary file
data/.coditsu/ci.yml DELETED
@@ -1,3 +0,0 @@
1
- repository_id: '376dd725-895a-4221-9de5-de8ede1b30a6'
2
- api_key: <%= ENV['CODITSU_API_KEY'] %>
3
- api_secret: <%= ENV['CODITSU_API_SECRET'] %>
data/.diffend.yml DELETED
@@ -1,3 +0,0 @@
1
- project_id: '78703667-6612-476e-9718-ae573983358e'
2
- shareable_id: '432691a9-92c8-4a40-91a1-b63b09ec4123'
3
- shareable_key: '34a19a31-06c5-4941-a32e-aceb006f3730'
@@ -1,88 +0,0 @@
1
- name: ci
2
-
3
- jobs:
4
- specs:
5
- needs:
6
- - diffend
7
- - coditsu
8
-
9
- runs-on: ubuntu-latest
10
- strategy:
11
- fail-fast: false
12
- matrix:
13
- ruby:
14
- - '3.0'
15
- - '2.7'
16
- - '2.6'
17
- - '2.5'
18
- - 'jruby-9.2.14.0'
19
- bundler:
20
- - '2.1.4'
21
- - '2.2.7'
22
- include:
23
- - ruby: '2.7'
24
- coverage: 'true'
25
-
26
- steps:
27
- - uses: actions/checkout@v2
28
- - uses: actions/cache@v2
29
- with:
30
- path: vendor/bundle
31
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
32
- restore-keys: |
33
- ${{ runner.os }}-gems-
34
- - name: Install package dependencies
35
- run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
36
- - name: Set up Ruby
37
- uses: ruby/setup-ruby@v1
38
- with:
39
- ruby-version: ${{matrix.ruby}}
40
- bundler: ${{matrix.bundler}}
41
- - name: Bundle install
42
- env:
43
- DIFFEND_DEVELOPMENT: true
44
- run: |
45
- bundle _${{matrix.bundler}}_ config path vendor/bundle
46
- bundle _${{matrix.bundler}}_ install --jobs 4 --retry 3
47
- - name: Run all tests
48
- env:
49
- GITHUB_COVERAGE: ${{matrix.coverage}}
50
- run: bundle _${{matrix.bundler}}_ exec rspec
51
-
52
- diffend:
53
- runs-on: ubuntu-latest
54
- strategy:
55
- fail-fast: false
56
- steps:
57
- - uses: actions/checkout@v2
58
- with:
59
- fetch-depth: 0
60
- - name: Set up Ruby
61
- uses: ruby/setup-ruby@v1
62
- with:
63
- ruby-version: 3.0
64
- - name: Install latest bundler
65
- run: gem install bundler --no-document
66
- - name: Install Diffend plugin
67
- run: bundle plugin install diffend
68
- - name: Bundle Secure
69
- run: bundle secure
70
-
71
- coditsu:
72
- runs-on: ubuntu-latest
73
- strategy:
74
- fail-fast: false
75
- steps:
76
- - uses: actions/checkout@v2
77
- with:
78
- fetch-depth: 0
79
- - name: Run Coditsu
80
- env:
81
- CODITSU_API_KEY: ${{ secrets.CODITSU_API_KEY }}
82
- CODITSU_API_SECRET: ${{ secrets.CODITSU_API_SECRET }}
83
- run: \curl -sSL https://api.coditsu.io/run/ci | bash
84
-
85
- on:
86
- push:
87
- schedule:
88
- - cron: '0 1 * * *'