summaryrefslogtreecommitdiff
path: root/app/validators
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /app/validators
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
downloadgitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/branch_filter_validator.rb4
-rw-r--r--app/validators/cron_validator.rb2
-rw-r--r--app/validators/json_schema_validator.rb2
-rw-r--r--app/validators/json_schemas/helm_metadata.json128
-rw-r--r--app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json7
-rw-r--r--app/validators/same_project_association_validator.rb2
6 files changed, 140 insertions, 5 deletions
diff --git a/app/validators/branch_filter_validator.rb b/app/validators/branch_filter_validator.rb
index 6a0899be850..89d6343a9a4 100644
--- a/app/validators/branch_filter_validator.rb
+++ b/app/validators/branch_filter_validator.rb
@@ -20,11 +20,11 @@ class BranchFilterValidator < ActiveModel::EachValidator
value_without_wildcards = value.tr('*', 'x')
unless Gitlab::GitRefValidator.validate(value_without_wildcards)
- record.errors[attribute] << "is not a valid branch name"
+ record.errors.add(attribute, "is not a valid branch name")
end
unless value.length <= 4000
- record.errors[attribute] << "is longer than the allowed length of 4000 characters."
+ record.errors.add(attribute, "is longer than the allowed length of 4000 characters.")
end
end
end
diff --git a/app/validators/cron_validator.rb b/app/validators/cron_validator.rb
index 6f42bdb5f9b..91b9cfcccc4 100644
--- a/app/validators/cron_validator.rb
+++ b/app/validators/cron_validator.rb
@@ -10,7 +10,7 @@ class CronValidator < ActiveModel::EachValidator
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.new "Non-whitelisted attribute"
+ raise NonWhitelistedAttributeError, "Non-whitelisted attribute"
end
end
end
diff --git a/app/validators/json_schema_validator.rb b/app/validators/json_schema_validator.rb
index 8dc6265f471..68f03e8a6a3 100644
--- a/app/validators/json_schema_validator.rb
+++ b/app/validators/json_schema_validator.rb
@@ -54,4 +54,4 @@ class JsonSchemaValidator < ActiveModel::EachValidator
end
end
-JsonSchemaValidator.prepend_ee_mod
+JsonSchemaValidator.prepend_mod
diff --git a/app/validators/json_schemas/helm_metadata.json b/app/validators/json_schemas/helm_metadata.json
new file mode 100644
index 00000000000..7ac36e956f3
--- /dev/null
+++ b/app/validators/json_schemas/helm_metadata.json
@@ -0,0 +1,128 @@
+{
+ "description": "Helm metadata",
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "home": {
+ "type": "string"
+ },
+ "sources": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "version": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "keywords": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "maintainers": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "icon": {
+ "type": "string"
+ },
+ "apiVersion": {
+ "type": "string"
+ },
+ "condition": {
+ "type": "string"
+ },
+ "tags": {
+ "type": "string"
+ },
+ "appVersion": {
+ "type": "string"
+ },
+ "deprecated": {
+ "type": "boolean"
+ },
+ "annotations": {
+ "type": "object",
+ "patternProperties": {
+ ".+": {
+ "type": "string"
+ },
+ "additionalProperties": false
+ }
+ },
+ "kubeVersion": {
+ "type": "string"
+ },
+ "dependencies": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "repository": {
+ "type": "string"
+ },
+ "condition": {
+ "type": "string"
+ },
+ "tags": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "enabled": {
+ "type": "boolean"
+ },
+ "import-values": {
+ "type": "array",
+ "items": {
+
+ }
+ },
+ "alias": {
+ "type": "string",
+ "pattern": "^[a-zA-Z0-9_-]+$"
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "enum": ["application", "library"]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "name",
+ "version",
+ "apiVersion"
+ ]
+} \ No newline at end of file
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 dc4880946b2..7c3720dd2e6 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
@@ -161,6 +161,13 @@
"variables": []
},
{
+ "name": "semgrep",
+ "label": "Semgrep",
+ "enabled": true,
+ "description": "Multi-language scanning",
+ "variables": []
+ },
+ {
"name": "sobelow",
"label": "Sobelow",
"enabled" : true,
diff --git a/app/validators/same_project_association_validator.rb b/app/validators/same_project_association_validator.rb
index 2af2a21fa9a..2fcc369b6ef 100644
--- a/app/validators/same_project_association_validator.rb
+++ b/app/validators/same_project_association_validator.rb
@@ -16,6 +16,6 @@ class SameProjectAssociationValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return if record.project == value&.project
- record.errors[attribute] << 'must associate the same project'
+ record.errors.add(attribute, 'must associate the same project')
end
end