graph_attack 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +13 -3
- data/lib/graph_attack/rate_limiter.rb +7 -1
- data/lib/graph_attack/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a15c0b11d8e25c73943da6bf70907df378deb42c
|
4
|
+
data.tar.gz: 25e5f9f166d1bb010eee56c7e595b126fe05b748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef5a10ecbc9cbe51553bce3936cdbee0eb3ff67bfee7b8f423bd91f2d9a7a012d6b615d2c961f16f1e5366f537ec60ba13ad5264d4141bfaca7a5fc3b25db6c4
|
7
|
+
data.tar.gz: 542014545b679ea08d44c59ec07df312f31be870d02edb88d3d6bb559948ced10ea9d566b09a7aa1e5ccd028642b230b2ebf6097b337d40108a4fbec1cb9c364
|
data/CHANGELOG.md
ADDED
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`,
|
87
|
-
run `bundle exec rake release`, which will create a git tag for the
|
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)
|
data/lib/graph_attack/version.rb
CHANGED
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.
|
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:
|
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
|