statelint 0.1.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +3 -1
- data/data/StateMachine.j2119 +11 -6
- data/lib/statelint.rb +0 -1
- data/lib/statelint/state_node.rb +41 -5
- data/statelint.gemspec +12 -5
- metadata +22 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c3084f3b4eea83b19e2d4bf60acf70ecf6e8bd151c1f86007203bfd8139c7c6d
|
4
|
+
data.tar.gz: e3f789d73ddde2eaa63f215598e907df32058bea101a608d68f6a66801e8703c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b59e83552e82a3e5333d79d99bfd8d19f4e416ab14ed7b1677f78ad48624d98d9384f048836b57f78ecb4480230816f9019218c1e2e46ef104d9e331140da024
|
7
|
+
data.tar.gz: 81173298fa0eb6dc22d02dbcf957dca86343f1b6713b5b2e3cef9809eb5a377de4e727189a4ef1ca1d32eddf3e416bf9f51de8d95ea3c073254265f718442ac1
|
data/Gemfile
CHANGED
data/data/StateMachine.j2119
CHANGED
@@ -4,7 +4,7 @@ A State Machine MUST have a string field named "StartAt".
|
|
4
4
|
A State Machine MAY have a string field named "Comment".
|
5
5
|
A State Machine MAY have a string field named "Version".
|
6
6
|
A State Machine MAY have a positive-integer field named "TimeoutSeconds" whose value MUST be less than 99999999.
|
7
|
-
A State MUST have a string field named "Type" whose value MUST be one of "Pass", "Succeed", "Fail", "Task", "Choice", "Wait", or "
|
7
|
+
A State MUST have a string field named "Type" whose value MUST be one of "Pass", "Succeed", "Fail", "Task", "Choice", "Wait", "Parallel", or "Map".
|
8
8
|
A State whose "Type" field's value is "Pass" is a "Pass State".
|
9
9
|
A State whose "Type" field's value is "Succeed" is a "Succeed State".
|
10
10
|
A State whose "Type" field's value is "Fail" is a "Fail State".
|
@@ -12,21 +12,23 @@ A State whose "Type" field's value is "Task" is a "Task State".
|
|
12
12
|
A State whose "Type" field's value is "Choice" is a "Choice State".
|
13
13
|
A State whose "Type" field's value is "Wait" is a "Wait State".
|
14
14
|
A State whose "Type" field's value is "Parallel" is a "Parallel State".
|
15
|
+
A State whose "Type" field's value is "Map" is a "Map State".
|
15
16
|
A State MAY have a string field named "Comment".
|
16
|
-
Each of a Pass State, a Task State,
|
17
|
+
Each of a Pass State, a Task State, a Wait State, a Parallel State, and a Map State MAY have a boolean field named "End".
|
18
|
+
Each of a Pass State, a Task State, a Parallel State, and a Map State MAY have a field named "Parameters".
|
17
19
|
A State whose "End" field's value is true is a "Terminal State".
|
18
20
|
Each of a Succeed State and a Fail State is a "Terminal State".
|
19
21
|
A State which is not a Terminal State or a Choice State MUST have a string field named "Next".
|
20
22
|
A Terminal State MUST NOT have a field named "Next".
|
21
23
|
A State MAY have a nullable-JSONPath field named "InputPath".
|
22
|
-
Each of a Pass State, a Task State, a
|
24
|
+
Each of a Pass State, a Task State, a Parallel State, and a Map State MAY have a nullable-referencePath field named "ResultPath".
|
23
25
|
A State MAY have a nullable-JSONPath field named "OutputPath".
|
24
26
|
A Pass State MAY have a field named "Result".
|
25
27
|
A Fail State MUST NOT have a field named "InputPath".
|
26
28
|
A Fail State MUST NOT have a field named "OutputPath".
|
27
29
|
A Fail State MAY have a string field named "Cause".
|
28
30
|
A Fail State MAY have a string field named "Error".
|
29
|
-
Each of a Task State and a
|
31
|
+
Each of a Task State, a Parallel State, and a Map State MAY have an object-array field named "Retry"; each element is a "Retrier".
|
30
32
|
A Task State MUST have a URI field named "Resource".
|
31
33
|
A Task State MAY have a positive-integer field named "TimeoutSeconds" whose value MUST be less than 99999999.
|
32
34
|
A Task State MAY have a positive-integer field named "HeartbeatSeconds" whose value MUST be less than 99999999.
|
@@ -34,7 +36,7 @@ A Retrier MUST have a nonempty-string-array field named "ErrorEquals".
|
|
34
36
|
A Retrier MAY have an positive-integer field named "IntervalSeconds".
|
35
37
|
A Retrier MAY have a nonnegative-integer field named "MaxAttempts" whose value MUST be less than 99999999.
|
36
38
|
A Retrier MAY have a float field named "BackoffRate" whose value MUST be greater than or equal to 1.0.
|
37
|
-
Each of a Task State and a
|
39
|
+
Each of a Task State, a Parallel State, and a Map State MAY have an object-array field named "Catch"; each element is a "Catcher".
|
38
40
|
A Catcher MUST have an nonempty-string-array field named "ErrorEquals".
|
39
41
|
A Catcher MUST have a string field named "Next".
|
40
42
|
A Catcher MAY have a nullable-referencePath field named "ResultPath".
|
@@ -106,6 +108,9 @@ A Wait State MAY have a referencePath field named "TimestampPath".
|
|
106
108
|
A Wait State MUST have only one of "Seconds", "SecondsPath", "Timestamp", and "TimestampPath".
|
107
109
|
A Wait State MUST have a field named one of "Seconds", "SecondsPath", "Timestamp", or "TimestampPath".
|
108
110
|
A Parallel State MUST have an object-array field named "Branches"; each element is a "Branch".
|
109
|
-
A
|
111
|
+
A Map State MUST have an object field named "Iterator"; its value is a "Branch".
|
112
|
+
A Map State MAY have a referencePath field named "ItemsPath".
|
113
|
+
A Map State MAY have a numeric field named "MaxConcurrency".
|
114
|
+
A Branch MUST have an object field named "States"; each field is a "State".
|
110
115
|
A Branch MUST have a string field named "StartAt".
|
111
116
|
A Branch MAY have a string field named "Comment".
|
data/lib/statelint.rb
CHANGED
data/lib/statelint/state_node.rb
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
# permissions and limitations under the License.
|
13
13
|
#!/usr/bin/env ruby
|
14
14
|
|
15
|
+
require 'j2119'
|
16
|
+
|
15
17
|
module StateMachineLint
|
16
18
|
|
17
19
|
# Semantic validation that can't be expressed in a J2119 schema
|
@@ -19,7 +21,7 @@ module StateMachineLint
|
|
19
21
|
class StateNode
|
20
22
|
|
21
23
|
def initialize
|
22
|
-
# We push States nodes on here when we traverse them.
|
24
|
+
# We push States nodes on here when we traverse them.
|
23
25
|
# Then, whenever we find a "Next" or "Default" or "StartAt" node,
|
24
26
|
# we validate that the target is there, and record that that
|
25
27
|
# target has an incoming pointer
|
@@ -52,7 +54,13 @@ module StateMachineLint
|
|
52
54
|
@current_states_incoming << []
|
53
55
|
end
|
54
56
|
|
55
|
-
node['States']
|
57
|
+
states = node['States']
|
58
|
+
states.keys.each do |name|
|
59
|
+
child = states[name]
|
60
|
+
if child.is_a?(Hash) && child.key?('Parameters')
|
61
|
+
probe_parameters(child, path + '.' + name, problems)
|
62
|
+
end
|
63
|
+
|
56
64
|
if @all_state_names[name]
|
57
65
|
problems <<
|
58
66
|
"State \"#{name}\", defined at #{path}.States, " +
|
@@ -66,7 +74,7 @@ module StateMachineLint
|
|
66
74
|
check_for_terminal(node, path, problems)
|
67
75
|
|
68
76
|
check_next(node, path, problems)
|
69
|
-
|
77
|
+
|
70
78
|
check_States_ALL(node['Retry'], path + '.Retry', problems)
|
71
79
|
check_States_ALL(node['Catch'], path + '.Catch', problems)
|
72
80
|
|
@@ -113,6 +121,34 @@ module StateMachineLint
|
|
113
121
|
end
|
114
122
|
end
|
115
123
|
|
124
|
+
# Search through Parameters for object nodes and check field semantics
|
125
|
+
def probe_parameters(node, path, problems)
|
126
|
+
if node.is_a?(Hash)
|
127
|
+
node.each do |name, val|
|
128
|
+
if name.end_with? '.$'
|
129
|
+
if (!val.is_a?(String)) || (!is_valid_parameters_path?(val))
|
130
|
+
problems << "Field \"#{name}\" of Parameters at \"#{path}\" is not a JSONPath"
|
131
|
+
end
|
132
|
+
else
|
133
|
+
probe_parameters(val, "#{path}.#{name}", problems)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
elsif node.is_a?(Array)
|
137
|
+
node.size.times {|i| probe_parameters(node[i], "#{path}[#{i}]", problems) }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Check if a string that ends with ".$" is a valid path
|
142
|
+
def is_valid_parameters_path?(val)
|
143
|
+
# If the value begins with “$$”, the first dollar character is stripped off and the remainder MUST be a Path.
|
144
|
+
if val.start_with?("$$")
|
145
|
+
path_to_check = val.gsub(/^\$/, "")
|
146
|
+
J2119::JSONPathChecker.is_path?(path_to_check)
|
147
|
+
else
|
148
|
+
J2119::JSONPathChecker.is_path?(val)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
116
152
|
def check_for_terminal(node, path, problems)
|
117
153
|
if node['States'] && node['States'].is_a?(Hash)
|
118
154
|
terminal_found = false
|
@@ -131,12 +167,12 @@ module StateMachineLint
|
|
131
167
|
end
|
132
168
|
end
|
133
169
|
end
|
134
|
-
|
170
|
+
|
135
171
|
def check_States_ALL(node, path, problems)
|
136
172
|
if !node.is_a?(Array)
|
137
173
|
return
|
138
174
|
end
|
139
|
-
|
175
|
+
|
140
176
|
i = 0
|
141
177
|
node.each do |element|
|
142
178
|
if element.is_a?(Hash)
|
data/statelint.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'statelint'
|
3
|
-
s.version = '0.1
|
4
|
-
s.date = '2016-09-28'
|
3
|
+
s.version = '0.4.1'
|
5
4
|
s.summary = "State Machine JSON validator"
|
6
5
|
s.description = "Validates a JSON object representing a State Machine"
|
7
6
|
s.authors = ["Tim Bray"]
|
@@ -11,7 +10,15 @@ Gem::Specification.new do |s|
|
|
11
10
|
f.match(%r{^(spec|test)/})
|
12
11
|
end
|
13
12
|
|
14
|
-
s.homepage = '
|
15
|
-
s.license = 'Apache
|
16
|
-
|
13
|
+
s.homepage = 'https://github.com/awslabs/statelint'
|
14
|
+
s.license = 'Apache-2.0'
|
15
|
+
|
16
|
+
s.required_ruby_version = '>= 1.9.2'
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'j2119', '~> 0.4', '>= 0.4.0'
|
19
|
+
|
20
|
+
s.metadata = {
|
21
|
+
'source_code_uri' => 'https://github.com/awslabs/statelint',
|
22
|
+
"bug_tracker_uri" => 'https://github.com/awslabs/statelint/issues'
|
23
|
+
}
|
17
24
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statelint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Bray
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: j2119
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.4.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.4'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 0.4.0
|
27
33
|
description: Validates a JSON object representing a State Machine
|
28
34
|
email: timbray@amazon.com
|
29
35
|
executables:
|
@@ -31,7 +37,7 @@ executables:
|
|
31
37
|
extensions: []
|
32
38
|
extra_rdoc_files: []
|
33
39
|
files:
|
34
|
-
- .gitignore
|
40
|
+
- ".gitignore"
|
35
41
|
- Gemfile
|
36
42
|
- LICENSE
|
37
43
|
- NOTICE.txt
|
@@ -42,27 +48,29 @@ files:
|
|
42
48
|
- lib/statelint.rb
|
43
49
|
- lib/statelint/state_node.rb
|
44
50
|
- statelint.gemspec
|
45
|
-
homepage:
|
51
|
+
homepage: https://github.com/awslabs/statelint
|
46
52
|
licenses:
|
47
|
-
- Apache
|
48
|
-
metadata:
|
53
|
+
- Apache-2.0
|
54
|
+
metadata:
|
55
|
+
source_code_uri: https://github.com/awslabs/statelint
|
56
|
+
bug_tracker_uri: https://github.com/awslabs/statelint/issues
|
49
57
|
post_install_message:
|
50
58
|
rdoc_options: []
|
51
59
|
require_paths:
|
52
60
|
- lib
|
53
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
62
|
requirements:
|
55
|
-
- -
|
63
|
+
- - ">="
|
56
64
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
65
|
+
version: 1.9.2
|
58
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
67
|
requirements:
|
60
|
-
- -
|
68
|
+
- - ">="
|
61
69
|
- !ruby/object:Gem::Version
|
62
70
|
version: '0'
|
63
71
|
requirements: []
|
64
72
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.
|
73
|
+
rubygems_version: 2.7.4
|
66
74
|
signing_key:
|
67
75
|
specification_version: 4
|
68
76
|
summary: State Machine JSON validator
|