graphiti 1.2.25 → 1.2.26

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
  SHA256:
3
- metadata.gz: d5f2ffef76f6dd895acddc9a4d2deb374a3d217c94d0c85fd1feb40ecac9f369
4
- data.tar.gz: c6ce48631bf54161b0678ac5d16a8e25b49c8259ec1405138559814745569129
3
+ metadata.gz: 872977a69e5cb7a4fd2cbe93953be2dbba89868f3c41267b8a72ce22ffb5c600
4
+ data.tar.gz: 2d189dcaa525e2d5a1b2ffd752a53cc28e0e381cb2411d8530e750175f9de92c
5
5
  SHA512:
6
- metadata.gz: 0e9d797893dfad771fbfe3400fc66e5830b80e8b029a059fdc12102c904e9d535b004fb08bb4501ce190effdda6f247b476ada10c6f0f6f4d963bcb0c971ab50
7
- data.tar.gz: 5a933a0b8174449530858b06081eb09cd181d1d02f37f5befaac0e1f3dd16bf420e2e6e72d2c64a4750fd8ff2eaf3e2e333b59843c01ac613fa0c10e3e02ef0e
6
+ metadata.gz: 2e3b922df304f43f3404db5e0213dce76bd073d6d226a3c62620fc5ff0198c2a13a6c7ed3b48b92421cfb6396acb31c11e84edb099bdab915cc9b8917baa845b
7
+ data.tar.gz: 80a5f5f23638c598c64012032a7ab4aea3fc5ce515f6b72f9bdf93f19c1c50ee3fd9fd373a6ccec34e4f84f6cf3217257d10d93b4a870aa06e91be67e610c8b0
@@ -366,6 +366,20 @@ module Graphiti
366
366
  end
367
367
  end
368
368
 
369
+ class UndefinedIDLookup < Base
370
+ def initialize(resource_class)
371
+ @resource_class = resource_class
372
+ end
373
+
374
+ def message
375
+ <<~MSG
376
+ Tried to resolve #{@resource_class} with an :id filter, but the filter was nil.
377
+ This can result in unscoping a query, which can cause incorrect values to be
378
+ returned which may or may not bypass standard access controls.
379
+ MSG
380
+ end
381
+ end
382
+
369
383
  class UnknownAttribute < AttributeError
370
384
  def message
371
385
  "#{super}, but could not find an attribute with that name."
@@ -23,6 +23,9 @@ module Graphiti
23
23
 
24
24
  # @api private
25
25
  def _find(params = {}, base_scope = nil)
26
+ guard_nil_id!(params[:data])
27
+ guard_nil_id!(params)
28
+
26
29
  id = params[:data].try(:[], :id) || params.delete(:id)
27
30
  params[:filter] ||= {}
28
31
  params[:filter][:id] = id if id
@@ -52,6 +55,13 @@ module Graphiti
52
55
  end
53
56
  end
54
57
  end
58
+
59
+ def guard_nil_id!(params)
60
+ return unless params
61
+ if params.key?(:id) && params[:id].nil?
62
+ raise Errors::UndefinedIDLookup.new(self)
63
+ end
64
+ end
55
65
  end
56
66
  end
57
67
  end
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.2.25"
2
+ VERSION = "1.2.26"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.25
4
+ version: 1.2.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable