diff options
Diffstat (limited to 'app/validators')
9 files changed, 65 insertions, 27 deletions
diff --git a/app/validators/abstract_path_validator.rb b/app/validators/abstract_path_validator.rb index ff390a624c5..29620543a0f 100644 --- a/app/validators/abstract_path_validator.rb +++ b/app/validators/abstract_path_validator.rb @@ -21,7 +21,7 @@ class AbstractPathValidator < ActiveModel::EachValidator end def validate_each(record, attribute, value) - unless value =~ self.class.format_regex + unless self.class.format_regex.match?(value) record.errors.add(attribute, self.class.format_error_message) return end diff --git a/app/validators/cluster_name_validator.rb b/app/validators/cluster_name_validator.rb index 79c9c67ae58..527116ba69b 100644 --- a/app/validators/cluster_name_validator.rb +++ b/app/validators/cluster_name_validator.rb @@ -16,7 +16,7 @@ class ClusterNameValidator < ActiveModel::EachValidator record.errors.add(attribute, " is invalid syntax") end - unless value =~ Gitlab::Regex.kubernetes_namespace_regex + unless Gitlab::Regex.kubernetes_namespace_regex.match(value) record.errors.add(attribute, Gitlab::Regex.kubernetes_namespace_regex_message) end end diff --git a/app/validators/cron_validator.rb b/app/validators/cron_validator.rb index 91b9cfcccc4..c12b29410d4 100644 --- a/app/validators/cron_validator.rb +++ b/app/validators/cron_validator.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true class CronValidator < ActiveModel::EachValidator - ATTRIBUTE_WHITELIST = %i[cron freeze_start freeze_end].freeze + ATTRIBUTE_ALLOWLIST = %i[cron freeze_start freeze_end].freeze - NonWhitelistedAttributeError = Class.new(StandardError) + NonAllowlistedAttributeError = Class.new(StandardError) def validate_each(record, attribute, value) - if ATTRIBUTE_WHITELIST.include?(attribute) + if ATTRIBUTE_ALLOWLIST.include?(attribute) cron_parser = Gitlab::Ci::CronParser.new(record.public_send(attribute), record.cron_timezone) # rubocop:disable GitlabSecurity/PublicSend record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_valid? else - raise NonWhitelistedAttributeError, "Non-whitelisted attribute" + raise NonAllowlistedAttributeError, "Non-allowlisted attribute" end end end diff --git a/app/validators/devise_email_validator.rb b/app/validators/devise_email_validator.rb index 6ca921ca7fa..b91cfe23f08 100644 --- a/app/validators/devise_email_validator.rb +++ b/app/validators/devise_email_validator.rb @@ -31,6 +31,6 @@ class DeviseEmailValidator < ActiveModel::EachValidator end def validate_each(record, attribute, value) - record.errors.add(attribute, :invalid) unless value =~ options[:regexp] + record.errors.add(attribute, :invalid) unless options[:regexp].match?(value) end end diff --git a/app/validators/json_schemas/default_branch_protection_defaults.json b/app/validators/json_schemas/default_branch_protection_defaults.json index bd2945c08fb..d93527ad0a4 100644 --- a/app/validators/json_schemas/default_branch_protection_defaults.json +++ b/app/validators/json_schemas/default_branch_protection_defaults.json @@ -62,14 +62,8 @@ "code_owner_approval_required": { "type": "boolean" }, - "merge_access_level": { - "type": "integer" - }, - "push_access_level": { - "type": "integer" - }, - "unprotect_access_level": { - "type": "integer" + "developer_can_initial_push": { + "type": "boolean" } }, "additionalProperties": false diff --git a/app/validators/json_schemas/organization_settings.json b/app/validators/json_schemas/organization_settings.json new file mode 100644 index 00000000000..350ce7d9066 --- /dev/null +++ b/app/validators/json_schemas/organization_settings.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Settings for Organizations", + "type": "object", + "additionalProperties": false, + "properties": { + "restricted_visibility_levels": { + "type": "array", + "items": { + "type": "integer" + } + } + } +} diff --git a/app/validators/json_schemas/scan_result_policy_vulnerability_attributes.json b/app/validators/json_schemas/scan_result_policy_vulnerability_attributes.json new file mode 100644 index 00000000000..e0051179a1d --- /dev/null +++ b/app/validators/json_schemas/scan_result_policy_vulnerability_attributes.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Scan result policy vulnerability_attributes", + "type": "object", + "properties": { + "false_positive": { + "type": "boolean" + }, + "fix_available": { + "type": "boolean" + } + }, + "additionalProperties": false +} diff --git a/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json b/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json index fb6b80e0725..9cfb62d4439 100644 --- a/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json +++ b/app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json @@ -32,12 +32,12 @@ }, { "field": "SEARCH_MAX_DEPTH", - "label": "Search maximum depth", + "label": "Search Maximum Depth", "type": "string", "default_value": "", "value": "", "size": "SMALL", - "description": "Maximum depth of language and framework detection" + "description": "Specifies the number of directory levels to be included in the repository search phase during SAST analysis. SAST scanner searches through the repository to detect the programming languages used and selects the corresponding analyzers. After that, the entire repository is analyzed." } ], "analyzers": [ @@ -80,56 +80,72 @@ "label": "Kubesec", "enabled": true, "description": "Kubernetes manifests, Helm Charts", - "variables": [] + "variables": [ + + ] }, { "name": "nodejs-scan", "label": "Node.js Scan", "enabled": true, "description": "Node.js", - "variables": [] + "variables": [ + + ] }, { "name": "phpcs-security-audit", "label": "PHP Security Audit", "enabled": true, "description": "PHP", - "variables": [] + "variables": [ + + ] }, { "name": "pmd-apex", "label": "PMD APEX", "enabled": true, "description": "Apex (Salesforce)", - "variables": [] + "variables": [ + + ] }, { "name": "security-code-scan", "label": "Security Code Scan", "enabled": true, "description": ".NET Core, .NET Framework", - "variables": [] + "variables": [ + + ] }, { "name": "semgrep", "label": "Semgrep", "enabled": true, "description": "Multi-language scanning", - "variables": [] + "variables": [ + + ] }, { "name": "sobelow", "label": "Sobelow", "enabled": true, "description": "Elixir (Phoenix)", - "variables": [] + "variables": [ + + ] }, { "name": "spotbugs", "label": "Spotbugs", "enabled": true, "description": "Groovy, Java, Scala", - "variables": [] + "variables": [ + + ] } ] -}
\ No newline at end of file +} diff --git a/app/validators/line_code_validator.rb b/app/validators/line_code_validator.rb index a351180790e..e1abccc1dff 100644 --- a/app/validators/line_code_validator.rb +++ b/app/validators/line_code_validator.rb @@ -7,7 +7,7 @@ class LineCodeValidator < ActiveModel::EachValidator PATTERN = /\A[a-z0-9]+_\d+_\d+\z/.freeze def validate_each(record, attribute, value) - unless value =~ PATTERN + unless PATTERN.match?(value) record.errors.add(attribute, "must be a valid line code") end end |