conjur-policy-parser 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ class Object
2
+ # Dear Ruby, I wish instance variables order was stable, because if it was
3
+ # then YAML would always come out the same.
4
+ def to_yaml_properties
5
+ instance_variables.sort
6
+ end
7
+ end
8
+
9
+ module Conjur
10
+ module Policy
11
+ module YAML
12
+ class Loader
13
+ class << self
14
+ def load yaml, filename = nil
15
+ dirname = if filename
16
+ File.dirname(filename)
17
+ else
18
+ '.'
19
+ end
20
+
21
+ parser = Psych::Parser.new(handler = Handler.new)
22
+ handler.filename = filename
23
+ handler.parser = parser
24
+ begin
25
+ parser.parse(yaml)
26
+ rescue
27
+ handler.log { $!.message }
28
+ handler.log { $!.backtrace.join(" \n") }
29
+ raise Invalid.new($!.message || "(no message)", filename, parser.mark)
30
+ end
31
+ records = handler.result
32
+
33
+ parse_includes records, dirname
34
+
35
+ records
36
+ end
37
+
38
+ def load_file filename
39
+ load File.read(filename), filename
40
+ end
41
+
42
+ protected
43
+
44
+ def parse_includes records, dirname
45
+ records.each_with_index do |record, idx|
46
+ if record.is_a?(Array)
47
+ parse_includes record, dirname
48
+ elsif record.is_a?(Types::Policy)
49
+ parse_includes record.body, dirname
50
+ elsif record.is_a?(Types::Include)
51
+ included = load File.read(File.expand_path(record.file, dirname)), record.file
52
+ records[idx..idx] = included
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,205 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: conjur-policy-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.12.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Gilpin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: safe_yaml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-expectations
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ci_reporter_rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - kgilpin@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - .gitignore
147
+ - .project
148
+ - .rspec
149
+ - .travis.yml
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - ci/test.sh
157
+ - conjur-policy-parser.gemspec
158
+ - jenkins.sh
159
+ - lib/conjur-policy-parser-version.rb
160
+ - lib/conjur-policy-parser.rb
161
+ - lib/conjur/policy/doc.rb
162
+ - lib/conjur/policy/invalid.rb
163
+ - lib/conjur/policy/logger.rb
164
+ - lib/conjur/policy/resolver.rb
165
+ - lib/conjur/policy/types/base.rb
166
+ - lib/conjur/policy/types/create.rb
167
+ - lib/conjur/policy/types/deny.rb
168
+ - lib/conjur/policy/types/give.rb
169
+ - lib/conjur/policy/types/grant.rb
170
+ - lib/conjur/policy/types/include.rb
171
+ - lib/conjur/policy/types/member.rb
172
+ - lib/conjur/policy/types/permit.rb
173
+ - lib/conjur/policy/types/policy.rb
174
+ - lib/conjur/policy/types/records.rb
175
+ - lib/conjur/policy/types/retire.rb
176
+ - lib/conjur/policy/types/revoke.rb
177
+ - lib/conjur/policy/types/update.rb
178
+ - lib/conjur/policy/yaml/handler.rb
179
+ - lib/conjur/policy/yaml/loader.rb
180
+ homepage: https://github.com/conjurinc/conjur-policy-parser
181
+ licenses:
182
+ - MIT
183
+ metadata: {}
184
+ post_install_message:
185
+ rdoc_options: []
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ requirements: []
199
+ rubyforge_project:
200
+ rubygems_version: 2.0.14.1
201
+ signing_key:
202
+ specification_version: 4
203
+ summary: Parse the Conjur policy YAML format.
204
+ test_files: []
205
+ has_rdoc: