openehr 2.3.1 → 2.3.2

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: 9d2c2f002014051bc668449dbd7a7c79c2a75d4664d702670e80a9307b43ffb4
4
- data.tar.gz: 374eccbd5be4cb9b76de4563a4648e5e2f346828a1abbe3988c6280de4278ecb
3
+ metadata.gz: a3d85dcafa7ccea7c1ae4a7cd794297b9b7c4b6a6126bae494fb5a6d9538fffc
4
+ data.tar.gz: 34bfec35b2de56cc2c97a02d049f6233b011d3e93908db2b5065f5fc1ede068e
5
5
  SHA512:
6
- metadata.gz: 7f5d3125c74f02accf2a6149ddfd7cfb5d79040184b1668de32a5850bf35a1464c2d448d140e865aa9e132adf3d8c93aca0d857a10c2ce96f54af2180a973c17
7
- data.tar.gz: f0707a9dc5ed67e5ba4277177c1b5b3fe8e053251ca04f06f0abf326038d430a669dd5988de8793d4486dcae087f44d11f139c23b89df2f9409ee6195c9738d4
6
+ metadata.gz: 9793f50126a31f5d84a21304cd55ecb1fcc3a65569ba9eb1c3c73de1e15ea991a7cc245cec6c37dde71ed8fa861df809d919e02e13baad328ee75d2f0b44a5c5
7
+ data.tar.gz: a79ea4ee8a7981000548c16405561f255f6c08b5a0fa413f7cc9301fa165894f1401ec0bcd9c7669f0f0018e3178cf479643212ae3feaa31c20225ef249cc35e
@@ -40,7 +40,9 @@ module OpenEHR
40
40
  OCCURRENCE_PATH = '/occurrences'
41
41
 
42
42
  def parse
43
- @opt = Nokogiri::XML::Document.parse(File.open(@filename))
43
+ @opt = File.open(@filename) do |file|
44
+ Nokogiri::XML::Document.parse(file, options: SAFE_PARSE_OPTIONS)
45
+ end
44
46
  @opt.remove_namespaces!
45
47
 
46
48
  uid = build_uid
@@ -30,7 +30,9 @@ module OpenEHR
30
30
 
31
31
  def doc
32
32
  @doc ||= begin
33
- parsed = Nokogiri::XML::Document.parse(File.open(@filename, 'rb:bom|utf-8'))
33
+ parsed = File.open(@filename, 'rb:bom|utf-8') do |file|
34
+ Nokogiri::XML::Document.parse(file, options: SAFE_PARSE_OPTIONS)
35
+ end
34
36
  parsed.remove_namespaces!
35
37
  parsed
36
38
  end
@@ -1,6 +1,34 @@
1
+ require 'nokogiri'
2
+
1
3
  module OpenEHR
2
4
  module Parser
3
5
  class Base
6
+ # Explicit, safe Nokogiri ParseOptions for untrusted OPT/archetype XML.
7
+ # Deliberately lists RECOVER|NONET|BIG_LINES by name rather than
8
+ # referencing Nokogiri::XML::ParseOptions::DEFAULT_XML - the whole
9
+ # point is to not silently follow that constant if a future Nokogiri
10
+ # release (or a downstream app pinning an older one) changes it.
11
+ #
12
+ # - RECOVER: parse malformed-but-well-intentioned XML leniently
13
+ # (matches today's implicit default; see
14
+ # docs/design/xxe-safe-parse-options-plan.md for real-fixture
15
+ # evidence that at least one downstream consumer OPT currently
16
+ # depends on this).
17
+ # - NONET: forbid network access during parsing. Nokogiri's own docs:
18
+ # "UNSAFE to unset this option" for untrusted input.
19
+ # - BIG_LINES: line numbers as `long int`, unrelated to safety.
20
+ # - NOENT (entity substitution) and DTDLOAD (external DTD subset
21
+ # loading) are deliberately NOT set - both default off in Nokogiri
22
+ # and both documented "UNSAFE to set...for untrusted documents".
23
+ # This is what actually gates XXE (see the plan's attack-proof
24
+ # section: enabling either makes local-file and external-DTD
25
+ # entity resolution succeed).
26
+ SAFE_PARSE_OPTIONS = Nokogiri::XML::ParseOptions.new(
27
+ Nokogiri::XML::ParseOptions::RECOVER |
28
+ Nokogiri::XML::ParseOptions::NONET |
29
+ Nokogiri::XML::ParseOptions::BIG_LINES
30
+ )
31
+
4
32
  attr_reader :filename
5
33
 
6
34
  def initialize(filename)
@@ -1,3 +1,3 @@
1
1
  module OpenEHR
2
- VERSION = "2.3.1"
2
+ VERSION = "2.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openehr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinji KOBAYASHI