active_hashcash 0.6.0 → 0.6.1

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: 0c53df9a89fac1a14b89fb109520d7b2c35d1455b3b2624d9200186d9a295cf7
4
- data.tar.gz: d090c36da4d4d17f80b5d7a653cbe2544fc311cdcf63a97bd3b46d1cf944631b
3
+ metadata.gz: abcb93cb16e4d2dd9dd6b7ac7706f4aa9ad03543828c2a67490f3cdba49d5c1c
4
+ data.tar.gz: f004201911b2a75db4bbcaf002a697c4c55e8e139a51c348a28b845d65f3f22a
5
5
  SHA512:
6
- metadata.gz: cde7a3bfff3389e1761e461dad1a44a2fd480078fd5fb80362c59f5a4a8f8601feff6a9bf28785bab757abf725213060bffaa724815c8a131b3424f7145bedb5
7
- data.tar.gz: 3f1c4d3842d4ef2aa871c986d36a9557c3c2b5f94145cdb65375dff56bf3a8e8bd5a24e718783962c3f4a5aaacfef709ae5c2f063b79794fec728ac3c9ef1aab
6
+ metadata.gz: 7a156de1587f52cc2f4f03ac10dae94146d3dc10f2da06aba6663931b00c6789b20c04897ed78f43dda2cfeb89153e6222f18080cb26adfa423552cb2203db8c
7
+ data.tar.gz: cd56b11ebd6fc83f647a292969bda59e9806afae9b5502adaf95d5bdf1f8b62a22ea74206d98714cfca0ddbbd0ba1a6fff2112467af028c5b82261dcbaf718e9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog of ActiveHashcash
2
2
 
3
+ ## 0.6.1 (2026-11-11)
4
+
5
+ - Reject non-canonical stamps so one proof of work cannot be spent multiple times (@schmijos)
6
+ - Treat unparsable stamp dates as invalid hashcash instead of raising a server error (@schmijos)
7
+ - Cap stamp field lengths to prevent storage bloat and index overflow errors (@schmijos)
8
+
3
9
  ## 0.6.0 (2026-09-22)
4
10
 
5
11
  - Penalize bad IPs reported by FireHOL lists. For this feature to do anything you must run the migration and schedule the sync job from a cron:
@@ -5,6 +5,7 @@ module ActiveHashcash
5
5
  # Unless you need something really specific, you should not need interact directly with that class.
6
6
  class Stamp < ApplicationRecord
7
7
  validates_presence_of :version, :bits, :date, :resource, :rand, :counter
8
+ validates_length_of :version, :resource, :ext, :rand, :counter, maximum: 255
8
9
 
9
10
  scope :created_from, -> (date) { where(created_at: date..) }
10
11
  scope :created_to, -> (date) { where(created_at: ..date) }
@@ -48,6 +49,7 @@ module ActiveHashcash
48
49
  # Saving in the database prevent from double spending the same stamp.
49
50
  def self.spend(string, resource, bits, date, options = {})
50
51
  return false unless stamp = parse(string)
52
+ return false if stamp.to_s != string.to_s
51
53
  stamp.attributes = options
52
54
  stamp.verify(resource, bits, date) && stamp.save
53
55
  rescue ActiveRecord::RecordNotUnique
@@ -61,6 +63,8 @@ module ActiveHashcash
61
63
  args = string.to_s.split(":")
62
64
  return if args.size != 7
63
65
  new(version: args[0], bits: args[1], date: Date.strptime(args[2], ActiveHashcash.date_format), resource: args[3], ext: args[4], rand: args[5], counter: args[6])
66
+ rescue Date::Error
67
+ nil
64
68
  end
65
69
 
66
70
  def self.mint(resource, attributes = {})
@@ -1,3 +1,3 @@
1
1
  module ActiveHashcash
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_hashcash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard