saml-kit 1.5.0 → 1.5.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: 6758626dbf26ac6ea50535978aead6d9046a6dd31662cff9eb962154a682380e
4
- data.tar.gz: 8fd7df975fa700f8d969f77c2fff0f59e9829ef3bde7ab6f41a6b5a94cb208d7
3
+ metadata.gz: 55bb650eff422a517582801633097c71478c4294f5cc8a4ff5bd3842545609ff
4
+ data.tar.gz: 2b9dfe74c62d2c04cd83453f9a579a4192a854b87124de15e92d49375d31000b
5
5
  SHA512:
6
- metadata.gz: 1e80fc106bbc6e06e167c0e5b6ce7b7f09d3bf7e471558533ec2a061089dc0367d60da5a393436a9feb3e8f5b12745193d7652c29f5d9cc9dae9ecd151a42a19
7
- data.tar.gz: a3a39fcbff995f9ac1dceca502412efd165690fdd66b91d093f423d8cc1573486c95655b1f958746f98c682c48eba69357a8b058fef53d216e770c7e5b9d8620
6
+ metadata.gz: b89dcaf5a139f92e8bd641bada1226a738aaaf92a06dbfcf2004f628f4e7f56822ae4aad6276f961bb1cce7b4e9482e388d3b0e24ce90b431ab7fd187d1b3db9
7
+ data.tar.gz: a98cb7a584d24fe7a0a7093d6e1028c27d777c2d26a42b621d1d5793adee1bc7e214140a2bcaeb04d14f74ee82519cdbb01ae7fbe774d005f0567a7a07c1739d
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- Version 1.5.0
1
+ Version 1.5.1
2
2
 
3
3
  # Changelog
4
4
  All notable changes to this project will be documented in this file.
@@ -8,6 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [1.5.1] - 2026-08-18
12
+ ### Fixed
13
+ - Compile the SAML XSDs without `Dir.chdir`. Schema compilation ran inside a
14
+ `Dir.chdir` block, which mutates process global state, so two threads
15
+ validating a document at the same time could raise `conflicting chdir during
16
+ another chdir block`. Each schema is now parsed as a document carrying its own
17
+ path, so its relative imports resolve without changing the working directory.
18
+ - Compile each XSD once instead of on every `valid?` call.
19
+
11
20
  ## [1.5.0] - 2026-08-17
12
21
  ### Security
13
22
  - Reject a `Response` or `Assertion` that carries no signature. A registered
@@ -142,7 +151,8 @@ exploitable or is a side effect of closing one that was.
142
151
  ### Removed
143
152
  - Removed optional SessionNotOnOrAfter attribute from AuthnStatement.
144
153
 
145
- [Unreleased]: https://github.com/xlgmokha/saml-kit/compare/v1.5.0...HEAD
154
+ [Unreleased]: https://github.com/xlgmokha/saml-kit/compare/v1.5.1...HEAD
155
+ [1.5.1]: https://github.com/xlgmokha/saml-kit/compare/v1.5.0...v1.5.1
146
156
  [1.5.0]: https://github.com/xlgmokha/saml-kit/compare/v1.4.1...v1.5.0
147
157
  [1.4.1]: https://github.com/xlgmokha/saml-kit/compare/v1.4.0...v1.4.1
148
158
  [1.4.0]: https://github.com/xlgmokha/saml-kit/compare/v1.3.0...v1.4.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- saml-kit (1.5.0)
4
+ saml-kit (1.5.1)
5
5
  activemodel (>= 5.1)
6
6
  base64 (~> 0.1)
7
7
  cgi (~> 0.1)
@@ -13,15 +13,42 @@ module Saml
13
13
  '../xsd/saml-schema-metadata-2.0.xsd', File.dirname(__FILE__)
14
14
  ).freeze
15
15
 
16
+ @schemas = {}
17
+ @monitor = Mutex.new
18
+
19
+ class << self
20
+ # Validation treats a schema as read only, so one instance is shared
21
+ # across threads. The hit path reads without the lock, which at worst
22
+ # compiles the same schema twice on rubies that lack a global lock.
23
+ #
24
+ # @!visibility private
25
+ def schema_for(path)
26
+ @schemas[path] || @monitor.synchronize do
27
+ @schemas[path] ||= compile(path)
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ # The xsd is parsed as a document carrying its own path as a base uri,
34
+ # so the relative schemaLocation imports in our xsds resolve against
35
+ # the xsd's own directory. A bare String carries no base uri and would
36
+ # resolve them against the working directory instead, which is what
37
+ # Dir.chdir used to paper over at the cost of crashing under threads.
38
+ def compile(path)
39
+ Nokogiri::XML::Schema.from_document(
40
+ Nokogiri::XML::Document.parse(File.read(path), url: path)
41
+ )
42
+ end
43
+ end
44
+
16
45
  # @!visibility private
17
- def matches_xsd?(xsd)
46
+ def matches_xsd?(path)
18
47
  return unless to_nokogiri.present?
19
48
 
20
- Dir.chdir(File.dirname(xsd)) do
21
- xsd = Nokogiri::XML::Schema(IO.read(xsd))
22
- xsd.validate(to_nokogiri.document).each do |error|
23
- errors.add(:base, error.message)
24
- end
49
+ schema = XsdValidatable.schema_for(path)
50
+ schema.validate(to_nokogiri.document).each do |error|
51
+ errors.add(:base, error.message)
25
52
  end
26
53
  end
27
54
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Saml
4
4
  module Kit
5
- VERSION = '1.5.0'
5
+ VERSION = '1.5.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saml-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan