attacked 0.1.0 → 1.0.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 +4 -4
- data/README.md +10 -2
- data/app/models/attacked/blocked_ip_address.rb +5 -5
- data/db/migrate/20220104121238_create_attacked_blocked_ip_addresses.rb +1 -1
- data/lib/attacked/version.rb +1 -1
- data/lib/attacked.rb +10 -0
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aeb323131d526113f62aa3a7acfa4842a4fcd8d9c1ba79fddab258fc7521f3d3
|
|
4
|
+
data.tar.gz: f957cedf0d9501e5e0405ffd2412f90dae7d4a75969e5be185678f0fb3a775ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ae73b71d77ef6133c287581dbfabe9edf29fa89562c85a4d7f2fc3e9b9e4968819617d5b27fb39744e6046b26158a753e1aea958c635f779bc7228c383679289
|
|
7
|
+
data.tar.gz: 23523e71a0224c746be7416fad7ca46811635111b839228a573e6c37c0b7e246c103514d4aa1725516d72af9db80a67fd748a274711bfd5d993e9a5b584118bd
|
data/README.md
CHANGED
|
@@ -39,13 +39,21 @@ Install [rack-attack](https://github.com/rack/rack-attack) as usual and setup a
|
|
|
39
39
|
# Block attacks from IPs
|
|
40
40
|
# To block an IP: Attacked::BlockedIpAddress.block("1.2.3.4")
|
|
41
41
|
# To unblock an IP: Attacked::BlockedIpAddress.unblock("1.2.3.4")
|
|
42
|
-
blocklist("
|
|
42
|
+
blocklist("block_ips") do |req|
|
|
43
43
|
Attacked::BlockedIpAddress.blocked?(req.ip)
|
|
44
44
|
end
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Please note that `Attacked` defaults to using the `Rails.cache` when caching blocked
|
|
48
|
-
IP addresses. As such you must setup a cache store for your application.
|
|
48
|
+
IP addresses. As such you must setup a cache store for your application. If you'd like
|
|
49
|
+
to setup a custom cache store you can create a `config/initializers/attacked.rb` and configure
|
|
50
|
+
the cache store:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
Attacked.config do |config|
|
|
54
|
+
config.cache = ActiveSupport::Cache::MemCacheStore.new("localhost", "server-downstairs.localnetwork:8229")
|
|
55
|
+
end
|
|
56
|
+
```
|
|
49
57
|
|
|
50
58
|
### Usage
|
|
51
59
|
|
|
@@ -15,7 +15,7 @@ module Attacked
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
def self.blocked?(ip_address)
|
|
18
|
-
|
|
18
|
+
Attacked.cache.read(blocked_cache_key(ip_address)) ? true : false
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def self.block(ip_address)
|
|
@@ -34,19 +34,19 @@ module Attacked
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
36
|
def create_in_cache
|
|
37
|
-
|
|
37
|
+
Attacked.cache.write(blocked_cache_key(ip_address), true)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def remove_from_cache
|
|
41
|
-
|
|
41
|
+
Attacked.cache.delete(blocked_cache_key(ip_address))
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def self.blocked_cache_key(ip_address)
|
|
45
|
-
"
|
|
45
|
+
"attacked_blocked_ip_#{ip_address}"
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def blocked_cache_key(ip_address)
|
|
49
|
-
"
|
|
49
|
+
"attacked_blocked_ip_#{ip_address}"
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class CreateAttackedBlockedIpAddresses < ActiveRecord::Migration[5.1]
|
|
2
2
|
def change
|
|
3
3
|
create_table :attacked_blocked_ip_addresses do |t|
|
|
4
|
-
t.string :ip_address, index: { unique: true }
|
|
4
|
+
t.string :ip_address, index: { unique: true, name: "idx_attacked_blocked_ip_on_ip" }
|
|
5
5
|
t.text :description
|
|
6
6
|
t.timestamps
|
|
7
7
|
end
|
data/lib/attacked/version.rb
CHANGED
data/lib/attacked.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: attacked
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Murray Summers
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -57,7 +57,7 @@ metadata:
|
|
|
57
57
|
homepage_uri: https://github.com/murraysum/attacked
|
|
58
58
|
source_code_uri: https://github.com/murraysum/attacked
|
|
59
59
|
changelog_uri: https://github.com/murraysum/attacked
|
|
60
|
-
post_install_message:
|
|
60
|
+
post_install_message:
|
|
61
61
|
rdoc_options: []
|
|
62
62
|
require_paths:
|
|
63
63
|
- lib
|
|
@@ -72,8 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
73
|
version: '0'
|
|
74
74
|
requirements: []
|
|
75
|
-
rubygems_version: 3.
|
|
76
|
-
signing_key:
|
|
75
|
+
rubygems_version: 3.4.10
|
|
76
|
+
signing_key:
|
|
77
77
|
specification_version: 4
|
|
78
78
|
summary: Manage a persisted list of blocked IP addresses
|
|
79
79
|
test_files: []
|