gitlab-exporter 11.9.0 → 12.0.1
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 +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +29 -3
- data/.ruby-version +1 -1
- data/Gemfile.lock +17 -17
- data/config/gitlab-exporter.yml.example +5 -1
- data/gitlab-exporter.gemspec +4 -4
- data/lib/gitlab_exporter/database/row_count.rb +134 -1
- data/lib/gitlab_exporter/rack_vulndb_255039_patch.rb +35 -0
- data/lib/gitlab_exporter/tls_helper.rb +39 -0
- data/lib/gitlab_exporter/version.rb +1 -1
- data/lib/gitlab_exporter/web_exporter.rb +46 -1
- data/spec/integration/cli_spec.rb +20 -0
- data/spec/spec_helper.rb +17 -2
- metadata +17 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10750ec2de43b0651c18fe3babdff54837e6e69b9efb921fd48bfda67d287bb6
|
|
4
|
+
data.tar.gz: bfcf564c0092a85b12f126772d06e5c04710088c6251252d69e2caf605cd1c9d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab38e15c3fd76461f508921d1c960a0029b84afa673e30f7f95d57bd20d3c110232eff726723c3e7c69e154acd0b7d844fd10d960181d8de161e571423a4c151
|
|
7
|
+
data.tar.gz: 389adc0b2611a4e235b07ef72b92c77f2669db4092b624f0d5d0486fb18d894420090c172890625558cbc8f65b2a82c1906670bdf46a98a685667b757f2690d0
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
|
@@ -12,6 +12,7 @@ variables:
|
|
|
12
12
|
stages:
|
|
13
13
|
- test
|
|
14
14
|
- dast
|
|
15
|
+
- publish
|
|
15
16
|
|
|
16
17
|
default:
|
|
17
18
|
image: ruby:${RUBY_VERSION}
|
|
@@ -24,7 +25,8 @@ default:
|
|
|
24
25
|
.before_scripts: &before_scripts
|
|
25
26
|
- git config --global user.email "bot@gitlab.com"
|
|
26
27
|
- git config --global user.name "Bot User"
|
|
27
|
-
- bundle
|
|
28
|
+
- bundle config set --local deployment true
|
|
29
|
+
- bundle install -j $(nproc)
|
|
28
30
|
|
|
29
31
|
workflow:
|
|
30
32
|
rules: &workflow_rules
|
|
@@ -41,8 +43,19 @@ rspec:
|
|
|
41
43
|
before_script: *before_scripts
|
|
42
44
|
parallel:
|
|
43
45
|
matrix:
|
|
44
|
-
- RUBY_VERSION: "2.7"
|
|
45
|
-
|
|
46
|
+
- RUBY_VERSION: ["2.7", "3.0"]
|
|
47
|
+
|
|
48
|
+
rspec_integration:
|
|
49
|
+
script:
|
|
50
|
+
- bundle exec rspec spec -t integration -f d -c
|
|
51
|
+
before_script: *before_scripts
|
|
52
|
+
services:
|
|
53
|
+
- redis:latest
|
|
54
|
+
variables:
|
|
55
|
+
REDIS_URL: "redis://redis"
|
|
56
|
+
parallel:
|
|
57
|
+
matrix:
|
|
58
|
+
- RUBY_VERSION: ["2.7", "3.0"]
|
|
46
59
|
|
|
47
60
|
rubocop:
|
|
48
61
|
script:
|
|
@@ -57,3 +70,16 @@ gemnasium-dependency_scanning:
|
|
|
57
70
|
|
|
58
71
|
secret_detection:
|
|
59
72
|
rules: *workflow_rules
|
|
73
|
+
|
|
74
|
+
publish_to_rubygems:
|
|
75
|
+
stage: publish
|
|
76
|
+
script:
|
|
77
|
+
- mkdir -p ~/.gem
|
|
78
|
+
- 'echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials'
|
|
79
|
+
- chmod 0600 ~/.gem/credentials
|
|
80
|
+
- gem build gitlab-exporter.gemspec --output=gitlab-exporter.gem
|
|
81
|
+
- gem push gitlab-exporter.gem
|
|
82
|
+
before_script: *before_scripts
|
|
83
|
+
rules:
|
|
84
|
+
# Only push to RubyGems.org when we tag a new version
|
|
85
|
+
- if: '$CI_COMMIT_TAG'
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.7.
|
|
1
|
+
2.7.6
|
data/Gemfile.lock
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gitlab-exporter (
|
|
4
|
+
gitlab-exporter (12.0.1)
|
|
5
5
|
connection_pool (= 2.2.5)
|
|
6
6
|
faraday (~> 1.8.0)
|
|
7
7
|
pg (= 1.2.3)
|
|
8
|
-
puma (= 5.5
|
|
8
|
+
puma (= 5.6.5)
|
|
9
9
|
quantile (= 0.2.1)
|
|
10
10
|
redis (= 4.4.0)
|
|
11
|
-
redis-namespace (= 1.
|
|
12
|
-
sidekiq (= 6.
|
|
13
|
-
sinatra (~> 2.
|
|
11
|
+
redis-namespace (= 1.9.0)
|
|
12
|
+
sidekiq (= 6.4.0)
|
|
13
|
+
sinatra (~> 2.2.0)
|
|
14
14
|
|
|
15
15
|
GEM
|
|
16
16
|
remote: https://rubygems.org/
|
|
@@ -37,24 +37,24 @@ GEM
|
|
|
37
37
|
faraday-net_http_persistent (1.2.0)
|
|
38
38
|
faraday-patron (1.0.0)
|
|
39
39
|
faraday-rack (1.0.0)
|
|
40
|
-
multipart-post (2.
|
|
41
|
-
mustermann (
|
|
40
|
+
multipart-post (2.2.3)
|
|
41
|
+
mustermann (2.0.2)
|
|
42
42
|
ruby2_keywords (~> 0.0.1)
|
|
43
43
|
nio4r (2.5.8)
|
|
44
44
|
parallel (1.20.1)
|
|
45
45
|
parser (3.0.0.0)
|
|
46
46
|
ast (~> 2.4.1)
|
|
47
47
|
pg (1.2.3)
|
|
48
|
-
puma (5.5
|
|
48
|
+
puma (5.6.5)
|
|
49
49
|
nio4r (~> 2.0)
|
|
50
50
|
quantile (0.2.1)
|
|
51
|
-
rack (2.2.
|
|
52
|
-
rack-protection (2.
|
|
51
|
+
rack (2.2.4)
|
|
52
|
+
rack-protection (2.2.2)
|
|
53
53
|
rack
|
|
54
54
|
rainbow (3.0.0)
|
|
55
55
|
redis (4.4.0)
|
|
56
|
-
redis-namespace (1.
|
|
57
|
-
redis (>=
|
|
56
|
+
redis-namespace (1.9.0)
|
|
57
|
+
redis (>= 4)
|
|
58
58
|
regexp_parser (2.0.3)
|
|
59
59
|
rexml (3.2.4)
|
|
60
60
|
rspec (3.7.0)
|
|
@@ -83,16 +83,16 @@ GEM
|
|
|
83
83
|
parser (>= 2.7.1.5)
|
|
84
84
|
ruby-progressbar (1.11.0)
|
|
85
85
|
ruby2_keywords (0.0.5)
|
|
86
|
-
sidekiq (6.
|
|
86
|
+
sidekiq (6.4.0)
|
|
87
87
|
connection_pool (>= 2.2.2)
|
|
88
88
|
rack (~> 2.0)
|
|
89
89
|
redis (>= 4.2.0)
|
|
90
|
-
sinatra (2.
|
|
91
|
-
mustermann (~>
|
|
90
|
+
sinatra (2.2.2)
|
|
91
|
+
mustermann (~> 2.0)
|
|
92
92
|
rack (~> 2.2)
|
|
93
|
-
rack-protection (= 2.
|
|
93
|
+
rack-protection (= 2.2.2)
|
|
94
94
|
tilt (~> 2.0)
|
|
95
|
-
tilt (2.0.
|
|
95
|
+
tilt (2.0.11)
|
|
96
96
|
unicode-display_width (1.7.0)
|
|
97
97
|
webrick (1.7.0)
|
|
98
98
|
|
|
@@ -6,11 +6,15 @@ db_common: &db_common
|
|
|
6
6
|
|
|
7
7
|
# Web server config
|
|
8
8
|
server:
|
|
9
|
-
name:
|
|
9
|
+
name: webrick # cf. https://github.com/sinatra/sinatra#available-settings
|
|
10
10
|
listen_address: 0.0.0.0
|
|
11
11
|
listen_port: 9168
|
|
12
12
|
# Maximum amount of memory to use in megabytes, after which the process is killed
|
|
13
13
|
memory_threshold: 1024
|
|
14
|
+
# TLS settings
|
|
15
|
+
tls_enabled: false
|
|
16
|
+
tls_cert_path: /tmp/server.crt
|
|
17
|
+
tls_key_path: /tmp/server.key
|
|
14
18
|
|
|
15
19
|
# Probes config
|
|
16
20
|
probes:
|
data/gitlab-exporter.gemspec
CHANGED
|
@@ -23,12 +23,12 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.add_runtime_dependency "connection_pool", "2.2.5"
|
|
24
24
|
s.add_runtime_dependency "faraday", "~> 1.8.0"
|
|
25
25
|
s.add_runtime_dependency "pg", "1.2.3"
|
|
26
|
-
s.add_runtime_dependency "puma", "5.5
|
|
26
|
+
s.add_runtime_dependency "puma", "5.6.5"
|
|
27
27
|
s.add_runtime_dependency "quantile", "0.2.1"
|
|
28
28
|
s.add_runtime_dependency "redis", "4.4.0"
|
|
29
|
-
s.add_runtime_dependency "redis-namespace", "1.
|
|
30
|
-
s.add_runtime_dependency "sidekiq", "6.
|
|
31
|
-
s.add_runtime_dependency "sinatra", "~> 2.
|
|
29
|
+
s.add_runtime_dependency "redis-namespace", "1.9.0"
|
|
30
|
+
s.add_runtime_dependency "sidekiq", "6.4.0"
|
|
31
|
+
s.add_runtime_dependency "sinatra", "~> 2.2.0"
|
|
32
32
|
|
|
33
33
|
s.add_development_dependency "rspec", "~> 3.7.0"
|
|
34
34
|
s.add_development_dependency "rspec-expectations", "~> 3.7.0"
|
|
@@ -125,12 +125,145 @@ module GitLab
|
|
|
125
125
|
archived: {}
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
|
-
|
|
128
|
+
namespaces: {
|
|
129
129
|
select: :namespaces,
|
|
130
130
|
fields: {
|
|
131
|
+
type: {},
|
|
131
132
|
visibility_level: {},
|
|
132
133
|
root: { definition: "(parent_id IS NULL)" }
|
|
133
134
|
}
|
|
135
|
+
},
|
|
136
|
+
container_repositories_migration_pending: {
|
|
137
|
+
select: :container_repositories,
|
|
138
|
+
where: <<~SQL
|
|
139
|
+
migration_state <> 'import_done'
|
|
140
|
+
AND created_at < '2022-08-17 00:00:00'
|
|
141
|
+
SQL
|
|
142
|
+
},
|
|
143
|
+
container_repositories_pre_importing: {
|
|
144
|
+
select: :container_repositories,
|
|
145
|
+
where: "migration_state = 'pre_importing'"
|
|
146
|
+
},
|
|
147
|
+
container_repositories_importing: {
|
|
148
|
+
select: :container_repositories,
|
|
149
|
+
where: "migration_state = 'importing'"
|
|
150
|
+
},
|
|
151
|
+
container_repositories_pre_import_done: {
|
|
152
|
+
select: :container_repositories,
|
|
153
|
+
where: "migration_state = 'pre_import_done'"
|
|
154
|
+
},
|
|
155
|
+
container_repositories_import_done: {
|
|
156
|
+
select: :container_repositories,
|
|
157
|
+
where: "migration_state = 'import_done'"
|
|
158
|
+
},
|
|
159
|
+
container_repositories_import_skipped: {
|
|
160
|
+
select: :container_repositories,
|
|
161
|
+
where: "migration_state = 'import_skipped'"
|
|
162
|
+
},
|
|
163
|
+
container_repositories_import_aborted: {
|
|
164
|
+
select: :container_repositories,
|
|
165
|
+
where: "migration_state = 'import_aborted'"
|
|
166
|
+
},
|
|
167
|
+
container_repositories_migration_all_free: {
|
|
168
|
+
select: :container_repositories,
|
|
169
|
+
where: <<~SQL
|
|
170
|
+
migration_plan IN ('free', 'early_adopter')
|
|
171
|
+
OR migration_plan IS NULL
|
|
172
|
+
SQL
|
|
173
|
+
},
|
|
174
|
+
container_repositories_migration_pending_free: {
|
|
175
|
+
select: :container_repositories,
|
|
176
|
+
where: <<~SQL
|
|
177
|
+
migration_state <> 'import_done'
|
|
178
|
+
AND created_at < '2022-08-17 00:00:00'
|
|
179
|
+
AND (migration_plan IN ('free', 'early_adopter')
|
|
180
|
+
OR migration_plan IS NULL)
|
|
181
|
+
SQL
|
|
182
|
+
},
|
|
183
|
+
container_repositories_import_done_free: {
|
|
184
|
+
select: :container_repositories,
|
|
185
|
+
where: <<~SQL
|
|
186
|
+
(migration_state = 'import_done' OR created_at >= '2022-08-17 00:00:00')
|
|
187
|
+
AND (migration_plan IN ('free', 'early_adopter')
|
|
188
|
+
OR migration_plan IS NULL)
|
|
189
|
+
SQL
|
|
190
|
+
},
|
|
191
|
+
container_repositories_stalled_pre_importing: {
|
|
192
|
+
select: :container_repositories,
|
|
193
|
+
where: <<~SQL
|
|
194
|
+
migration_state = 'pre_importing'
|
|
195
|
+
AND (COALESCE(migration_pre_import_started_at, TO_TIMESTAMP(0)) < (now() - INTERVAL '20 minutes'))
|
|
196
|
+
SQL
|
|
197
|
+
},
|
|
198
|
+
container_repositories_stalled_pre_import_done: {
|
|
199
|
+
select: :container_repositories,
|
|
200
|
+
where: <<~SQL
|
|
201
|
+
migration_state = 'pre_import_done'
|
|
202
|
+
AND (COALESCE(migration_pre_import_done_at, TO_TIMESTAMP(0)) < (now() - INTERVAL '5 minutes'))
|
|
203
|
+
SQL
|
|
204
|
+
},
|
|
205
|
+
container_repositories_stalled_importing: {
|
|
206
|
+
select: :container_repositories,
|
|
207
|
+
where: <<~SQL
|
|
208
|
+
migration_state = 'importing'
|
|
209
|
+
AND (COALESCE(migration_import_started_at, TO_TIMESTAMP(0)) < (now() - INTERVAL '5 minutes'))
|
|
210
|
+
SQL
|
|
211
|
+
},
|
|
212
|
+
container_repositories_skipped_not_in_plan: {
|
|
213
|
+
select: :container_repositories,
|
|
214
|
+
where: <<~SQL
|
|
215
|
+
migration_state = 'import_skipped'
|
|
216
|
+
AND migration_skipped_reason = 0
|
|
217
|
+
SQL
|
|
218
|
+
},
|
|
219
|
+
container_repositories_skipped_too_many_retries: {
|
|
220
|
+
select: :container_repositories,
|
|
221
|
+
where: <<~SQL
|
|
222
|
+
migration_state = 'import_skipped'
|
|
223
|
+
AND migration_skipped_reason = 1
|
|
224
|
+
SQL
|
|
225
|
+
},
|
|
226
|
+
container_repositories_skipped_too_many_tags: {
|
|
227
|
+
select: :container_repositories,
|
|
228
|
+
where: <<~SQL
|
|
229
|
+
migration_state = 'import_skipped'
|
|
230
|
+
AND migration_skipped_reason = 2
|
|
231
|
+
SQL
|
|
232
|
+
},
|
|
233
|
+
container_repositories_skipped_deny_list: {
|
|
234
|
+
select: :container_repositories,
|
|
235
|
+
where: <<~SQL
|
|
236
|
+
migration_state = 'import_skipped'
|
|
237
|
+
AND migration_skipped_reason = 3
|
|
238
|
+
SQL
|
|
239
|
+
},
|
|
240
|
+
container_repositories_skipped_canceled: {
|
|
241
|
+
select: :container_repositories,
|
|
242
|
+
where: <<~SQL
|
|
243
|
+
migration_state = 'import_skipped'
|
|
244
|
+
AND migration_skipped_reason IN (4, 8)
|
|
245
|
+
SQL
|
|
246
|
+
},
|
|
247
|
+
container_repositories_skipped_not_found: {
|
|
248
|
+
select: :container_repositories,
|
|
249
|
+
where: <<~SQL
|
|
250
|
+
migration_state = 'import_skipped'
|
|
251
|
+
AND migration_skipped_reason = 5
|
|
252
|
+
SQL
|
|
253
|
+
},
|
|
254
|
+
container_repositories_skipped_native: {
|
|
255
|
+
select: :container_repositories,
|
|
256
|
+
where: <<~SQL
|
|
257
|
+
migration_state = 'import_skipped'
|
|
258
|
+
AND migration_skipped_reason = 6
|
|
259
|
+
SQL
|
|
260
|
+
},
|
|
261
|
+
container_repositories_skipped_force_canceled: {
|
|
262
|
+
select: :container_repositories,
|
|
263
|
+
where: <<~SQL
|
|
264
|
+
migration_state = 'import_skipped'
|
|
265
|
+
AND migration_skipped_reason = 7
|
|
266
|
+
SQL
|
|
134
267
|
}
|
|
135
268
|
}.freeze
|
|
136
269
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
if Gem.loaded_specs["rack"].version >= Gem::Version.new("3.0.0")
|
|
4
|
+
fail <<~ERR
|
|
5
|
+
This patch is unnecessary in Rack versions 3.0.0 or newer.
|
|
6
|
+
Please remove this file and the associated spec.
|
|
7
|
+
|
|
8
|
+
See https://github.com/rack/rack/blob/main/CHANGELOG.md#security (issue #1733)
|
|
9
|
+
ERR
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Patches a cache poisoning attack vector in Rack by not allowing semicolons
|
|
13
|
+
# to delimit query parameters.
|
|
14
|
+
# See https://github.com/rack/rack/issues/1732.
|
|
15
|
+
#
|
|
16
|
+
# Solution is taken from the same issue.
|
|
17
|
+
#
|
|
18
|
+
# The actual patch is due for release in Rack 3.0.0.
|
|
19
|
+
module Rack
|
|
20
|
+
class Request # rubocop:disable Style/Documentation
|
|
21
|
+
Helpers.module_eval do
|
|
22
|
+
# rubocop: disable Naming/MethodName
|
|
23
|
+
def GET
|
|
24
|
+
if get_header(RACK_REQUEST_QUERY_STRING) == query_string
|
|
25
|
+
get_header(RACK_REQUEST_QUERY_HASH)
|
|
26
|
+
else
|
|
27
|
+
query_hash = parse_query(query_string, "&") # only allow ampersand here
|
|
28
|
+
set_header(RACK_REQUEST_QUERY_STRING, query_string)
|
|
29
|
+
set_header(RACK_REQUEST_QUERY_HASH, query_hash)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
# rubocop: enable Naming/MethodName
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contains helper methods to generate TLS related configuration for web servers
|
|
2
|
+
module TLSHelper
|
|
3
|
+
CERT_REGEX = /-----BEGIN CERTIFICATE-----(?:.|\n)+?-----END CERTIFICATE-----/.freeze
|
|
4
|
+
|
|
5
|
+
def validate_tls_config(config)
|
|
6
|
+
%i[tls_cert_path tls_key_path].each do |key|
|
|
7
|
+
fail "TLS enabled, but #{key} not specified in config" unless config.key?(key)
|
|
8
|
+
|
|
9
|
+
fail "File specified via #{key} not found: #{config[key]}" unless File.exist?(config[key])
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def webrick_tls_config(config)
|
|
14
|
+
# This monkey-patches WEBrick::GenericServer, so never require this unless TLS is enabled.
|
|
15
|
+
require "webrick/ssl"
|
|
16
|
+
|
|
17
|
+
certs = load_ca_certs_bundle(File.binread(config[:tls_cert_path]))
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
SSLEnable: true,
|
|
21
|
+
SSLCertificate: certs.shift,
|
|
22
|
+
SSLPrivateKey: OpenSSL::PKey.read(File.binread(config[:tls_key_path])),
|
|
23
|
+
# SSLStartImmediately is true by default according to the docs, but when WEBrick creates the
|
|
24
|
+
# SSLServer internally, the switch was always nil for some reason. Setting this explicitly fixes this.
|
|
25
|
+
SSLStartImmediately: true,
|
|
26
|
+
SSLExtraChainCert: certs
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# In Ruby OpenSSL v3.0.0, this can be replaced by OpenSSL::X509::Certificate.load
|
|
31
|
+
# https://github.com/ruby/openssl/issues/254
|
|
32
|
+
def load_ca_certs_bundle(ca_certs_string)
|
|
33
|
+
return [] unless ca_certs_string
|
|
34
|
+
|
|
35
|
+
ca_certs_string.scan(CERT_REGEX).map do |ca_cert_string|
|
|
36
|
+
OpenSSL::X509::Certificate.new(ca_cert_string)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
require "sinatra/base"
|
|
2
2
|
require "English"
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
require_relative "rack_vulndb_255039_patch"
|
|
6
|
+
require_relative "tls_helper"
|
|
3
7
|
|
|
4
8
|
module GitLab
|
|
5
9
|
module Exporter
|
|
@@ -51,6 +55,8 @@ module GitLab
|
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
class << self
|
|
58
|
+
include TLSHelper
|
|
59
|
+
|
|
54
60
|
DEFAULT_WEB_SERVER = "webrick".freeze
|
|
55
61
|
|
|
56
62
|
def setup(config)
|
|
@@ -74,8 +80,47 @@ module GitLab
|
|
|
74
80
|
config ||= {}
|
|
75
81
|
|
|
76
82
|
set(:server, config.fetch(:name, DEFAULT_WEB_SERVER))
|
|
77
|
-
set(:bind, config.fetch(:listen_address, "0.0.0.0"))
|
|
78
83
|
set(:port, config.fetch(:listen_port, 9168))
|
|
84
|
+
|
|
85
|
+
# Depending on whether TLS is enabled or not, bind string
|
|
86
|
+
# will be different.
|
|
87
|
+
if config.fetch(:tls_enabled, "false").to_s == "true"
|
|
88
|
+
set_tls_config(config)
|
|
89
|
+
else
|
|
90
|
+
set(:bind, config.fetch(:listen_address, "0.0.0.0"))
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def set_tls_config(config) # rubocop:disable Naming/AccessorMethodName
|
|
95
|
+
validate_tls_config(config)
|
|
96
|
+
|
|
97
|
+
web_server = config.fetch(:name, DEFAULT_WEB_SERVER)
|
|
98
|
+
if web_server == "webrick"
|
|
99
|
+
set_webrick_tls(config)
|
|
100
|
+
elsif web_server == "puma"
|
|
101
|
+
set_puma_tls(config)
|
|
102
|
+
else
|
|
103
|
+
fail "TLS not supported for web server `#{web_server}`."
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def set_webrick_tls(config) # rubocop:disable Naming/AccessorMethodName
|
|
108
|
+
server_settings = {}
|
|
109
|
+
server_settings.merge!(webrick_tls_config(config))
|
|
110
|
+
|
|
111
|
+
set(:bind, config.fetch(:listen_address, "0.0.0.0"))
|
|
112
|
+
set(:server_settings, server_settings)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def set_puma_tls(config) # rubocop:disable Naming/AccessorMethodName
|
|
116
|
+
listen_address = config.fetch(:listen_address, "0.0.0.0")
|
|
117
|
+
listen_port = config.fetch(:listen_port, 8443)
|
|
118
|
+
tls_cert_path = CGI.escape(config.fetch(:tls_cert_path))
|
|
119
|
+
tls_key_path = CGI.escape(config.fetch(:tls_key_path))
|
|
120
|
+
|
|
121
|
+
bind_string = "ssl://#{listen_address}:#{listen_port}?cert=#{tls_cert_path}&key=#{tls_key_path}"
|
|
122
|
+
|
|
123
|
+
set(:bind, bind_string)
|
|
79
124
|
end
|
|
80
125
|
|
|
81
126
|
def setup_probes(config)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "gitlab_exporter/cli"
|
|
3
|
+
|
|
4
|
+
module GitLab
|
|
5
|
+
module Exporter
|
|
6
|
+
module CLI
|
|
7
|
+
describe SidekiqRunner, :integration do
|
|
8
|
+
let(:redis_url) { ENV.fetch("REDIS_URL", "redis://localhost:6379") }
|
|
9
|
+
let(:io) { StringIO.new }
|
|
10
|
+
|
|
11
|
+
it "can properly reach out to redis" do
|
|
12
|
+
args = CLIArgs.new([io], options: { /^--redis-url/ => redis_url })
|
|
13
|
+
runner = SidekiqRunner.new(args)
|
|
14
|
+
|
|
15
|
+
expect { runner.run }.not_to raise_error
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -7,6 +7,10 @@ require "tmpdir"
|
|
|
7
7
|
$LOAD_PATH.unshift File.expand_path(".")
|
|
8
8
|
Dir["spec/support/**/*.rb"].each do |f| require f end
|
|
9
9
|
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
config.filter_run_excluding integration: true
|
|
12
|
+
end
|
|
13
|
+
|
|
10
14
|
class GitRepoBuilder
|
|
11
15
|
def origin
|
|
12
16
|
@origin ||= create_origin
|
|
@@ -41,19 +45,30 @@ class GitRepoBuilder
|
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
class CLIArgs
|
|
44
|
-
def initialize(args)
|
|
48
|
+
def initialize(args, options: {})
|
|
45
49
|
@arguments = args
|
|
50
|
+
@options = options
|
|
46
51
|
end
|
|
47
52
|
|
|
48
53
|
def options
|
|
49
54
|
yield self
|
|
55
|
+
|
|
56
|
+
self
|
|
50
57
|
end
|
|
51
58
|
|
|
52
|
-
def on(*
|
|
59
|
+
def on(flag, *_)
|
|
60
|
+
match = @options.find { |regex, _| regex.match?(flag) }
|
|
61
|
+
|
|
62
|
+
yield match[1] if match
|
|
63
|
+
end
|
|
53
64
|
|
|
54
65
|
def banner=(banner); end
|
|
55
66
|
|
|
56
67
|
def parse!
|
|
57
68
|
@arguments
|
|
58
69
|
end
|
|
70
|
+
|
|
71
|
+
def shift
|
|
72
|
+
@arguments.shift
|
|
73
|
+
end
|
|
59
74
|
end
|
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gitlab-exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 12.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pablo Carranza
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2016-07-27 00:00:00.000000000 Z
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 5.5
|
|
61
|
+
version: 5.6.5
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - '='
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 5.5
|
|
68
|
+
version: 5.6.5
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: quantile
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,42 +100,42 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - '='
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 1.
|
|
103
|
+
version: 1.9.0
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - '='
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 1.
|
|
110
|
+
version: 1.9.0
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: sidekiq
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - '='
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 6.
|
|
117
|
+
version: 6.4.0
|
|
118
118
|
type: :runtime
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - '='
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: 6.
|
|
124
|
+
version: 6.4.0
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
126
|
name: sinatra
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
129
|
- - "~>"
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: 2.
|
|
131
|
+
version: 2.2.0
|
|
132
132
|
type: :runtime
|
|
133
133
|
prerelease: false
|
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
136
|
- - "~>"
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: 2.
|
|
138
|
+
version: 2.2.0
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
140
|
name: rspec
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -202,8 +202,10 @@ files:
|
|
|
202
202
|
- lib/gitlab_exporter/prober.rb
|
|
203
203
|
- lib/gitlab_exporter/process.rb
|
|
204
204
|
- lib/gitlab_exporter/prometheus.rb
|
|
205
|
+
- lib/gitlab_exporter/rack_vulndb_255039_patch.rb
|
|
205
206
|
- lib/gitlab_exporter/ruby.rb
|
|
206
207
|
- lib/gitlab_exporter/sidekiq.rb
|
|
208
|
+
- lib/gitlab_exporter/tls_helper.rb
|
|
207
209
|
- lib/gitlab_exporter/util.rb
|
|
208
210
|
- lib/gitlab_exporter/version.rb
|
|
209
211
|
- lib/gitlab_exporter/web_exporter.rb
|
|
@@ -215,6 +217,7 @@ files:
|
|
|
215
217
|
- spec/fixtures/smaps/sample.txt
|
|
216
218
|
- spec/git_process_proper_spec.rb
|
|
217
219
|
- spec/git_spec.rb
|
|
220
|
+
- spec/integration/cli_spec.rb
|
|
218
221
|
- spec/memstats_spec.rb
|
|
219
222
|
- spec/prometheus_metrics_spec.rb
|
|
220
223
|
- spec/ruby_spec.rb
|
|
@@ -224,7 +227,7 @@ homepage: http://gitlab.com
|
|
|
224
227
|
licenses:
|
|
225
228
|
- MIT
|
|
226
229
|
metadata: {}
|
|
227
|
-
post_install_message:
|
|
230
|
+
post_install_message:
|
|
228
231
|
rdoc_options: []
|
|
229
232
|
require_paths:
|
|
230
233
|
- lib
|
|
@@ -239,8 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
239
242
|
- !ruby/object:Gem::Version
|
|
240
243
|
version: '0'
|
|
241
244
|
requirements: []
|
|
242
|
-
rubygems_version: 3.
|
|
243
|
-
signing_key:
|
|
245
|
+
rubygems_version: 3.1.6
|
|
246
|
+
signing_key:
|
|
244
247
|
specification_version: 4
|
|
245
248
|
summary: GitLab metrics exporter
|
|
246
249
|
test_files:
|
|
@@ -252,6 +255,7 @@ test_files:
|
|
|
252
255
|
- spec/fixtures/smaps/sample.txt
|
|
253
256
|
- spec/git_process_proper_spec.rb
|
|
254
257
|
- spec/git_spec.rb
|
|
258
|
+
- spec/integration/cli_spec.rb
|
|
255
259
|
- spec/memstats_spec.rb
|
|
256
260
|
- spec/prometheus_metrics_spec.rb
|
|
257
261
|
- spec/ruby_spec.rb
|