New upstream version 15.2.3+ds1
This commit is contained in:
parent
95815f5e46
commit
67b9e80cf4
7 changed files with 370 additions and 297 deletions
|
@ -2,6 +2,13 @@
|
||||||
documentation](doc/development/changelog.md) for instructions on adding your own
|
documentation](doc/development/changelog.md) for instructions on adding your own
|
||||||
entry.
|
entry.
|
||||||
|
|
||||||
|
## 15.2.3 (2022-08-22)
|
||||||
|
|
||||||
|
### Security (2 changes)
|
||||||
|
|
||||||
|
- [Validate if values to be saved in Redis can be converted to string](gitlab-org/security/gitlab@427c7818b229fd45b10cb5de9ea6cc7c451dd4da) ([merge request](gitlab-org/security/gitlab!2724))
|
||||||
|
- [Fix CSS selector used in specs](gitlab-org/security/gitlab@47bb40d097e2b05ecdbeebf6bdbe6eb9b6db1c7b) ([merge request](gitlab-org/security/gitlab!2727))
|
||||||
|
|
||||||
## 15.2.2 (2022-08-01)
|
## 15.2.2 (2022-08-01)
|
||||||
|
|
||||||
### Fixed (6 changes)
|
### Fixed (6 changes)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
15.2.2
|
15.2.3
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
15.2.2
|
15.2.3
|
21
lib/gitlab/cache/import/caching.rb
vendored
21
lib/gitlab/cache/import/caching.rb
vendored
|
@ -65,6 +65,8 @@ module Gitlab
|
||||||
# value - The value to set.
|
# value - The value to set.
|
||||||
# timeout - The time after which the cache key should expire.
|
# timeout - The time after which the cache key should expire.
|
||||||
def self.write(raw_key, value, timeout: TIMEOUT)
|
def self.write(raw_key, value, timeout: TIMEOUT)
|
||||||
|
validate_redis_value!(value)
|
||||||
|
|
||||||
key = cache_key_for(raw_key)
|
key = cache_key_for(raw_key)
|
||||||
|
|
||||||
Redis::Cache.with do |redis|
|
Redis::Cache.with do |redis|
|
||||||
|
@ -99,6 +101,8 @@ module Gitlab
|
||||||
# timeout - The time after which the cache key should expire.
|
# timeout - The time after which the cache key should expire.
|
||||||
# @return - the incremented value
|
# @return - the incremented value
|
||||||
def self.increment_by(raw_key, value, timeout: TIMEOUT)
|
def self.increment_by(raw_key, value, timeout: TIMEOUT)
|
||||||
|
validate_redis_value!(value)
|
||||||
|
|
||||||
key = cache_key_for(raw_key)
|
key = cache_key_for(raw_key)
|
||||||
|
|
||||||
Redis::Cache.with do |redis|
|
Redis::Cache.with do |redis|
|
||||||
|
@ -113,6 +117,8 @@ module Gitlab
|
||||||
# value - The value to add to the set.
|
# value - The value to add to the set.
|
||||||
# timeout - The new timeout of the key.
|
# timeout - The new timeout of the key.
|
||||||
def self.set_add(raw_key, value, timeout: TIMEOUT)
|
def self.set_add(raw_key, value, timeout: TIMEOUT)
|
||||||
|
validate_redis_value!(value)
|
||||||
|
|
||||||
key = cache_key_for(raw_key)
|
key = cache_key_for(raw_key)
|
||||||
|
|
||||||
Redis::Cache.with do |redis|
|
Redis::Cache.with do |redis|
|
||||||
|
@ -128,6 +134,8 @@ module Gitlab
|
||||||
# raw_key - The key of the set to check.
|
# raw_key - The key of the set to check.
|
||||||
# value - The value to check for.
|
# value - The value to check for.
|
||||||
def self.set_includes?(raw_key, value)
|
def self.set_includes?(raw_key, value)
|
||||||
|
validate_redis_value!(value)
|
||||||
|
|
||||||
key = cache_key_for(raw_key)
|
key = cache_key_for(raw_key)
|
||||||
|
|
||||||
Redis::Cache.with do |redis|
|
Redis::Cache.with do |redis|
|
||||||
|
@ -157,6 +165,8 @@ module Gitlab
|
||||||
mapping.each do |raw_key, value|
|
mapping.each do |raw_key, value|
|
||||||
key = cache_key_for("#{key_prefix}#{raw_key}")
|
key = cache_key_for("#{key_prefix}#{raw_key}")
|
||||||
|
|
||||||
|
validate_redis_value!(value)
|
||||||
|
|
||||||
multi.set(key, value, ex: timeout)
|
multi.set(key, value, ex: timeout)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -186,6 +196,8 @@ module Gitlab
|
||||||
#
|
#
|
||||||
# Returns true when the key was overwritten, false otherwise.
|
# Returns true when the key was overwritten, false otherwise.
|
||||||
def self.write_if_greater(raw_key, value, timeout: TIMEOUT)
|
def self.write_if_greater(raw_key, value, timeout: TIMEOUT)
|
||||||
|
validate_redis_value!(value)
|
||||||
|
|
||||||
key = cache_key_for(raw_key)
|
key = cache_key_for(raw_key)
|
||||||
val = Redis::Cache.with do |redis|
|
val = Redis::Cache.with do |redis|
|
||||||
redis
|
redis
|
||||||
|
@ -202,6 +214,8 @@ module Gitlab
|
||||||
# value - The field value to add to the hash.
|
# value - The field value to add to the hash.
|
||||||
# timeout - The new timeout of the key.
|
# timeout - The new timeout of the key.
|
||||||
def self.hash_add(raw_key, field, value, timeout: TIMEOUT)
|
def self.hash_add(raw_key, field, value, timeout: TIMEOUT)
|
||||||
|
validate_redis_value!(value)
|
||||||
|
|
||||||
key = cache_key_for(raw_key)
|
key = cache_key_for(raw_key)
|
||||||
|
|
||||||
Redis::Cache.with do |redis|
|
Redis::Cache.with do |redis|
|
||||||
|
@ -226,6 +240,13 @@ module Gitlab
|
||||||
def self.cache_key_for(raw_key)
|
def self.cache_key_for(raw_key)
|
||||||
"#{Redis::Cache::CACHE_NAMESPACE}:#{raw_key}"
|
"#{Redis::Cache::CACHE_NAMESPACE}:#{raw_key}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.validate_redis_value!(value)
|
||||||
|
value_as_string = value.to_s
|
||||||
|
return if value_as_string.is_a?(String)
|
||||||
|
|
||||||
|
raise "Value '#{value_as_string}' of type '#{value_as_string.class}' for '#{value.inspect}' is not a String"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -329,7 +329,7 @@ RSpec.describe 'Project' do
|
||||||
it 'has working links to submodules' do
|
it 'has working links to submodules' do
|
||||||
click_link('645f6c4c')
|
click_link('645f6c4c')
|
||||||
|
|
||||||
expect(page).to have_selector('.qa-branches-select', text: '645f6c4c82fd3f5e06f67134450a570b795e55a6') # rubocop:disable QA/SelectorUsage
|
expect(page).to have_selector('[data-testid="branches-select"]', text: '645f6c4c82fd3f5e06f67134450a570b795e55a6')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for signed commit on default branch', :js do
|
context 'for signed commit on default branch', :js do
|
||||||
|
|
45
spec/lib/gitlab/cache/import/caching_spec.rb
vendored
45
spec/lib/gitlab/cache/import/caching_spec.rb
vendored
|
@ -3,6 +3,17 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
||||||
|
shared_examples 'validated redis value' do
|
||||||
|
let(:value) { double('value', to_s: Object.new) }
|
||||||
|
|
||||||
|
it 'raise error if value.to_s does not return a String' do
|
||||||
|
value_as_string = value.to_s
|
||||||
|
message = /Value '#{value_as_string}' of type '#{value_as_string.class}' for '#{value.inspect}' is not a String/
|
||||||
|
|
||||||
|
expect { subject }.to raise_error(message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '.read' do
|
describe '.read' do
|
||||||
it 'reads a value from the cache' do
|
it 'reads a value from the cache' do
|
||||||
described_class.write('foo', 'bar')
|
described_class.write('foo', 'bar')
|
||||||
|
@ -56,6 +67,16 @@ RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
||||||
expect(described_class.write('foo', 10)).to eq(10)
|
expect(described_class.write('foo', 10)).to eq(10)
|
||||||
expect(described_class.read('foo')).to eq('10')
|
expect(described_class.read('foo')).to eq('10')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'validated redis value' do
|
||||||
|
subject { described_class.write('foo', value) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '.increment_by' do
|
||||||
|
it_behaves_like 'validated redis value' do
|
||||||
|
subject { described_class.increment_by('foo', value) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.increment' do
|
describe '.increment' do
|
||||||
|
@ -78,6 +99,10 @@ RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
||||||
|
|
||||||
expect(values).to eq(['10'])
|
expect(values).to eq(['10'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'validated redis value' do
|
||||||
|
subject { described_class.set_add('foo', value) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.set_includes?' do
|
describe '.set_includes?' do
|
||||||
|
@ -96,6 +121,10 @@ RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
||||||
|
|
||||||
expect(described_class.set_includes?('foo', 10)).to eq(true)
|
expect(described_class.set_includes?('foo', 10)).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'validated redis value' do
|
||||||
|
subject { described_class.set_includes?('foo', value) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.values_from_set' do
|
describe '.values_from_set' do
|
||||||
|
@ -120,6 +149,10 @@ RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
||||||
|
|
||||||
expect(values).to eq({ '1' => '1', '2' => '2' })
|
expect(values).to eq({ '1' => '1', '2' => '2' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'validated redis value' do
|
||||||
|
subject { described_class.hash_add('foo', 1, value) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.values_from_hash' do
|
describe '.values_from_hash' do
|
||||||
|
@ -160,6 +193,12 @@ RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
||||||
expect(found).to eq(value.to_s)
|
expect(found).to eq(value.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'validated redis value' do
|
||||||
|
let(:mapping) { { 'foo' => value, 'bar' => value } }
|
||||||
|
|
||||||
|
subject { described_class.write_multiple(mapping) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.expire' do
|
describe '.expire' do
|
||||||
|
@ -175,4 +214,10 @@ RSpec.describe Gitlab::Cache::Import::Caching, :clean_gitlab_redis_cache do
|
||||||
expect(found_ttl).to be <= timeout
|
expect(found_ttl).to be <= timeout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.write_if_greater' do
|
||||||
|
it_behaves_like 'validated redis value' do
|
||||||
|
subject { described_class.write_if_greater('foo', value) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue