decidim-cdtb 0.6.2 → 0.6.3
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/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/config/initializers/cdtb_rack_attack.rb +30 -4
- data/lib/cdtb/ip_parser.rb +2 -0
- data/lib/decidim/cdtb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 87cfa078ca5fb059a580e029b4319a64d192a0b02e3cfd1136c2dd5d8d30a8e2
|
|
4
|
+
data.tar.gz: 2859c2bb9f9b079a672fe10600347bee48652daf70ec6810d412741765f00fdb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48af433b8ce336f0f1f78a293a0ab129543e556b574f749e8b561e149f3fda247a59a4126cd6e512e35e127e17be921f22a0ad8abc78ad687a52419e4ff74cdd
|
|
7
|
+
data.tar.gz: df959a73420d0db727c237ed5c37edbe69e79f224a2bd7bf71f335dafc02d79b3a491718763ab3b2d6ac13716825c5f3cd475e55da2f35268e821c59e9c00ffa
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## [0.6.3] - 2026-10-16 (minor)
|
|
2
|
+
|
|
3
|
+
- Implement RackAttack feature to block abuse reported IPs.
|
|
4
|
+
- Improve RackAttack tests and compatibility with subnets.
|
|
5
|
+
|
|
1
6
|
## [0.6.2] - 2026-09-10 (minor)
|
|
2
7
|
|
|
3
8
|
- Prevent `cdtb:users:remove` from enqueueing the admin block notification email when blocking users while preserving auditability and moderation records.
|
data/Gemfile.lock
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "cdtb/ip_parser"
|
|
4
|
+
require "csv"
|
|
5
|
+
require "ipaddr"
|
|
4
6
|
|
|
5
7
|
unless ENV["CDTB_RACK_ATTACK_DISABLED"].to_i.positive? || %w[development test].include?(Rails.env)
|
|
6
8
|
require "rack/attack"
|
|
@@ -36,14 +38,38 @@ unless ENV["CDTB_RACK_ATTACK_DISABLED"].to_i.positive? || %w[development test].i
|
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
Rack::Attack.blocklist("cdtb:block all PHP RQs") do |request|
|
|
39
|
-
request.path.end_with?("
|
|
41
|
+
request.path.end_with?(".php")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
ABUSE_REPORTED_IPS_CSV_PATH= ENV.fetch("ABUSE_REPORTED_IPS_CSV_PATH", nil)
|
|
45
|
+
if ABUSE_REPORTED_IPS_CSV_PATH.present? && File.exist?(ABUSE_REPORTED_IPS_CSV_PATH)
|
|
46
|
+
ABUSE_REPORTED_IPS_CACHE_KEY= ["cdtb", "reported_ips", ABUSE_REPORTED_IPS_CSV_PATH].freeze
|
|
47
|
+
Rack::Attack.blocklist("block IPs in reported website") do |request|
|
|
48
|
+
ip= Cdtb::IpParser.extract_ip(request)
|
|
49
|
+
|
|
50
|
+
reported_ips = Rails.cache.fetch(ABUSE_REPORTED_IPS_CACHE_KEY, expires_in: 1.hour) do
|
|
51
|
+
if ABUSE_REPORTED_IPS_CSV_PATH.present? && File.exist?(ABUSE_REPORTED_IPS_CSV_PATH)
|
|
52
|
+
CSV.read(ABUSE_REPORTED_IPS_CSV_PATH).flatten.compact.map(&:strip).reject(&:blank?)
|
|
53
|
+
else
|
|
54
|
+
[]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
reported_ips.any? { |reported_ip| ip.start_with?(reported_ip) }
|
|
59
|
+
end
|
|
40
60
|
end
|
|
41
61
|
|
|
42
62
|
if ENV["RACK_ATTACK_BLOCKED_IPS"].present?
|
|
43
|
-
blocked_ips_and_subnets= ENV["RACK_ATTACK_BLOCKED_IPS"].split(",")
|
|
63
|
+
blocked_ips_and_subnets= ENV["RACK_ATTACK_BLOCKED_IPS"].split(",").filter_map do |ip_or_subnet|
|
|
64
|
+
IPAddr.new(ip_or_subnet.strip)
|
|
65
|
+
rescue IPAddr::InvalidAddressError
|
|
66
|
+
nil
|
|
67
|
+
end
|
|
44
68
|
Rack::Attack.blocklist("cdtb:block all unaccepted IPs") do |request|
|
|
45
|
-
|
|
46
|
-
blocked_ips_and_subnets.any? { |ip_or_subnet|
|
|
69
|
+
request_ip= IPAddr.new(Cdtb::IpParser.extract_ip(request))
|
|
70
|
+
blocked_ips_and_subnets.any? { |ip_or_subnet| ip_or_subnet.include?(request_ip) }
|
|
71
|
+
rescue IPAddr::InvalidAddressError
|
|
72
|
+
false
|
|
47
73
|
end
|
|
48
74
|
end
|
|
49
75
|
end
|
data/lib/cdtb/ip_parser.rb
CHANGED
data/lib/decidim/cdtb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-cdtb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oliver Valls
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: decidim
|