Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfn validate fails for wrong min/max constraint #414

Closed
surega21 opened this issue Apr 8, 2020 · 3 comments · Fixed by #675
Closed

cfn validate fails for wrong min/max constraint #414

surega21 opened this issue Apr 8, 2020 · 3 comments · Fixed by #675
Labels
bug Something isn't working schema processing

Comments

@surega21
Copy link

surega21 commented Apr 8, 2020

For a numeric type, the range constraints allowed are : minimum, maximum, exclusiveMinimum, exclusiveMaximum.

A schema with string contraints - minLength, maxLength on a numeric type is simply ignored during validation.

ex wrong schema:

                "TimeoutMinutes": {
                    "description": "The maximum time in minutes that tests are permitted to run.",
                    "type": "integer",
                    "minLength": 60,
                    "maxLength": 1440
                }

The validation should fail here. The correct schema would be :

                "TimeoutMinutes": {
                    "description": "The maximum time in minutes that tests are permitted to run.",
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 1440
                }
@PatMyron
Copy link
Contributor

PatMyron commented Aug 6, 2020

Will need to do a sweep of existing resource-providers once we can detect these

number with string minLength/maxLength constraints:
CloudformationSchemas $ grep -E -C 2 -i 'type.*(integer|number)' * | grep -E -i 'm[ia][nx]Length'
aws-cloudformation/aws-cloudformation-resource-providers-ssm#69 (comment)
aws-cloudformation/aws-cloudformation-resource-providers-opsworkscm#16 (comment)
aws-cloudformation/aws-cloudformation-resource-providers-iotwireless#4 (comment)
aws-cloudformation/aws-cloudformation-resource-providers-auditmanager#2 (comment)

string with numeric minimum/maximum constraints:
CloudformationSchemas $ grep -E -C 2 -i 'type.*string' * | grep -E -i '"m[ia][nx]imum"'
aws-cloudformation/aws-cloudformation-resource-providers-kinesisfirehose#16 (comment)
https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-codepipeline/pull/8#discussion_r460315825
https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-codepipeline/pull/9#discussion_r460316286
https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-gamelift/pull/6#discussion_r460316682
https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-gamelift/pull/7
aws-cloudformation/aws-cloudformation-resource-providers-applicationinsights#1
aws-cloudformation/aws-cloudformation-resource-providers-glue#1
aws-cloudformation/aws-cloudformation-resource-providers-sagemaker#2
https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-ec2-ni/pull/4/#discussion_r553623394
aws-cloudformation/aws-cloudformation-resource-providers-iot#19 (comment)

object with string minLength/maxLength constraints:
CloudformationSchemas $ grep -E -C 2 -i 'type.*object' * | grep -E -i 'm[ia][nx]Length'
aws-cloudformation/aws-cloudformation-resource-providers-codeartifact#20 (comment)
aws-cloudformation/aws-cloudformation-resource-providers-codeartifact#22 (comment)

array with string minLength/maxLength constraints:
CloudformationSchemas $ grep -E -C 2 -i 'type.*array' * | grep -E -i '"m[ia][nx]Length"'
aws-cloudformation/aws-cloudformation-resource-providers-kendra#83 (comment)
https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-workspaces/pull/2#discussion_r566405923
aws-cloudformation/aws-cloudformation-resource-providers-iot#19 (comment)
aws-cloudformation/aws-cloudformation-resource-providers-sagemaker#2

@rjlohan
Copy link
Contributor

rjlohan commented Aug 12, 2020

This might be worth pushing into the validation library we use: https://github.com/everit-org/json-schema

Also need to make sure our dependencies are up to date.

@PatMyron PatMyron changed the title cfn validate fails for wrong numeric constraint. cfn validate fails for wrong min/max constraint Jan 5, 2021
@PatMyron PatMyron linked a pull request Feb 3, 2021 that will close this issue
PatMyron added a commit that referenced this issue Apr 13, 2021
@PatMyron
Copy link
Contributor

PatMyron commented Apr 13, 2021

More incorrect JSON schema keywords for specific types beyond min/max keywords like additionalProperties/additionalItems, catching in #729:

Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: EC2InboundPermissions
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: InstanceDefinitions
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: LogPaths
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: MetricGroups
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: MonitoringInputs
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: ServerProcesses
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: Tags
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: TaskProperties
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: array for property: VpcSubnets
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: ConcurrentExecutions
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: DesiredEC2Instances
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: FromPort
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: GameSessionActivationTimeoutSeconds
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: MaxConcurrentGameSessionActivations
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: MaxSize
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: MinSize
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: NewGameSessionsPerCreator
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: PolicyPeriodInMinutes
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: integer for property: ToPort
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: number for property: EstimatedInstanceWarmup
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: number for property: MaxSize
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: number for property: MinSize
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: number for property: TargetValue
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: AutoScalingGroupArn
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: BalancingStrategy
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: BuildId
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: CertificateType
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: DeleteOption
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: Description
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: EC2InstanceType
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: FleetId
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: FleetType
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: GameServerGroupArn
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: GameServerGroupName
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: GameServerProtectionPolicy
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: InstanceRoleARN
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: InstanceType
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: IpRange
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: LaunchPath
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: LaunchTemplateId
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: LaunchTemplateName
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: Name
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: NewGameSessionProtectionPolicy
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: Parameters
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: PeerVpcAwsAccountId
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: PeerVpcId
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: Protocol
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: RoleArn
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: ScriptId
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: ServerLaunchParameters
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: ServerLaunchPath
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: Version
Incorrect JSON schema keyword(s) {'additionalProperties'} for type: string for property: WeightedCapacity
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: BytesPerSecond
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: BytesScannedCutoffPerQuery
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: BytesScannedCutoffPerQuery
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: Gt
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: Gte
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: Lt
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: Lte
Incorrect JSON schema keyword(s) {'format'} for type: integer for property: Size
Incorrect JSON schema keyword(s) {'format'} for type: number for property: ProbabilityThresholdAttribute
Incorrect JSON schema keyword(s) {'format'} for type: number for property: ProbabilityThresholdAttribute

format seems intentionally used for other types?, so I guess I'll leave that out of the new validation

PatMyron added a commit that referenced this issue Apr 26, 2021
expanding type_specific_keywords similar to #414
eduardomourar pushed a commit to eduardomourar/cloudformation-cli that referenced this issue Apr 30, 2021
kddejong pushed a commit to kddejong/cloudformation-cli that referenced this issue Oct 24, 2022
kddejong pushed a commit to kddejong/cloudformation-cli that referenced this issue Oct 24, 2022
awesomedevchris pushed a commit to awesomedevchris/awesome_app that referenced this issue Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working schema processing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants