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 +4 -4
- data/lib/openehr/parser/opt_parser.rb +3 -1
- data/lib/openehr/parser/xml_archetype_parser.rb +3 -1
- data/lib/openehr/parser.rb +28 -0
- data/lib/openehr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a3d85dcafa7ccea7c1ae4a7cd794297b9b7c4b6a6126bae494fb5a6d9538fffc
|
|
4
|
+
data.tar.gz: 34bfec35b2de56cc2c97a02d049f6233b011d3e93908db2b5065f5fc1ede068e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 =
|
|
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 =
|
|
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
|
data/lib/openehr/parser.rb
CHANGED
|
@@ -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)
|
data/lib/openehr/version.rb
CHANGED