gitlab-labkit 0.21.3 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Dangerfile +1 -7
- data/README.md +2 -1
- data/gitlab-labkit.gemspec +4 -4
- data/lib/gitlab-labkit.rb +1 -0
- data/lib/labkit/context.rb +1 -5
- data/lib/labkit/fips.rb +47 -0
- data/lib/labkit/middleware/sidekiq/context/server.rb +1 -0
- metadata +13 -14
- data/danger/plugins/project_helper.rb +0 -15
- data/danger/roulette/Dangerfile +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e86f57fe5a7804f3b930b86abd75f74f7e4a6b01d67eba235c036ba88646052
|
4
|
+
data.tar.gz: ea7d3fe526de0859b739b108adebdf86110cc49f6c59ae98b9b834c876794bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a21a42f553c966c7bf5555afea1abaa72ab2837300bd09bae84c2b58f141a72c22cb3f2f20257c1ab1aadc789af47b2ed3104440b0ca3d66f37e67c17c32f0e
|
7
|
+
data.tar.gz: b8f72ab37a74c3523dfc8095d2ebe549c2710bed45741c9a6acb0211424a602695732340e94b7d9d7d3bcd3a1b95151540b3726462bf821ee03acc03951a3968
|
data/.rubocop.yml
CHANGED
data/Dangerfile
CHANGED
@@ -2,10 +2,4 @@
|
|
2
2
|
|
3
3
|
require 'gitlab-dangerfiles'
|
4
4
|
|
5
|
-
|
6
|
-
gitlab_dangerfiles.import_plugins
|
7
|
-
gitlab_dangerfiles.import_dangerfiles
|
8
|
-
|
9
|
-
danger.import_plugin('danger/plugins/*.rb')
|
10
|
-
|
11
|
-
danger.import_dangerfile(path: File.join('danger', 'roulette'))
|
5
|
+
Gitlab::Dangerfiles.for_project(self, 'labkit-ruby', &:import_defaults)
|
data/README.md
CHANGED
@@ -16,10 +16,11 @@ The changelog is available via [**tagged release notes**](https://gitlab.com/git
|
|
16
16
|
|
17
17
|
## Functionality
|
18
18
|
|
19
|
-
LabKit-Ruby provides functionality in
|
19
|
+
LabKit-Ruby provides functionality in a number of areas:
|
20
20
|
|
21
21
|
1. `Labkit::Context` used for providing context information to log messages.
|
22
22
|
1. `Labkit::Correlation` For accessing the correlation id. (Generated and propagated by `Labkit::Context`)
|
23
|
+
1. `Labkit::FIPS` for checking for FIPS mode and using FIPS-compliant algorithms.
|
23
24
|
1. `Labkit::Logging` for sanitizing log messages.
|
24
25
|
1. `Labkit::Tracing` for handling and propagating distributed traces.
|
25
26
|
|
data/gitlab-labkit.gemspec
CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.required_ruby_version = ">= 2.6.0"
|
20
20
|
|
21
21
|
# Please maintain alphabetical order for dependencies
|
22
|
-
spec.add_runtime_dependency "actionpack", ">= 5.0.0", "<
|
23
|
-
spec.add_runtime_dependency "activesupport", ">= 5.0.0", "<
|
22
|
+
spec.add_runtime_dependency "actionpack", ">= 5.0.0", "< 8.0.0"
|
23
|
+
spec.add_runtime_dependency "activesupport", ">= 5.0.0", "< 8.0.0"
|
24
24
|
spec.add_runtime_dependency "grpc", ">= 1.37" # Be sure to update the "grpc-tools" dev_dependency too
|
25
|
-
spec.add_runtime_dependency "jaeger-client", "~> 1.1"
|
25
|
+
spec.add_runtime_dependency "jaeger-client", "~> 1.1.0"
|
26
26
|
spec.add_runtime_dependency "opentracing", "~> 0.4"
|
27
27
|
spec.add_runtime_dependency "pg_query", "~> 2.1"
|
28
28
|
spec.add_runtime_dependency "redis", ">3.0.0", "<5.0.0"
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
# Please maintain alphabetical order for dev dependencies
|
31
31
|
spec.add_development_dependency "excon", "~> 0.78.1"
|
32
32
|
spec.add_development_dependency "faraday", "~> 1.2.0"
|
33
|
-
spec.add_development_dependency "gitlab-dangerfiles"
|
33
|
+
spec.add_development_dependency "gitlab-dangerfiles", "~> 2.11.0"
|
34
34
|
spec.add_development_dependency "gitlab-styles", "~> 6.2.0"
|
35
35
|
spec.add_development_dependency "grpc-tools", ">= 1.37"
|
36
36
|
spec.add_development_dependency "httparty", "~> 0.17.3"
|
data/lib/gitlab-labkit.rb
CHANGED
data/lib/labkit/context.rb
CHANGED
@@ -9,7 +9,6 @@ require "active_support/core_ext/string/inflections"
|
|
9
9
|
module Labkit
|
10
10
|
# A context can be used to provide structured information on what resources
|
11
11
|
# GitLab is working on within a service.
|
12
|
-
# The currently supported keys are defined in the `KNOWN_KEYS` constant.
|
13
12
|
#
|
14
13
|
# Values can be provided by passing a hash. If one of the values is a Proc
|
15
14
|
# the proc will only be called when the value is actually needed.
|
@@ -28,8 +27,6 @@ module Labkit
|
|
28
27
|
CORRELATION_ID_KEY = "correlation_id"
|
29
28
|
RAW_KEYS = [CORRELATION_ID_KEY].freeze
|
30
29
|
HEADER_PREFIX = "X-Gitlab-"
|
31
|
-
KNOWN_KEYS = %w[user project root_namespace subscription_plan caller_id
|
32
|
-
remote_ip related_class feature_category client_id].freeze
|
33
30
|
|
34
31
|
class << self
|
35
32
|
def with_context(attributes = {})
|
@@ -122,7 +119,6 @@ module Labkit
|
|
122
119
|
|
123
120
|
def assign_attributes(attributes)
|
124
121
|
attributes = attributes.transform_keys(&method(:log_key))
|
125
|
-
attributes = attributes.slice(*known_log_keys)
|
126
122
|
|
127
123
|
data.merge!(attributes)
|
128
124
|
|
@@ -138,7 +134,7 @@ module Labkit
|
|
138
134
|
|
139
135
|
private
|
140
136
|
|
141
|
-
delegate :log_key,
|
137
|
+
delegate :log_key, to: :class
|
142
138
|
|
143
139
|
attr_reader :data
|
144
140
|
|
data/lib/labkit/fips.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Labkit
|
4
|
+
module Digest
|
5
|
+
module SHA2
|
6
|
+
def new(*args, &block)
|
7
|
+
bitlen = args.first || 256
|
8
|
+
::OpenSSL::Digest.const_get("SHA#{bitlen}").new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class FIPS
|
14
|
+
OPENSSL_DIGESTS = %i[SHA1 SHA256 SHA384 SHA512].freeze
|
15
|
+
|
16
|
+
class << self
|
17
|
+
# Returns whether we should be running in FIPS mode or not
|
18
|
+
#
|
19
|
+
# @return [Boolean]
|
20
|
+
def enabled?
|
21
|
+
# Attempt to auto-detect FIPS mode from OpenSSL
|
22
|
+
return true if OpenSSL.fips_mode
|
23
|
+
|
24
|
+
# Otherwise allow it to be set manually via the env vars
|
25
|
+
return true if %w[1 true yes].include?(ENV["FIPS_MODE"])
|
26
|
+
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
# Swap Ruby's Digest::SHAx implementations for OpenSSL::Digest::SHAx.
|
31
|
+
def enable_fips_mode!
|
32
|
+
require "digest"
|
33
|
+
require "digest/sha2"
|
34
|
+
|
35
|
+
::Digest::SHA2.singleton_class.prepend(Labkit::Digest::SHA2)
|
36
|
+
OPENSSL_DIGESTS.each { |alg| use_openssl_digest(alg, alg) }
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def use_openssl_digest(ruby_algorithm, openssl_algorithm)
|
42
|
+
::Digest.send(:remove_const, ruby_algorithm) # rubocop:disable GitlabSecurity/PublicSend
|
43
|
+
::Digest.const_set(ruby_algorithm, OpenSSL::Digest.const_get(openssl_algorithm, false))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -10,6 +10,7 @@ module Labkit
|
|
10
10
|
def call(_worker_class, job, _queue)
|
11
11
|
worker_name = (job["wrapped"].presence || job["class"]).to_s
|
12
12
|
data = job.merge(Labkit::Context.log_key(:caller_id) => worker_name)
|
13
|
+
.select { |key, _| key.start_with?("#{Labkit::Context::LOG_KEY}.") || Labkit::Context::RAW_KEYS.include?(key.to_s) }
|
13
14
|
|
14
15
|
Labkit::Context.with_context(data) do |_context|
|
15
16
|
yield
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-labkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Newdigate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 5.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 8.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 5.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 8.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 5.0.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 8.0.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 5.0.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 8.0.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: grpc
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
73
|
+
version: 1.1.0
|
74
74
|
type: :runtime
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 1.1.0
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: opentracing
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,16 +158,16 @@ dependencies:
|
|
158
158
|
name: gitlab-dangerfiles
|
159
159
|
requirement: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
|
-
- - "
|
161
|
+
- - "~>"
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version:
|
163
|
+
version: 2.11.0
|
164
164
|
type: :development
|
165
165
|
prerelease: false
|
166
166
|
version_requirements: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- - "
|
168
|
+
- - "~>"
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version:
|
170
|
+
version: 2.11.0
|
171
171
|
- !ruby/object:Gem::Dependency
|
172
172
|
name: gitlab-styles
|
173
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -371,8 +371,6 @@ files:
|
|
371
371
|
- LICENSE
|
372
372
|
- README.md
|
373
373
|
- Rakefile
|
374
|
-
- danger/plugins/project_helper.rb
|
375
|
-
- danger/roulette/Dangerfile
|
376
374
|
- gitlab-labkit.gemspec
|
377
375
|
- lib/gitlab-labkit.rb
|
378
376
|
- lib/labkit/context.rb
|
@@ -383,6 +381,7 @@ files:
|
|
383
381
|
- lib/labkit/correlation/grpc/grpc_common.rb
|
384
382
|
- lib/labkit/correlation/grpc/server_interceptor.rb
|
385
383
|
- lib/labkit/excon_publisher.rb
|
384
|
+
- lib/labkit/fips.rb
|
386
385
|
- lib/labkit/httpclient_publisher.rb
|
387
386
|
- lib/labkit/logging.rb
|
388
387
|
- lib/labkit/logging/grpc.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Danger
|
4
|
-
# Common helper functions for danger scripts
|
5
|
-
class ProjectHelper < ::Danger::Plugin
|
6
|
-
def changes
|
7
|
-
# We do not need to categorize files in this code base
|
8
|
-
helper.changes([])
|
9
|
-
end
|
10
|
-
|
11
|
-
def project_name
|
12
|
-
"labkit-ruby"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/danger/roulette/Dangerfile
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
MESSAGE = <<MARKDOWN
|
4
|
-
## Reviewer roulette
|
5
|
-
|
6
|
-
Changes that require review have been detected! A merge request is normally
|
7
|
-
reviewed by both a reviewer and a maintainer in its primary category and by a
|
8
|
-
maintainer in all other categories.
|
9
|
-
MARKDOWN
|
10
|
-
|
11
|
-
TABLE_MARKDOWN = <<MARKDOWN
|
12
|
-
|
13
|
-
To spread load more evenly across eligible reviewers, Danger has picked a candidate for each
|
14
|
-
review slot. Feel free to
|
15
|
-
[override these selections](https://about.gitlab.com/handbook/engineering/projects/#labkit-ruby)
|
16
|
-
if you think someone else would be better-suited
|
17
|
-
or request help in the `#labkit` Slack channel.
|
18
|
-
|
19
|
-
To read more on how to use the reviewer roulette, please take a look at the
|
20
|
-
[Engineering workflow](https://about.gitlab.com/handbook/engineering/workflow/#basics)
|
21
|
-
and [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html).
|
22
|
-
|
23
|
-
Once you've decided who will review this merge request, mention them as you
|
24
|
-
normally would! Danger does not automatically notify them for you.
|
25
|
-
|
26
|
-
| Reviewer | Maintainer |
|
27
|
-
| -------- | ---------- |
|
28
|
-
MARKDOWN
|
29
|
-
|
30
|
-
def note_for_spins_role(spins, role)
|
31
|
-
spins.each do |spin|
|
32
|
-
note = note_for_spin_role(spin, role)
|
33
|
-
|
34
|
-
return note if note
|
35
|
-
end
|
36
|
-
|
37
|
-
'No %{role} available' % { role: role }
|
38
|
-
end
|
39
|
-
|
40
|
-
def note_for_spin_role(spin, role)
|
41
|
-
spin.public_send(role)&.markdown_name(author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend
|
42
|
-
end
|
43
|
-
|
44
|
-
def markdown_row_for_spins(spins_array)
|
45
|
-
reviewer_note = note_for_spins_role(spins_array, :reviewer)
|
46
|
-
maintainer_note = note_for_spins_role(spins_array, :maintainer)
|
47
|
-
|
48
|
-
"#{reviewer_note} | #{maintainer_note} |"
|
49
|
-
end
|
50
|
-
|
51
|
-
if project_helper.changes.any?
|
52
|
-
project = project_helper.project_name
|
53
|
-
|
54
|
-
random_roulette_spins = roulette.spin(project, [nil], timezone_experiment: false)
|
55
|
-
|
56
|
-
rows = random_roulette_spins.map do |spin|
|
57
|
-
markdown_row_for_spins([spin])
|
58
|
-
end
|
59
|
-
|
60
|
-
markdown(MESSAGE)
|
61
|
-
markdown(TABLE_MARKDOWN + rows.join("\n")) unless rows.empty?
|
62
|
-
end
|