gitlab-exporter 11.18.0 → 12.1.0
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/.gitlab-ci.yml +13 -2
- data/.ruby-version +1 -1
- data/Gemfile.lock +10 -10
- data/gitlab-exporter.gemspec +2 -2
- data/lib/gitlab_exporter/database/row_count.rb +5 -18
- data/lib/gitlab_exporter/rack_vulndb_255039_patch.rb +35 -0
- data/lib/gitlab_exporter/version.rb +1 -1
- data/lib/gitlab_exporter/web_exporter.rb +1 -0
- data/spec/integration/cli_spec.rb +20 -0
- data/spec/spec_helper.rb +17 -2
- metadata +8 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c67811051d44f3c3e2fe6213eeb60f7a1c7997ddd2409008d52949cff5560fa
|
|
4
|
+
data.tar.gz: 0d750aef0b50d237783a09c22c35fdbcef0651a4998f6363cef2447786b9f8e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e60b685e6005754b165963ad218462875a80eb26aef8f5a01753fb90c138f6e98e2ceb13a43aea058487579c2a9068328611af78b01ba6b58a391cc0d0e84a0
|
|
7
|
+
data.tar.gz: 611b3b9f1a66a50e7754a27f16f8fbd12f143559607fa1a4097c252823ace586043d334df8ae2a6a7060a52adb01b24ff6978141267bdddb2dc9b595d8f004e1
|
data/.gitlab-ci.yml
CHANGED
|
@@ -43,8 +43,19 @@ rspec:
|
|
|
43
43
|
before_script: *before_scripts
|
|
44
44
|
parallel:
|
|
45
45
|
matrix:
|
|
46
|
-
- RUBY_VERSION: "2.7"
|
|
47
|
-
|
|
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"]
|
|
48
59
|
|
|
49
60
|
rubocop:
|
|
50
61
|
script:
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.7.
|
|
1
|
+
2.7.7
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gitlab-exporter (
|
|
4
|
+
gitlab-exporter (12.1.0)
|
|
5
5
|
connection_pool (= 2.2.5)
|
|
6
6
|
faraday (~> 1.8.0)
|
|
7
7
|
pg (= 1.2.3)
|
|
8
|
-
puma (= 5.6.
|
|
8
|
+
puma (= 5.6.5)
|
|
9
9
|
quantile (= 0.2.1)
|
|
10
10
|
redis (= 4.4.0)
|
|
11
|
-
redis-namespace (= 1.
|
|
11
|
+
redis-namespace (= 1.9.0)
|
|
12
12
|
sidekiq (= 6.4.0)
|
|
13
13
|
sinatra (~> 2.2.0)
|
|
14
14
|
|
|
@@ -45,16 +45,16 @@ GEM
|
|
|
45
45
|
parser (3.0.0.0)
|
|
46
46
|
ast (~> 2.4.1)
|
|
47
47
|
pg (1.2.3)
|
|
48
|
-
puma (5.6.
|
|
48
|
+
puma (5.6.5)
|
|
49
49
|
nio4r (~> 2.0)
|
|
50
50
|
quantile (0.2.1)
|
|
51
|
-
rack (2.2.
|
|
52
|
-
rack-protection (2.2.
|
|
51
|
+
rack (2.2.5)
|
|
52
|
+
rack-protection (2.2.4)
|
|
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)
|
|
@@ -87,10 +87,10 @@ GEM
|
|
|
87
87
|
connection_pool (>= 2.2.2)
|
|
88
88
|
rack (~> 2.0)
|
|
89
89
|
redis (>= 4.2.0)
|
|
90
|
-
sinatra (2.2.
|
|
90
|
+
sinatra (2.2.4)
|
|
91
91
|
mustermann (~> 2.0)
|
|
92
92
|
rack (~> 2.2)
|
|
93
|
-
rack-protection (= 2.2.
|
|
93
|
+
rack-protection (= 2.2.4)
|
|
94
94
|
tilt (~> 2.0)
|
|
95
95
|
tilt (2.0.11)
|
|
96
96
|
unicode-display_width (1.7.0)
|
data/gitlab-exporter.gemspec
CHANGED
|
@@ -23,10 +23,10 @@ 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.6.
|
|
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.
|
|
29
|
+
s.add_runtime_dependency "redis-namespace", "1.9.0"
|
|
30
30
|
s.add_runtime_dependency "sidekiq", "6.4.0"
|
|
31
31
|
s.add_runtime_dependency "sinatra", "~> 2.2.0"
|
|
32
32
|
|
|
@@ -19,11 +19,6 @@ module GitLab
|
|
|
19
19
|
projects.mirror = true
|
|
20
20
|
AND projects.archived = false
|
|
21
21
|
AND project_mirror_data.retry_count <= 14
|
|
22
|
-
AND (
|
|
23
|
-
(projects.visibility_level = 20 AND root_namespaces.visibility_level = 20)
|
|
24
|
-
OR
|
|
25
|
-
plans.name IN ('early_adopter', 'bronze', 'silver', 'gold')
|
|
26
|
-
)
|
|
27
22
|
AND project_mirror_data.next_execution_timestamp > '2020-03-28'
|
|
28
23
|
SQL
|
|
29
24
|
|
|
@@ -31,15 +26,6 @@ module GitLab
|
|
|
31
26
|
select: :projects,
|
|
32
27
|
joins: <<~SQL,
|
|
33
28
|
INNER JOIN project_mirror_data ON project_mirror_data.project_id = projects.id
|
|
34
|
-
INNER JOIN namespaces AS root_namespaces ON root_namespaces.id = (
|
|
35
|
-
WITH RECURSIVE "base_and_ancestors" AS (
|
|
36
|
-
(SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = projects.namespace_id)
|
|
37
|
-
UNION
|
|
38
|
-
(SELECT "namespaces".* FROM "namespaces", "base_and_ancestors" WHERE "namespaces"."id" = "base_and_ancestors"."parent_id")
|
|
39
|
-
) SELECT "namespaces".id FROM "base_and_ancestors" AS "namespaces" WHERE "namespaces"."parent_id" IS NULL
|
|
40
|
-
)
|
|
41
|
-
LEFT JOIN gitlab_subscriptions ON gitlab_subscriptions.namespace_id = root_namespaces.id
|
|
42
|
-
LEFT JOIN plans ON plans.id = gitlab_subscriptions.hosted_plan_id
|
|
43
29
|
SQL
|
|
44
30
|
check: "SELECT 1 FROM information_schema.tables WHERE table_name='plans'"
|
|
45
31
|
}.freeze
|
|
@@ -125,9 +111,10 @@ module GitLab
|
|
|
125
111
|
archived: {}
|
|
126
112
|
}
|
|
127
113
|
},
|
|
128
|
-
|
|
114
|
+
namespaces: {
|
|
129
115
|
select: :namespaces,
|
|
130
116
|
fields: {
|
|
117
|
+
type: {},
|
|
131
118
|
visibility_level: {},
|
|
132
119
|
root: { definition: "(parent_id IS NULL)" }
|
|
133
120
|
}
|
|
@@ -191,21 +178,21 @@ module GitLab
|
|
|
191
178
|
select: :container_repositories,
|
|
192
179
|
where: <<~SQL
|
|
193
180
|
migration_state = 'pre_importing'
|
|
194
|
-
AND (COALESCE(migration_pre_import_started_at,
|
|
181
|
+
AND (COALESCE(migration_pre_import_started_at, TO_TIMESTAMP(0)) < (now() - INTERVAL '20 minutes'))
|
|
195
182
|
SQL
|
|
196
183
|
},
|
|
197
184
|
container_repositories_stalled_pre_import_done: {
|
|
198
185
|
select: :container_repositories,
|
|
199
186
|
where: <<~SQL
|
|
200
187
|
migration_state = 'pre_import_done'
|
|
201
|
-
AND (COALESCE(migration_pre_import_done_at,
|
|
188
|
+
AND (COALESCE(migration_pre_import_done_at, TO_TIMESTAMP(0)) < (now() - INTERVAL '5 minutes'))
|
|
202
189
|
SQL
|
|
203
190
|
},
|
|
204
191
|
container_repositories_stalled_importing: {
|
|
205
192
|
select: :container_repositories,
|
|
206
193
|
where: <<~SQL
|
|
207
194
|
migration_state = 'importing'
|
|
208
|
-
AND (COALESCE(migration_import_started_at,
|
|
195
|
+
AND (COALESCE(migration_import_started_at, TO_TIMESTAMP(0)) < (now() - INTERVAL '5 minutes'))
|
|
209
196
|
SQL
|
|
210
197
|
},
|
|
211
198
|
container_repositories_skipped_not_in_plan: {
|
|
@@ -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,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,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gitlab-exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 12.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pablo Carranza
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 5.6.
|
|
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.6.
|
|
68
|
+
version: 5.6.5
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: quantile
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,14 +100,14 @@ 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
|
|
@@ -202,6 +202,7 @@ 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
|
|
207
208
|
- lib/gitlab_exporter/tls_helper.rb
|
|
@@ -216,6 +217,7 @@ files:
|
|
|
216
217
|
- spec/fixtures/smaps/sample.txt
|
|
217
218
|
- spec/git_process_proper_spec.rb
|
|
218
219
|
- spec/git_spec.rb
|
|
220
|
+
- spec/integration/cli_spec.rb
|
|
219
221
|
- spec/memstats_spec.rb
|
|
220
222
|
- spec/prometheus_metrics_spec.rb
|
|
221
223
|
- spec/ruby_spec.rb
|
|
@@ -253,6 +255,7 @@ test_files:
|
|
|
253
255
|
- spec/fixtures/smaps/sample.txt
|
|
254
256
|
- spec/git_process_proper_spec.rb
|
|
255
257
|
- spec/git_spec.rb
|
|
258
|
+
- spec/integration/cli_spec.rb
|
|
256
259
|
- spec/memstats_spec.rb
|
|
257
260
|
- spec/prometheus_metrics_spec.rb
|
|
258
261
|
- spec/ruby_spec.rb
|