-
Notifications
You must be signed in to change notification settings - Fork 163
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
catch common resource schema issues in cfn validate #675
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2d7c0f1
catching non-ASCII characters
PatMyron 27f97ac
test resource schemas with common issue warnings
PatMyron 8fb40f2
patterns/enums
PatMyron b9deeb5
test resource schemas with common issue warnings
PatMyron cee7bb7
lowercase properties and incorrect min/max constraints
PatMyron 7bf5383
test resource schemas with common issue warnings
PatMyron 425788e
pre-commit
PatMyron 4ca0528
iterating properties instead of just property names
PatMyron 99e7dec
checking definitions in addition to properties
PatMyron df38768
using JsonSchemaFlattener
PatMyron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"typeName" : "AWS::Service::Type", | ||
"description" : "", | ||
"additionalProperties" : false, | ||
"properties" : { | ||
"property" : { | ||
"type" : "string" | ||
} | ||
}, | ||
"readOnlyProperties": [ | ||
"/properties/property" | ||
], | ||
"primaryIdentifier" : [ "/properties/property" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"typeName" : "AWS::Service::Type", | ||
"description" : "🤠", | ||
"additionalProperties" : false, | ||
"properties" : { | ||
"Property" : { | ||
"type" : "string" | ||
} | ||
}, | ||
"readOnlyProperties": [ | ||
"/properties/Property" | ||
], | ||
"primaryIdentifier" : [ "/properties/Property" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"typeName" : "AWS::Service::Type", | ||
"description" : "", | ||
"additionalProperties" : false, | ||
"properties" : { | ||
"Property" : { | ||
"type" : "string", | ||
"pattern" : "arn:aws:[A-Za-z0-9]+{1,255}", | ||
"enum" : [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ], | ||
"minimum" : 0 | ||
} | ||
}, | ||
"readOnlyProperties": [ | ||
"/properties/Property" | ||
], | ||
"primaryIdentifier" : [ "/properties/Property" ] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this type of testing. Get rid of some of the java patterns would be helpful. My question is the python re the one we want to standardize on? For instance
^[\d\w-_.+]*$
is technically valid but in python it needs to be^[\d\w\-_.+]*$
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, resource schema patterns should be valid and equivalent in both Python and Java (and more)
JSON schema itself recommends sticking to a minimal subset of regular expression syntax. Let's encourage the same
Just emitting warnings for patterns not valid in Python seems like a good start in that direction:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed completely here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Golang has some interesting regex limitations even within that minimal subset:
hashicorp/terraform-provider-awscc#88
golang/go#7252