diff --git a/ee/app/validators/json_schemas/security_orchestration_policy.json b/ee/app/validators/json_schemas/security_orchestration_policy.json index a63c354090841706c2ea2eafcf2cd47b6c478dd8..2c20ce3d32fa9371da90fcb18be23dbeae47d48e 100644 --- a/ee/app/validators/json_schemas/security_orchestration_policy.json +++ b/ee/app/validators/json_schemas/security_orchestration_policy.json @@ -660,11 +660,13 @@ "type": "array", "description": "Specifies the licenses to match.", "minItems": 1, + "maxItems": 1000, "uniqueItems": true, "additionalItems": false, "items": { "type": "string", - "minLength": 1 + "minLength": 1, + "maxLength": 255 } }, "license_states": { diff --git a/ee/spec/models/security/orchestration_policy_configuration_spec.rb b/ee/spec/models/security/orchestration_policy_configuration_spec.rb index 1cf21ece09ee83e41d9e4ac22f9dfff61715a091..ab7eaa3d81414f115a7712f4c6e0689522c16f3b 100644 --- a/ee/spec/models/security/orchestration_policy_configuration_spec.rb +++ b/ee/spec/models/security/orchestration_policy_configuration_spec.rb @@ -1308,6 +1308,38 @@ expect(errors).to contain_exactly( "property '/#{type}/0/rules/0/license_types/0' is invalid: error_type=minLength") end + + context "when too long" do + before do + rule[:license_types] = ["a" * 256] + end + + specify do + expect(errors).to contain_exactly("property '/#{type}/0/rules/0/license_types/0' is invalid: error_type=maxLength") + end + end + + context "with repeated licenses" do + before do + rule[:license_types] = ["a"] * 2 + end + + specify do + expect(errors).to contain_exactly("property '/#{type}/0/rules/0/license_types' is invalid: error_type=uniqueItems") + end + end + + context "with too many licenses" do + before do + licenses = [] + 1001.times { |i| licenses << "License #{i}" } + rule[:license_types] = licenses + end + + specify do + expect(errors).to contain_exactly("property '/#{type}/0/rules/0/license_types' is invalid: error_type=maxItems") + end + end end describe "license_states" do