Skip to content

Commit e87fbda

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/security/gitlab@14-1-stable-ee
1 parent 3c992c7 commit e87fbda

File tree

16 files changed

+196
-55
lines changed

16 files changed

+196
-55
lines changed

app/controllers/admin/users_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def edit
4444
end
4545

4646
def impersonate
47-
if can?(user, :log_in)
47+
if can?(user, :log_in) && !impersonation_in_progress?
4848
session[:impersonator_id] = current_user.id
4949

5050
warden.set_user(user, scope: :user)
@@ -56,7 +56,9 @@ def impersonate
5656
redirect_to root_path
5757
else
5858
flash[:alert] =
59-
if user.blocked?
59+
if impersonation_in_progress?
60+
_("You are already impersonating another user")
61+
elsif user.blocked?
6062
_("You cannot impersonate a blocked user")
6163
elsif user.internal?
6264
_("You cannot impersonate an internal user")

app/controllers/concerns/impersonation.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def current_user
1414
protected
1515

1616
def check_impersonation_availability
17-
return unless session[:impersonator_id]
17+
return unless impersonation_in_progress?
1818

1919
unless Gitlab.config.gitlab.impersonation_enabled
2020
stop_impersonation
@@ -31,6 +31,10 @@ def stop_impersonation
3131
current_user
3232
end
3333

34+
def impersonation_in_progress?
35+
session[:impersonator_id].present?
36+
end
37+
3438
def log_impersonation_event
3539
Gitlab::AppLogger.info("User #{impersonator.username} has stopped impersonating #{current_user.username}")
3640
end

app/controllers/import/gitea_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ def client
6666

6767
override :client_options
6868
def client_options
69-
{ host: provider_url, api_version: 'v1' }
69+
verified_url, provider_hostname = verify_blocked_uri
70+
71+
{ host: verified_url.scheme == 'https' ? provider_url : verified_url.to_s, api_version: 'v1', hostname: provider_hostname }
7072
end
7173

7274
def verify_blocked_uri
73-
Gitlab::UrlBlocker.validate!(
75+
@verified_url_and_hostname ||= Gitlab::UrlBlocker.validate!(
7476
provider_url,
7577
allow_localhost: allow_local_requests?,
7678
allow_local_network: allow_local_requests?,

app/controllers/profiles/passwords_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def update
4747
password_attributes[:password_automatically_set] = false
4848

4949
unless @user.password_automatically_set || @user.valid_password?(user_params[:current_password])
50+
handle_invalid_current_password_attempt!
51+
5052
redirect_to edit_profile_password_path, alert: _('You must provide a valid current password')
5153
return
5254
end
@@ -85,6 +87,12 @@ def authorize_change_password!
8587
render_404 unless @user.allow_password_authentication?
8688
end
8789

90+
def handle_invalid_current_password_attempt!
91+
Gitlab::AppLogger.info(message: 'Invalid current password when attempting to update user password', username: @user.username, ip: request.remote_ip)
92+
93+
@user.increment_failed_attempts!
94+
end
95+
8896
def user_params
8997
params.require(:user).permit(:current_password, :password, :password_confirmation)
9098
end

config/initializers/doorkeeper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
# Issue access tokens with refresh token (disabled by default)
4949
use_refresh_token
5050

51+
# Forbids creating/updating applications with arbitrary scopes that are
52+
# not in configuration, i.e. `default_scopes` or `optional_scopes`.
53+
# (disabled by default)
54+
enforce_configured_scopes
55+
5156
# Forces the usage of the HTTPS protocol in non-native redirect uris (enabled
5257
# by default in non-development environments). OAuth2 delegates security in
5358
# communication to the HTTPS protocol so it is wise to keep this enabled.

doc/user/project/settings/import_export.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ The following items are **not** exported:
137137
- Webhooks
138138
- Any encrypted tokens
139139
- Merge Request Approvers
140+
- Repository size limits
140141

141142
NOTE:
142143
For more details on the specific data persisted in a project export, see the

lib/gitlab/import_export/group/import_export.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ excluded_attributes:
3737
- :trial_ends_on
3838
- :shared_runners_minute_limit
3939
- :extra_shared_runners_minutes_limit
40+
- :repository_size_limit
4041
epics:
4142
- :state_id
4243

lib/gitlab/import_export/project/import_export.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ excluded_attributes:
173173
- :show_default_award_emojis
174174
- :services
175175
- :exported_protected_branches
176+
- :repository_size_limit
176177
namespaces:
177178
- :runners_token
178179
- :runners_token_encrypted

lib/gitlab/legacy_github_import/client.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ class Client
88

99
attr_reader :access_token, :host, :api_version, :wait_for_rate_limit_reset
1010

11-
def initialize(access_token, host: nil, api_version: 'v3', wait_for_rate_limit_reset: true)
11+
def initialize(access_token, host: nil, api_version: 'v3', wait_for_rate_limit_reset: true, hostname: nil)
1212
@access_token = access_token
1313
@host = host.to_s.sub(%r{/+\z}, '')
14+
@hostname = hostname
1415
@api_version = api_version
1516
@users = {}
1617
@wait_for_rate_limit_reset = wait_for_rate_limit_reset
@@ -28,7 +29,8 @@ def api
2829
# If there is no config, we're connecting to github.com and we
2930
# should verify ssl.
3031
connection_options: {
31-
ssl: { verify: config ? config['verify_ssl'] : true }
32+
ssl: { verify: config ? config['verify_ssl'] : true },
33+
headers: { host: @hostname }.compact
3234
}
3335
)
3436
end

locale/gitlab.pot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37284,6 +37284,9 @@ msgstr ""
3728437284
msgid "You are already a member of this %{member_source}."
3728537285
msgstr ""
3728637286

37287+
msgid "You are already impersonating another user"
37288+
msgstr ""
37289+
3728737290
msgid "You are an admin, which means granting access to %{client_name} will allow them to interact with GitLab as an admin as well. Proceed with caution."
3728837291
msgstr ""
3728937292

0 commit comments

Comments
 (0)