Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-31 03:04:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-31 03:04:18 +0300
commit386b6dbcda5bb479ff0a6038d5dcf188bcd878b8 (patch)
treebf9f655c2546eed57ee03aee07317abf9399cca5 /app
parentf5ed5550433a5fedd128542680a94a2c9407919e (diff)
Add latest changes from gitlab-org/security/gitlab@14-9-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/blob/openapi/index.js7
-rw-r--r--app/models/releases/link.rb12
2 files changed, 12 insertions, 7 deletions
diff --git a/app/assets/javascripts/blob/openapi/index.js b/app/assets/javascripts/blob/openapi/index.js
index b19cc19cb8c..a04da98ff77 100644
--- a/app/assets/javascripts/blob/openapi/index.js
+++ b/app/assets/javascripts/blob/openapi/index.js
@@ -1,6 +1,5 @@
import { SwaggerUIBundle } from 'swagger-ui-dist';
import createFlash from '~/flash';
-import { removeParams, updateHistory } from '~/lib/utils/url_utility';
import { __ } from '~/locale';
export default () => {
@@ -8,14 +7,10 @@ export default () => {
Promise.all([import(/* webpackChunkName: 'openapi' */ 'swagger-ui-dist/swagger-ui.css')])
.then(() => {
- // Temporary fix to prevent an XSS attack due to "useUnsafeMarkdown"
- // Once we upgrade Swagger to "4.0.0", we can safely remove this as it will be deprecated
- // Follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/339696
- updateHistory({ url: removeParams(['useUnsafeMarkdown']), replace: true });
SwaggerUIBundle({
url: el.dataset.endpoint,
dom_id: '#js-openapi-viewer',
- useUnsafeMarkdown: false,
+ deepLinking: true,
});
})
.catch((error) => {
diff --git a/app/models/releases/link.rb b/app/models/releases/link.rb
index acc56d3980a..347adbdf96a 100644
--- a/app/models/releases/link.rb
+++ b/app/models/releases/link.rb
@@ -9,10 +9,20 @@ module Releases
# See https://gitlab.com/gitlab-org/gitlab/-/issues/218753
# Regex modified to prevent catastrophic backtracking
FILEPATH_REGEX = %r{\A\/[^\/](?!.*\/\/.*)[\-\.\w\/]+[\da-zA-Z]+\z}.freeze
+ FILEPATH_MAX_LENGTH = 128
validates :url, presence: true, addressable_url: { schemes: %w(http https ftp) }, uniqueness: { scope: :release }
validates :name, presence: true, uniqueness: { scope: :release }
- validates :filepath, uniqueness: { scope: :release }, format: { with: FILEPATH_REGEX }, allow_blank: true, length: { maximum: 128 }
+ validates :filepath, uniqueness: { scope: :release }, allow_blank: true
+ validate :filepath_format_valid?
+
+ # we use a custom validator here to prevent running the regex if the string is too long
+ # see https://gitlab.com/gitlab-org/gitlab/-/issues/273771
+ def filepath_format_valid?
+ return if filepath.nil? # valid use case
+ return errors.add(:filepath, "is too long (maximum is #{FILEPATH_MAX_LENGTH} characters)") if filepath.length > FILEPATH_MAX_LENGTH
+ return errors.add(:filepath, 'is in an invalid format') unless FILEPATH_REGEX.match? filepath
+ end
scope :sorted, -> { order(created_at: :desc) }