ndr_import 11.4.1 → 11.6.0

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: 126526e53b9a41befd988c332ee181142e5917c491daa0310341e1b9ee9d9728
4
- data.tar.gz: 6fa42ce8d1bff9030f13b3498cbd3c783cd73484d04246a5ed2c6c8b48e66b07
3
+ metadata.gz: 0f7ea78a292f3c2ee622bda06d341329c97af0dd0edd36c039ee349a08b74284
4
+ data.tar.gz: 1dae1db120f401a1cfb85b5d243563fd9ba26f290b313d561d4b6b3327b732b8
5
5
  SHA512:
6
- metadata.gz: d2ef81755bc31b84725d3e170ca4b88de89d78b98518eaae72b6e8048ec28ab3b39f01afe2bf61bc31362573d470b576529d8fb614c8e85dffbc5b5da209c5d9
7
- data.tar.gz: f12ebb30d9943a653dcd9d97706678f03702072ab2de7e673e002d70c9dc1c113e8c1886b29d3870e2d8c40510ecf1316bd9531c7ea47f4cbaf1df594c7429e8
6
+ metadata.gz: bb20b9455c14347bd9ce894858693f94f3c7d8d3fa2c2eac390bb948011db5ae1001513ce6654cca1ca2bdbad40cf5dbd5e6c3bb491def911893159447f7fbe9
7
+ data.tar.gz: 5683e42c10156785a8e58f13269250f59f90c81ca46613840e405f6f7e6c80a7f203e3ccdb4b49fef0eeb1d300394f5120464cb5d5bd193950505f6f36365281
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
- *no unreleased changes*
2
+ * no unreleased changes
3
+
4
+ ## 11.6.0 / 2026-09-08
5
+ ### Fixed
6
+ * `NdrImport::File::SevenZip` was extracting files one directory level too deep
7
+ * Support rubyzip 3
8
+
9
+ ## 11.5.0 / 2026-06-25
10
+ ### Fixed
11
+ * Support Rails 8.1, Ruby 4.0. Drop support for Ruby 3.2
12
+ * Allow direct assignment of `table.table_metadata`
3
13
 
4
14
  ## 11.4.1 / 2025-11-05
5
15
  ### Fixed
data/SECURITY.md ADDED
@@ -0,0 +1,35 @@
1
+ # Security
2
+
3
+ NHS England takes security and the protection of private data extremely seriously. If you believe you have found a vulnerability or other issue which has compromised or could compromise the security of any of our systems and/or private data managed by our systems, please do not hesitate to contact us using the methods outlined below.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Security](#security)
8
+ - [Table of Contents](#table-of-contents)
9
+ - [Reporting a vulnerability](#reporting-a-vulnerability)
10
+ - [Email](#email)
11
+ - [NCSC](#ncsc)
12
+ - [General Security Enquiries](#general-security-enquiries)
13
+
14
+ ## Reporting a vulnerability
15
+
16
+ Please note, email is our preferred method of receiving reports.
17
+
18
+ ### Email
19
+
20
+ If you wish to notify us of a vulnerability via email, please include detailed information on the nature of the vulnerability and any steps required to reproduce it.
21
+
22
+ You can reach us at:
23
+
24
+ - [Brian.Shand@nhs.net](mailto:Brian.Shand@nhs.net)
25
+ - [cybersecurity@nhs.net](mailto:cybersecurity@nhs.net)
26
+
27
+ ### NCSC
28
+
29
+ You can send your report to the National Cyber Security Centre, who will assess your report and pass it on to NHS England if necessary.
30
+
31
+ You can report vulnerabilities here: [https://www.ncsc.gov.uk/information/vulnerability-reporting](https://www.ncsc.gov.uk/information/vulnerability-reporting)
32
+
33
+ ## General Security Enquiries
34
+
35
+ If you have general enquiries regarding our cybersecurity, please reach out to us at [cybersecurity@nhs.net](mailto:cybersecurity@nhs.net)
@@ -46,7 +46,7 @@ module NdrImport
46
46
  next unless entry.file? && basename.match(@pattern)
47
47
 
48
48
  unzipped_filename = destination.join(basename)
49
- szr.extract([entry], unzipped_filename)
49
+ szr.extract([entry], destination)
50
50
 
51
51
  unzipped_files(unzipped_filename, &block)
52
52
  end
@@ -57,8 +57,9 @@ module NdrImport
57
57
  def metadata_from_stream(xpath)
58
58
  cursor = Cursor.new(xpath, false)
59
59
 
60
- # If markup isn't well-formed, try to work around it:
61
- options = Nokogiri::XML::ParseOptions::RECOVER
60
+ # If markup isn't well-formed, try to work around it (but keep NONET,
61
+ # so external entities/DTDs can't trigger network requests):
62
+ options = Nokogiri::XML::ParseOptions::RECOVER | Nokogiri::XML::ParseOptions::NONET
62
63
  reader = Nokogiri::XML::Reader(@stream, nil, @encoding, options)
63
64
 
64
65
  reader.each do |node|
@@ -44,7 +44,11 @@ module NdrImport
44
44
  next unless entry.file? && basename.match(@pattern)
45
45
 
46
46
  unzipped_filename = destination.join(basename)
47
- zipfile.extract(entry, unzipped_filename)
47
+ if zipfile.respond_to?(:extract_v3)
48
+ zipfile.extract_v3(entry, basename, destination_directory: destination)
49
+ else
50
+ zipfile.extract(entry, basename, destination_directory: destination)
51
+ end
48
52
 
49
53
  unzipped_files(unzipped_filename, &block)
50
54
  end
@@ -183,8 +183,9 @@ module NdrImport
183
183
  # Track nesting as the cursor moves through the document:
184
184
  cursor = Cursor.new(node_xpath, pattern_match_xpath)
185
185
 
186
- # If markup isn't well-formed, try to work around it:
187
- options = Nokogiri::XML::ParseOptions::RECOVER
186
+ # If markup isn't well-formed, try to work around it (but keep NONET,
187
+ # so external entities/DTDs can't trigger network requests):
188
+ options = Nokogiri::XML::ParseOptions::RECOVER | Nokogiri::XML::ParseOptions::NONET
188
189
  reader = Nokogiri::XML::Reader(io, nil, encoding, options)
189
190
 
190
191
  reader.each do |node|
@@ -9,13 +9,13 @@ module NdrImport
9
9
 
10
10
  # Unzip the file, creating the destination directory if necessary.
11
11
  # A pattern can be provided to only extract required files.
12
- def unzip_file(source, destination, pattern = //)
12
+ def unzip_file(source, destination, pattern = //) # rubocop:disable Metrics/MethodLength
13
13
  # SECURE TVB Mon Aug 13 14:41:05 BST 2012 : SafePath will raise exception if insecure
14
14
  # path is constructed
15
15
  # SafeFile.safepath_to_string will make sure that the arguments are from type SafePath
16
16
 
17
17
  # SECURE: BNS 2010-09-21 (for external access)
18
- fail 'Not allowed in external environment' if defined?(::Rails) && ::Rails.env.external?
18
+ raise 'Not allowed in external environment' if defined?(::Rails) && ::Rails.env.external? # rubocop:disable Rails/UnknownEnv
19
19
 
20
20
  require 'zip'
21
21
  # TODO: Abort if destination directory already exists...
@@ -25,18 +25,21 @@ module NdrImport
25
25
  zipfile.entries.each do |entry|
26
26
  # SECURE: TPG 2010-11-1: The path is stripped from the zipfile entry when extracted
27
27
  basename = ::File.basename(entry.name)
28
- zipfile.extract(entry, destination.join(basename)) if entry.file? && basename.match(pattern)
28
+ if entry.file? && basename.match(pattern)
29
+ if zipfile.respond_to?(:extract_v3)
30
+ zipfile.extract_v3(entry, basename, destination_directory: destination)
31
+ else
32
+ zipfile.extract(entry, basename, destination_directory: destination)
33
+ end
34
+ end
29
35
  end
30
36
  end
31
-
32
- rescue ::Zip::ZipDestinationFileExistsError
37
+ rescue (defined?(::Zip::ZipDestinationFileExistsError) ? ::Zip::ZipDestinationFileExistsError : ::Zip::DestinationExistsError)
33
38
  # I'm going to ignore this and just overwrite the files.
34
- rescue SecurityError => ex
35
- raise ex
36
- rescue ArgumentError => ex
37
- raise ex
38
- rescue => ex
39
- puts ex
39
+ rescue ArgumentError, SecurityError => e
40
+ raise e
41
+ rescue StandardError => e
42
+ puts e # rubocop:disable Rails/Output
40
43
  end
41
44
  end
42
45
  end
@@ -11,9 +11,9 @@ module NdrImport
11
11
  include NdrImport::Mapper
12
12
 
13
13
  def self.all_valid_options
14
- %w[canonical_name delimiter liberal_parsing filename_pattern file_password last_data_column
15
- tablename_pattern header_lines footer_lines format klass columns slurp row_identifier
16
- significant_mapped_fields]
14
+ %w[canonical_name delimiter liberal_parsing filename_pattern file_password
15
+ last_data_column tablename_pattern header_lines footer_lines
16
+ format klass columns slurp row_identifier significant_mapped_fields table_metadata]
17
17
  end
18
18
 
19
19
  def all_valid_options
@@ -72,7 +72,7 @@ module NdrImport
72
72
 
73
73
  # This method does the table row yielding for the extract method, setting the notifier
74
74
  # so that we can monitor progress
75
- def yield_tables_and_their_content(filename, tables, &block)
75
+ def yield_tables_and_their_content(filename, tables, &)
76
76
  return enum_for(:yield_tables_and_their_content, filename, tables) unless block_given?
77
77
 
78
78
  tables.each do |tablename, table_content, file_metadata|
@@ -80,7 +80,9 @@ module NdrImport
80
80
  next if mapping.nil?
81
81
 
82
82
  mapping.notifier = get_notifier(record_total(filename, table_content))
83
- mapping.table_metadata = file_metadata || {}
83
+ # Merge file_metadata (from VCF or XML) with directly assigned table_metadata
84
+ # to form `table_metadata`
85
+ mapping.table_metadata = (mapping.table_metadata || {}).merge(file_metadata || {})
84
86
  yield(mapping, table_content)
85
87
  end
86
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # This stores the current version of the NdrImport gem
3
3
  module NdrImport
4
- VERSION = '11.4.1'
4
+ VERSION = '11.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndr_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.4.1
4
+ version: 11.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NCRS Development Team
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-11-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activemodel
@@ -33,7 +32,7 @@ dependencies:
33
32
  version: '7.1'
34
33
  - - "<"
35
34
  - !ruby/object:Gem::Version
36
- version: '8.1'
35
+ version: '8.2'
37
36
  type: :runtime
38
37
  prerelease: false
39
38
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +42,7 @@ dependencies:
43
42
  version: '7.1'
44
43
  - - "<"
45
44
  - !ruby/object:Gem::Version
46
- version: '8.1'
45
+ version: '8.2'
47
46
  - !ruby/object:Gem::Dependency
48
47
  name: ndr_support
49
48
  requirement: !ruby/object:Gem::Requirement
@@ -65,33 +64,45 @@ dependencies:
65
64
  - !ruby/object:Gem::Version
66
65
  version: '6'
67
66
  - !ruby/object:Gem::Dependency
68
- name: rubyzip
67
+ name: roo
69
68
  requirement: !ruby/object:Gem::Requirement
70
69
  requirements:
71
- - - "~>"
70
+ - - ">="
72
71
  - !ruby/object:Gem::Version
73
72
  version: '2.0'
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '4'
74
76
  type: :runtime
75
77
  prerelease: false
76
78
  version_requirements: !ruby/object:Gem::Requirement
77
79
  requirements:
78
- - - "~>"
80
+ - - ">="
79
81
  - !ruby/object:Gem::Version
80
82
  version: '2.0'
83
+ - - "<"
84
+ - !ruby/object:Gem::Version
85
+ version: '4'
81
86
  - !ruby/object:Gem::Dependency
82
- name: roo
87
+ name: rubyzip
83
88
  requirement: !ruby/object:Gem::Requirement
84
89
  requirements:
85
- - - "~>"
90
+ - - ">="
86
91
  - !ruby/object:Gem::Version
87
92
  version: '2.0'
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: '4'
88
96
  type: :runtime
89
97
  prerelease: false
90
98
  version_requirements: !ruby/object:Gem::Requirement
91
99
  requirements:
92
- - - "~>"
100
+ - - ">="
93
101
  - !ruby/object:Gem::Version
94
102
  version: '2.0'
103
+ - - "<"
104
+ - !ruby/object:Gem::Version
105
+ version: '4'
95
106
  - !ruby/object:Gem::Dependency
96
107
  name: avro
97
108
  requirement: !ruby/object:Gem::Requirement
@@ -242,16 +253,22 @@ dependencies:
242
253
  name: spreadsheet
243
254
  requirement: !ruby/object:Gem::Requirement
244
255
  requirements:
245
- - - '='
256
+ - - ">="
246
257
  - !ruby/object:Gem::Version
247
258
  version: 1.2.6
259
+ - - "<"
260
+ - !ruby/object:Gem::Version
261
+ version: '1.4'
248
262
  type: :runtime
249
263
  prerelease: false
250
264
  version_requirements: !ruby/object:Gem::Requirement
251
265
  requirements:
252
- - - '='
266
+ - - ">="
253
267
  - !ruby/object:Gem::Version
254
268
  version: 1.2.6
269
+ - - "<"
270
+ - !ruby/object:Gem::Version
271
+ version: '1.4'
255
272
  - !ruby/object:Gem::Dependency
256
273
  name: bundler
257
274
  requirement: !ruby/object:Gem::Requirement
@@ -406,6 +423,7 @@ files:
406
423
  - LICENSE.txt
407
424
  - README.md
408
425
  - Rakefile
426
+ - SECURITY.md
409
427
  - exe/pdf_acro_form_to_yaml
410
428
  - exe/pdf_to_text
411
429
  - exe/word_to_text
@@ -464,7 +482,6 @@ homepage: https://github.com/NHSDigital/ndr_import
464
482
  licenses:
465
483
  - MIT
466
484
  metadata: {}
467
- post_install_message:
468
485
  rdoc_options: []
469
486
  require_paths:
470
487
  - lib
@@ -472,15 +489,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
472
489
  requirements:
473
490
  - - ">="
474
491
  - !ruby/object:Gem::Version
475
- version: '3.2'
492
+ version: '3.3'
476
493
  required_rubygems_version: !ruby/object:Gem::Requirement
477
494
  requirements:
478
495
  - - ">="
479
496
  - !ruby/object:Gem::Version
480
497
  version: '0'
481
498
  requirements: []
482
- rubygems_version: 3.5.22
483
- signing_key:
499
+ rubygems_version: 3.6.9
484
500
  specification_version: 4
485
501
  summary: NDR Import
486
502
  test_files: []