semian 0.19.1 → 0.20.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6bae2b0df6fceb44b91a57900ba40be6b53588866025c269627b08c2ccfa193
4
- data.tar.gz: f11b8fb67e10cfbb5f1fe393225a45ba0836324768e5fa01366f760151b635b3
3
+ metadata.gz: bf43c5c57553b9262a1c1c4ef782fe92483480c1793604c9d0c7b328b907de53
4
+ data.tar.gz: c8d73c47247f10cdac57053356f61e65bdb5f38c134b2122f030e42dc175b26d
5
5
  SHA512:
6
- metadata.gz: b39cc0bfcf4341bd0a008f50109abb77f27b75021c28245d4c8e4b2af3bb78ca4611deef872c3b40714d4047a8ede6bcfc88cd426a8866f2e51249f3606aefb4
7
- data.tar.gz: 89829e6fb002b9d96c2b96ede7339e10e7d3e1c6fee8d8d023b831747e969622d08342e07d7e0cd7ce31f433239e984b881417140e15a9a736501a62c941c79b
6
+ metadata.gz: e6c96130e5c56f963e7ab63f1d561c843a8d3ff93593981bfe819d034dcf3c3e88a4a3a00b35c8779b8529629ea8fa29cd06e73acec0233ec1b909bd32184057
7
+ data.tar.gz: 589794eedc49e355705f82271743346a289f10aba2089d80a89a9eade0fa4a221d5476142e3c20aee3a501139ceb6c82217bed378842e6f91cc6f5cb54fc5636
@@ -15,6 +15,8 @@ end
15
15
 
16
16
  require "mkmf"
17
17
 
18
+ dir_config("openssl")
19
+
18
20
  abort "openssl is missing. please install openssl." unless find_header("openssl/sha.h")
19
21
  abort "openssl is missing. please install openssl." unless find_library("crypto", "SHA1")
20
22
 
@@ -359,12 +359,6 @@ ms_to_timespec(long ms, struct timespec *ts)
359
359
  ts->tv_nsec = (ms % 1000) * 1000000;
360
360
  }
361
361
 
362
- static void
363
- semian_resource_mark(void *ptr)
364
- {
365
- /* noop */
366
- }
367
-
368
362
  static void
369
363
  semian_resource_free(void *ptr)
370
364
  {
@@ -386,7 +380,7 @@ static const rb_data_type_t
386
380
  semian_resource_type = {
387
381
  "semian_resource",
388
382
  {
389
- semian_resource_mark,
383
+ NULL,
390
384
  semian_resource_free,
391
385
  semian_resource_memsize
392
386
  },
@@ -9,7 +9,7 @@ module ActiveRecord
9
9
  class TrilogyAdapter
10
10
  ActiveRecord::ActiveRecordError.include(::Semian::AdapterError)
11
11
 
12
- class SemianError < StatementInvalid
12
+ class SemianError < ConnectionNotEstablished
13
13
  def initialize(semian_identifier, *args)
14
14
  super(*args)
15
15
  @semian_identifier = semian_identifier
@@ -82,26 +82,16 @@ module Semian
82
82
 
83
83
  private
84
84
 
85
- def acquire_semian_resource(**)
86
- super
87
- rescue ActiveRecord::StatementInvalid => error
88
- if error.cause.is_a?(Trilogy::TimeoutError)
89
- semian_resource.mark_failed(error)
90
- error.semian_identifier = semian_identifier
91
- end
92
- raise
93
- end
94
-
95
85
  def resource_exceptions
96
- [ActiveRecord::ConnectionNotEstablished]
86
+ [
87
+ ActiveRecord::AdapterTimeout,
88
+ ActiveRecord::ConnectionFailed,
89
+ ActiveRecord::ConnectionNotEstablished,
90
+ ]
97
91
  end
98
92
 
99
93
  # TODO: share this with Mysql2
100
- QUERY_ALLOWLIST = Regexp.union(
101
- %r{\A(?:/\*.*?\*/)?\s*ROLLBACK}i,
102
- %r{\A(?:/\*.*?\*/)?\s*COMMIT}i,
103
- %r{\A(?:/\*.*?\*/)?\s*RELEASE\s+SAVEPOINT}i,
104
- )
94
+ QUERY_ALLOWLIST = %r{\A(?:/\*.*?\*/)?\s*(ROLLBACK|COMMIT|RELEASE\s+SAVEPOINT)}i
105
95
 
106
96
  def query_allowlisted?(sql, *)
107
97
  QUERY_ALLOWLIST.match?(sql)
data/lib/semian/mysql2.rb CHANGED
@@ -22,8 +22,8 @@ module Semian
22
22
  include Semian::Adapter
23
23
 
24
24
  CONNECTION_ERROR = Regexp.union(
25
- /Can't connect to MySQL server on/i,
26
- /Lost connection to MySQL server/i,
25
+ /Can't connect to (?:MySQL )?server on/i,
26
+ /Lost connection to (?:MySQL )?server/i,
27
27
  /MySQL server has gone away/i,
28
28
  /Too many connections/i,
29
29
  /closed MySQL connection/i,
@@ -37,11 +37,7 @@ module Semian
37
37
  DEFAULT_HOST = "localhost"
38
38
  DEFAULT_PORT = 3306
39
39
 
40
- QUERY_WHITELIST = Regexp.union(
41
- %r{\A(?:/\*.*?\*/)?\s*ROLLBACK}i,
42
- %r{\A(?:/\*.*?\*/)?\s*COMMIT}i,
43
- %r{\A(?:/\*.*?\*/)?\s*RELEASE\s+SAVEPOINT}i,
44
- )
40
+ QUERY_ALLOWLIST = %r{\A(?:/\*.*?\*/)?\s*(ROLLBACK|COMMIT|RELEASE\s+SAVEPOINT)}i
45
41
 
46
42
  class << self
47
43
  # The naked methods are exposed as `raw_query` and `raw_connect` for instrumentation purpose
@@ -114,7 +110,7 @@ module Semian
114
110
  end
115
111
 
116
112
  def query_whitelisted?(sql, *)
117
- QUERY_WHITELIST =~ sql
113
+ QUERY_ALLOWLIST =~ sql
118
114
  rescue ArgumentError
119
115
  # The above regexp match can fail if the input SQL string contains binary
120
116
  # data that is not recognized as a valid encoding, in which case we just
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Semian
4
- VERSION = "0.19.1"
4
+ VERSION = "0.20.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Francis
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-05-16 00:00:00.000000000 Z
13
+ date: 2023-10-27 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: |2
16
16
  A Ruby C extention that is used to control access to shared resources
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.4.13
82
+ rubygems_version: 3.4.21
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Bulkheading for Ruby with SysV semaphores