graph_attack 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86f3e5cffd6d44474777d8922c3c4082d21143dd
4
- data.tar.gz: 2a0ad09a08d65b22c3b97752b1ce0428cc2040e9
3
+ metadata.gz: a15c0b11d8e25c73943da6bf70907df378deb42c
4
+ data.tar.gz: 25e5f9f166d1bb010eee56c7e595b126fe05b748
5
5
  SHA512:
6
- metadata.gz: 830ea8dbf7fad402e69a27bc1e05189af0488fb241580e12a65bb69eca19591552411f4868cd657fd656d989a868686564c5791b0f250bded67e26ae17389d92
7
- data.tar.gz: b7566c50d48645f92ad17bb2f5210346042c178bc10cbe91ea9d58514161570e364d898275b3dadee215588201372d2c38e78177318c10554b4760e523c91bfd
6
+ metadata.gz: ef5a10ecbc9cbe51553bce3936cdbee0eb3ff67bfee7b8f423bd91f2d9a7a012d6b615d2c961f16f1e5366f537ec60ba13ad5264d4141bfaca7a5fc3b25db6c4
7
+ data.tar.gz: 542014545b679ea08d44c59ec07df312f31be870d02edb88d3d6bb559948ced10ea9d566b09a7aa1e5ccd028642b230b2ebf6097b337d40108a4fbec1cb9c364
@@ -0,0 +1,13 @@
1
+ unreleased
2
+ ----------
3
+
4
+ v1.1.0
5
+ ------
6
+
7
+ Feature:
8
+ - Add `redis_client` option to provide a custom Redis client.
9
+
10
+ v1.0.0
11
+ ------
12
+
13
+ First release!
data/README.md CHANGED
@@ -70,6 +70,16 @@ class GraphqlController < ApplicationController
70
70
  end
71
71
  ```
72
72
 
73
+ ## Configuration
74
+
75
+ Use a custom Redis client instead of the default:
76
+
77
+ ```rb
78
+ query_analyzer GraphAttack::RateLimiter.new(
79
+ redis_client: Redis.new(url: "…")
80
+ )
81
+ ```
82
+
73
83
  ## Development
74
84
 
75
85
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -83,9 +93,9 @@ see the tags on this repository.
83
93
 
84
94
  ## Releasing
85
95
 
86
- To release a new version, update the version number in `version.rb`, and then
87
- run `bundle exec rake release`, which will create a git tag for the version,
88
- push git commits and tags, and push the `.gem` file to
96
+ To release a new version, update the version number in `version.rb`, commit,
97
+ and then run `bundle exec rake release`, which will create a git tag for the
98
+ version, push git commits and tags, and push the `.gem` file to
89
99
  [rubygems.org](https://rubygems.org).
90
100
 
91
101
  ## Contributing
@@ -9,6 +9,10 @@ module GraphAttack
9
9
  class Error < StandardError; end
10
10
  class RateLimited < GraphQL::AnalysisError; end
11
11
 
12
+ def initialize(redis_client: Redis.new)
13
+ @redis_client = redis_client
14
+ end
15
+
12
16
  def initial_value(query)
13
17
  {
14
18
  ip: query.context[:ip],
@@ -34,6 +38,8 @@ module GraphAttack
34
38
 
35
39
  private
36
40
 
41
+ attr_reader :redis_client
42
+
37
43
  def increment_rate_limit(ip, key)
38
44
  raise Error, 'Missing :ip value on the GraphQL context' unless ip
39
45
 
@@ -72,7 +78,7 @@ module GraphAttack
72
78
 
73
79
  def rate_limit(ip)
74
80
  @rate_limit ||= {}
75
- @rate_limit[ip] ||= Ratelimit.new(ip)
81
+ @rate_limit[ip] ||= Ratelimit.new(ip, redis: redis_client)
76
82
  end
77
83
 
78
84
  def rate_limited_node?(visit_type, node)
@@ -1,3 +1,3 @@
1
1
  module GraphAttack
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graph_attack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fanny Cheung
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-09-07 00:00:00.000000000 Z
12
+ date: 2019-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql
@@ -122,6 +122,7 @@ files:
122
122
  - ".rspec"
123
123
  - ".rubocop.yml"
124
124
  - ".travis.yml"
125
+ - CHANGELOG.md
125
126
  - CODE_OF_CONDUCT.md
126
127
  - Gemfile
127
128
  - LICENSE.md