sitegoose 0.3.7 → 0.3.8

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
  SHA256:
3
- metadata.gz: f9f39eed7c9a7192621ff68704361c87a26581bf3c0614f2c087d818ab1cb06b
4
- data.tar.gz: 42a640b58f7029c07493cf7c6c3d574485ace71031d6be81d9467172b5b3f07b
3
+ metadata.gz: 7c6553a95ccdc7a0298bc4668238349e5db5fa55bc9f51031affc0ebb845cfb3
4
+ data.tar.gz: 2ab74e0aa776b017a3e1bcca3ffd635c003aa083355c6749c0d400d5da742462
5
5
  SHA512:
6
- metadata.gz: 884734d7932019e61d89c1d50c3040cdbbe002225993222bb85bf138d84051d90a668de178b83416dce86bb88065886bd5748d0bd1df4c5b73ac0a046eec62d9
7
- data.tar.gz: e0db299aca1229d854b6da784635f8a41796c8ea817d7dd1ffb32e7f91c46b7e2a01a3a3cd0eee83d11e5dfa2fcdc5e5fee60d2f53c18d8305b897a0245df233
6
+ metadata.gz: e3e184e3fa7e6377cc4c8fde76eafa375f22baa66a9603e843a4370682015361b7f6a28627b5f7496582504e7cd527ee5449f1bddba49433fbb2abfd1c363445
7
+ data.tar.gz: 4c9d5856d64163ee84663fdc4ea8c570cb89970de3d9e752c15e8a2711bcdb3087fb02fd5fe876b354f5378ee66f4a5d3068a5942ba41859b5c6260e71e48b3d
@@ -124,7 +124,7 @@ module SiteGoose
124
124
  # A request another site made the browser send (firewall.md, "Checking a
125
125
  # request"): an <img> or a no-cors fetch on any page can ask for /.env,
126
126
  # or for a page 120 times a minute, from the visitor's own address. It
127
- # is refused but bans no one, and is reported as only watched.
127
+ # is refused but bans no one, and is reported as refused.
128
128
  def self.foreign?(fetch_site)
129
129
  %w[cross-site same-site].include?(SiteGoose.text(fetch_site).strip.downcase)
130
130
  end
@@ -561,10 +561,10 @@ module SiteGoose
561
561
  decision = if rule.empty?
562
562
  allow
563
563
  else
564
- # Reported as watched, so the collector bans no one elsewhere
564
+ # Reported as refused, so the collector bans no one elsewhere
565
565
  # and counts nothing toward `shared`.
566
- foreign = !bans && (%w[probe rate].include?(rule) || rule.start_with?("request:"))
567
- report(event.call(rule, foreign ? "monitor" : action))
566
+ foreign = !bans && action == "block" && (%w[probe rate].include?(rule) || rule.start_with?("request:"))
567
+ report(event.call(rule, foreign ? "refused" : action))
568
568
  if limit_window
569
569
  # retry_after: the limit's own window, which the 429 carries.
570
570
  { action: action, rule: rule, status: 429, retry_after: limit_window }
@@ -87,8 +87,11 @@ module SiteGoose
87
87
  @core.log("forms", "the site secret was refused; forms aren't checked") if res&.status == 403
88
88
  return unchecked
89
89
  end
90
- data = res.json
91
- data = {} unless data.is_a?(Hash)
90
+ data = res.status == 200 ? res.json : nil
91
+ # A verdict, spam or not, is always a 200 with `success`. Anything else
92
+ # judged nothing, and must not look like protection that works.
93
+ return unchecked unless data.is_a?(Hash) && [true, false].include?(data["success"])
94
+
92
95
  spam = data["success"] == false
93
96
  { ok: !spam, spam: spam, reasons: Array(data["reasons"]), checked: true }
94
97
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SiteGoose
4
- VERSION = "0.3.7"
4
+ VERSION = "0.3.8"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitegoose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - steviec87