oso-oso 0.8.2 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d51e82a017eaa54ea9a33b9199461015e3eac36
4
- data.tar.gz: 6903b31bf79562138d28d96c1c33d51270f65ba5
3
+ metadata.gz: 108fa811ddeadbf668f15c5375ccd5c38831cfdc
4
+ data.tar.gz: 0dd84c501d529534c91c340c893bb7ab667576f0
5
5
  SHA512:
6
- metadata.gz: 91cc12a5af5fc9b16492681e398b8d09d341ac4dd4af34ca0b216c774248024723844937b1c106e7aceba03dc574b6377530cb74f2e591c86cab62ae836538df
7
- data.tar.gz: 1cd76a3ba326f3e505e956f22f41ae1a572bc995e990be19e294dae803bd0683f01b7d3589ca4a44923848deb150ccb401ee77bfaf99faacc6e9b032a61b0fe7
6
+ metadata.gz: 76965f84a8ce657cf66689a2017342908651c0bef5e12fb668357b566a8f9c22da0a9009116faf580c80313c2a060620e9543891f9e1edda36df95e542262063
7
+ data.tar.gz: 2bf2c2f309ba30ed13f6ff5cfb930e7f64d36db75376cb959d886c11f375dacb0a83fcbd6bc90cde9049aede2bf94235b599bcb5b143d89a81aac5cae9307ee9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oso-oso (0.8.2)
4
+ oso-oso (0.11.1)
5
5
  ffi (~> 1.0)
6
6
 
7
7
  GEM
@@ -14,7 +14,7 @@ GEM
14
14
  coderay (1.1.3)
15
15
  diff-lcs (1.4.4)
16
16
  e2mmap (0.1.0)
17
- ffi (1.13.1)
17
+ ffi (1.14.2)
18
18
  jaro_winkler (1.5.4)
19
19
  maruku (0.7.3)
20
20
  method_source (1.0.0)
@@ -93,4 +93,4 @@ DEPENDENCIES
93
93
  yard (~> 0.9.25)
94
94
 
95
95
  BUNDLED WITH
96
- 2.1.4
96
+ 2.2.4
Binary file
Binary file
Binary file
data/lib/oso.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'oso/http'
4
3
  require 'oso/oso'
5
- require 'oso/path_mapper'
6
4
  require 'oso/polar'
7
5
  require 'oso/version'
8
6
 
data/lib/oso/oso.rb CHANGED
@@ -7,8 +7,6 @@ module Oso
7
7
  class Oso < Polar::Polar
8
8
  def initialize
9
9
  super
10
- register_class(Http, name: 'Http')
11
- register_class(PathMapper, name: 'PathMapper')
12
10
  end
13
11
 
14
12
  # Query the knowledge base to determine whether an actor is allowed to
@@ -41,7 +41,15 @@ module Oso
41
41
  class InvalidIteratorError < PolarRuntimeError; end
42
42
  class InvalidQueryTypeError < PolarRuntimeError; end
43
43
  class NullByteInPolarFileError < PolarRuntimeError; end
44
- class UnexpectedPolarTypeError < PolarRuntimeError; end
44
+ class UnexpectedPolarTypeError < PolarRuntimeError; # rubocop:disable Style/Documentation
45
+ def initialize(tag)
46
+ if tag == 'Expression'
47
+ super(UNEXPECTED_EXPRESSION_MESSAGE)
48
+ else
49
+ super(tag)
50
+ end
51
+ end
52
+ end
45
53
  class InlineQueryFailedError < PolarRuntimeError; # rubocop:disable Style/Documentation
46
54
  # @param source [String]
47
55
  def initialize(source)
@@ -91,5 +99,11 @@ module Oso
91
99
  # Generic Polar API exception.
92
100
  class ApiError < Error; end
93
101
  class ParameterError < ApiError; end
102
+
103
+ UNEXPECTED_EXPRESSION_MESSAGE = <<~MSG
104
+ Recieved Expression from Polar VM. The Expression type is not yet supported in this language.
105
+
106
+ This may mean you performed an operation in your policy over an unbound variable.
107
+ MSG
94
108
  end
95
109
  end
@@ -46,7 +46,7 @@ module Oso
46
46
  # @raise [DuplicateClassAliasError] if attempting to register a class
47
47
  # under a previously-registered name.
48
48
  def cache_class(cls, name:)
49
- raise DuplicateClassAliasError, name: name, old: get_class(name), new: cls if classes.key? name
49
+ raise DuplicateClassAliasError.new name: name, old: get_class(name), new: cls if classes.key? name
50
50
 
51
51
  classes[name] = cls
52
52
  name
data/lib/oso/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Oso
4
- VERSION = '0.8.2'
4
+ VERSION = '0.11.1'
5
5
  end
data/oso-oso.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Oso Security, Inc.']
9
9
  spec.email = ['support@osohq.com']
10
10
  spec.licenses = ['Apache-2.0']
11
- spec.summary = 'oso authorization library.'
11
+ spec.summary = 'Oso authorization library.'
12
12
  spec.homepage = 'https://www.osohq.com/'
13
13
 
14
14
  spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oso-oso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oso Security, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-25 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -130,9 +130,7 @@ files:
130
130
  - ext/oso-oso/lib/libpolar.so
131
131
  - ext/oso-oso/lib/polar.dll
132
132
  - lib/oso.rb
133
- - lib/oso/http.rb
134
133
  - lib/oso/oso.rb
135
- - lib/oso/path_mapper.rb
136
134
  - lib/oso/polar.rb
137
135
  - lib/oso/polar/errors.rb
138
136
  - lib/oso/polar/ffi.rb
@@ -175,5 +173,5 @@ rubyforge_project:
175
173
  rubygems_version: 2.6.14.4
176
174
  signing_key:
177
175
  specification_version: 4
178
- summary: oso authorization library.
176
+ summary: Oso authorization library.
179
177
  test_files: []
data/lib/oso/http.rb DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Oso
4
- # An HTTP resource.
5
- class Http
6
- def initialize(hostname, path, query)
7
- @hostname = hostname
8
- @path = path
9
- @query = query
10
- end
11
-
12
- private
13
-
14
- attr_reader :hostname, :path, :query
15
- end
16
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Oso
4
- # Map from a template string with capture groups of the form
5
- # `{name}` to a dictionary of the form `{name: captured_value}`
6
- class PathMapper
7
- def initialize(template)
8
- capture_group = /({([^}]+)})/
9
-
10
- template = template.dup
11
- template.scan(capture_group).each do |outer, inner|
12
- template = if inner == '*'
13
- template.gsub! outer, '.*'
14
- else
15
- template.gsub! outer, "(?<#{inner}>[^/]+)"
16
- end
17
- end
18
- @pattern = /\A#{template}\Z/
19
- end
20
-
21
- def map(string)
22
- string.match(pattern)&.named_captures || {}
23
- end
24
-
25
- private
26
-
27
- attr_reader :pattern
28
- end
29
- end