summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-16 12:07:43 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-16 12:07:43 +0000
commitd10a462fedbd7794a83abdba9b4526600f71de5b (patch)
tree4dbd21cb89013d9e07b05bac5101cd13585a8be5 /app/models
parent13867d66e92c2fd8962a126db4fbdc32891343c9 (diff)
downloadgitlab-ce-d10a462fedbd7794a83abdba9b4526600f71de5b.tar.gz
Add latest changes from gitlab-org/gitlab@masterogolowinski-master-patch-80898
Diffstat (limited to 'app/models')
-rw-r--r--app/models/application_setting.rb6
-rw-r--r--app/models/application_setting_implementation.rb3
-rw-r--r--app/models/blob.rb1
-rw-r--r--app/models/blob_viewer/open_api.rb15
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/ci/persistent_ref.rb4
-rw-r--r--app/models/ci/pipeline.rb1
-rw-r--r--app/models/clusters/cluster.rb2
-rw-r--r--app/models/clusters/concerns/application_core.rb2
-rw-r--r--app/models/concerns/group_descendant.rb2
-rw-r--r--app/models/concerns/storage/legacy_namespace.rb2
-rw-r--r--app/models/merge_request.rb2
-rw-r--r--app/models/upload.rb2
-rw-r--r--app/models/uploads/local.rb2
-rw-r--r--app/models/user.rb5
15 files changed, 41 insertions, 10 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index e764b6c56b0..456b6430088 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -46,6 +46,12 @@ class ApplicationSetting < ApplicationRecord
presence: true,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+ validates :minimum_password_length,
+ presence: true,
+ numericality: { only_integer: true,
+ greater_than_or_equal_to: DEFAULT_MINIMUM_PASSWORD_LENGTH,
+ less_than_or_equal_to: Devise.password_length.max }
+
validates :home_page_url,
allow_blank: true,
addressable_url: true,
diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb
index e1eb8d429bb..98d8bb43b93 100644
--- a/app/models/application_setting_implementation.rb
+++ b/app/models/application_setting_implementation.rb
@@ -30,6 +30,8 @@ module ApplicationSettingImplementation
'/admin/session'
].freeze
+ DEFAULT_MINIMUM_PASSWORD_LENGTH = 8
+
class_methods do
def defaults
{
@@ -106,6 +108,7 @@ module ApplicationSettingImplementation
sourcegraph_enabled: false,
sourcegraph_url: nil,
sourcegraph_public_only: true,
+ minimum_password_length: DEFAULT_MINIMUM_PASSWORD_LENGTH,
terminal_max_session_time: 0,
throttle_authenticated_api_enabled: false,
throttle_authenticated_api_period_in_seconds: 3600,
diff --git a/app/models/blob.rb b/app/models/blob.rb
index cc089715b06..c0f26ee64f8 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -26,6 +26,7 @@ class Blob < SimpleDelegator
BlobViewer::Markup,
BlobViewer::Notebook,
BlobViewer::SVG,
+ BlobViewer::OpenApi,
BlobViewer::Image,
BlobViewer::Sketch,
diff --git a/app/models/blob_viewer/open_api.rb b/app/models/blob_viewer/open_api.rb
new file mode 100644
index 00000000000..963b7336c8d
--- /dev/null
+++ b/app/models/blob_viewer/open_api.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module BlobViewer
+ class OpenApi < Base
+ include Rich
+ include ClientSide
+
+ self.partial_name = 'openapi'
+ self.file_types = %i(openapi)
+ self.binary = false
+ # TODO: get an icon for OpenAPI
+ self.switcher_icon = 'file-pdf-o'
+ self.switcher_title = 'OpenAPI'
+ end
+end
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 2e6b5d68747..4077a868373 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -289,7 +289,7 @@ module Ci
begin
build.deployment.drop!
rescue => e
- Gitlab::Sentry.track_and_raise_for_dev_exception(e, build_id: build.id)
+ Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, build_id: build.id)
end
true
diff --git a/app/models/ci/persistent_ref.rb b/app/models/ci/persistent_ref.rb
index 634c03e0326..76139f5d676 100644
--- a/app/models/ci/persistent_ref.rb
+++ b/app/models/ci/persistent_ref.rb
@@ -26,7 +26,7 @@ module Ci
create_ref(sha, path)
rescue => e
- Gitlab::Sentry
+ Gitlab::ErrorTracking
.track_exception(e, pipeline_id: pipeline.id)
end
@@ -37,7 +37,7 @@ module Ci
rescue Gitlab::Git::Repository::NoRepository
# no-op
rescue => e
- Gitlab::Sentry
+ Gitlab::ErrorTracking
.track_exception(e, pipeline_id: pipeline.id)
end
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index ce263566ea6..29ec41ef1a1 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -638,6 +638,7 @@ module Ci
variables.append(key: 'CI_COMMIT_BEFORE_SHA', value: before_sha)
variables.append(key: 'CI_COMMIT_REF_NAME', value: source_ref)
variables.append(key: 'CI_COMMIT_REF_SLUG', value: source_ref_slug)
+ variables.append(key: 'CI_COMMIT_BRANCH', value: ref) if branch?
variables.append(key: 'CI_COMMIT_TAG', value: ref) if tag?
variables.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message.to_s)
variables.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title.to_s)
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index 2d5b4905bf5..d2eee78f3df 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -335,7 +335,7 @@ module Clusters
rescue Kubeclient::HttpError => e
kubeclient_error_status(e.message)
rescue => e
- Gitlab::Sentry.track_exception(e, cluster_id: id)
+ Gitlab::ErrorTracking.track_exception(e, cluster_id: id)
:unknown_failure
else
diff --git a/app/models/clusters/concerns/application_core.rb b/app/models/clusters/concerns/application_core.rb
index cc9eafbcdd6..f6431f5bac3 100644
--- a/app/models/clusters/concerns/application_core.rb
+++ b/app/models/clusters/concerns/application_core.rb
@@ -76,7 +76,7 @@ module Clusters
message: error.message
})
- Gitlab::Sentry.track_exception(error, cluster_id: cluster&.id, application_id: id)
+ Gitlab::ErrorTracking.track_exception(error, cluster_id: cluster&.id, application_id: id)
end
end
end
diff --git a/app/models/concerns/group_descendant.rb b/app/models/concerns/group_descendant.rb
index 18f6a7a9c58..67953105bed 100644
--- a/app/models/concerns/group_descendant.rb
+++ b/app/models/concerns/group_descendant.rb
@@ -52,7 +52,7 @@ module GroupDescendant
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/49404'
}
- Gitlab::Sentry.track_and_raise_for_dev_exception(exception, extras)
+ Gitlab::ErrorTracking.track_and_raise_for_dev_exception(exception, extras)
end
if parent.nil? && hierarchy_top.present?
diff --git a/app/models/concerns/storage/legacy_namespace.rb b/app/models/concerns/storage/legacy_namespace.rb
index b9081f9bbf2..da4f2a79895 100644
--- a/app/models/concerns/storage/legacy_namespace.rb
+++ b/app/models/concerns/storage/legacy_namespace.rb
@@ -37,7 +37,7 @@ module Storage
send_update_instructions
write_projects_repository_config
rescue => e
- Gitlab::Sentry.track_and_raise_for_dev_exception(e,
+ Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e,
full_path_before_last_save: full_path_before_last_save,
full_path: full_path,
action: 'move_dir')
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 1671b1e2d55..2280c5280d5 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1514,7 +1514,7 @@ class MergeRequest < ApplicationRecord
end
end
rescue ActiveRecord::LockWaitTimeout => e
- Gitlab::Sentry.track_exception(e)
+ Gitlab::ErrorTracking.track_exception(e)
raise RebaseLockTimeout, REBASE_LOCK_MESSAGE
end
diff --git a/app/models/upload.rb b/app/models/upload.rb
index 12917f85431..46ae924bf8c 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -104,7 +104,7 @@ class Upload < ApplicationRecord
# Help sysadmins find missing upload files
if persisted? && !exist
exception = RuntimeError.new("Uploaded file does not exist")
- Gitlab::Sentry.track_exception(exception, self.attributes)
+ Gitlab::ErrorTracking.track_exception(exception, self.attributes)
Gitlab::Metrics.counter(:upload_file_does_not_exist_total, _('The number of times an upload record could not find its file')).increment
end
diff --git a/app/models/uploads/local.rb b/app/models/uploads/local.rb
index f1f25dfb584..bd295a66838 100644
--- a/app/models/uploads/local.rb
+++ b/app/models/uploads/local.rb
@@ -23,7 +23,7 @@ module Uploads
unless in_uploads?(path)
message = "Path '#{path}' is not in uploads dir, skipping"
logger.warn(message)
- Gitlab::Sentry.track_and_raise_for_dev_exception(
+ Gitlab::ErrorTracking.track_and_raise_for_dev_exception(
RuntimeError.new(message), uploads_dir: storage_dir)
return
end
diff --git a/app/models/user.rb b/app/models/user.rb
index b6ed550e441..441ad1e70be 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -381,6 +381,11 @@ class User < ApplicationRecord
# Class methods
#
class << self
+ # Devise method overridden to allow support for dynamic password lengths
+ def password_length
+ Gitlab::CurrentSettings.minimum_password_length..Devise.password_length.max
+ end
+
# Devise method overridden to allow sign in with email or username
def find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup