gds-api-adapters 103.3.1 → 103.4.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 +4 -4
- data/lib/gds_api/validators/base_path_validator.rb +55 -0
- data/lib/gds_api/version.rb +1 -1
- data/lib/gds_api.rb +1 -0
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0eb796b8332cbddc0dd921c95b922f527d4da64f8b124aefaffb37e8c14cb9c3
|
|
4
|
+
data.tar.gz: 2cbed0d36be2e00a2f60d53fa6d5229f88f44352e13b6956491a0569d876c109
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4aff4d846206a4a7abd063de10490c2f4965425abe2d6af9459eac8b2f10a37f516c3819e48e86e3d324da12027d050b1890f763b9cbf141b3405b34fdd240a4
|
|
7
|
+
data.tar.gz: e51536e06a6613c51f457f124cb5c01327ea5c04c506bbd287e88525f38c87bc6ca403f5ab18e0758011cad5f510d0fed9898870d56f5fdb2c1000510b112374
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module GdsApi
|
|
2
|
+
module Validators
|
|
3
|
+
class BasePathValidator
|
|
4
|
+
MAX_PATH_LENGTH = 512
|
|
5
|
+
|
|
6
|
+
attr_reader :base_path
|
|
7
|
+
|
|
8
|
+
def initialize(base_path)
|
|
9
|
+
@base_path = base_path
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def valid?
|
|
13
|
+
!(base_path.nil? || no_leading_slash? || too_long? || potential_path_traversal? || ends_with_a_period? || invalid_chars?)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def errors
|
|
17
|
+
return { base_path_invalid: ["must not be nil"] } if base_path.nil?
|
|
18
|
+
|
|
19
|
+
errors = []
|
|
20
|
+
errors << [:base_path_invalid, "must start with a /"] if no_leading_slash?
|
|
21
|
+
errors << [:base_path_too_long, "must not be longer than #{MAX_PATH_LENGTH} bytes"] if too_long?
|
|
22
|
+
errors << [:base_path_invalid, "must not include runs of . and or / characters, which could be penetration attempts"] if potential_path_traversal?
|
|
23
|
+
errors << [:base_path_invalid, "must not end with a ."] if ends_with_a_period?
|
|
24
|
+
errors << [:base_path_invalid, "must not include characters that are not lowercase letters, numbers, -, ., or /"] if invalid_chars?
|
|
25
|
+
|
|
26
|
+
errors.each_with_object({}) do |err, memo|
|
|
27
|
+
memo[err[0]] ||= []
|
|
28
|
+
memo[err[0]] << err[1]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def no_leading_slash?
|
|
35
|
+
base_path[0] != "/"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def too_long?
|
|
39
|
+
base_path.length > MAX_PATH_LENGTH
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def potential_path_traversal?
|
|
43
|
+
base_path =~ /([\/.]{2,})/
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def ends_with_a_period?
|
|
47
|
+
base_path[-1] == "."
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def invalid_chars?
|
|
51
|
+
base_path !~ /^([\/a-z0-9.-])+$/
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/gds_api/version.rb
CHANGED
data/lib/gds_api.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gds-api-adapters
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 103.
|
|
4
|
+
version: 103.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
@@ -141,14 +141,14 @@ dependencies:
|
|
|
141
141
|
requirements:
|
|
142
142
|
- - "~>"
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '
|
|
144
|
+
version: '6.0'
|
|
145
145
|
type: :development
|
|
146
146
|
prerelease: false
|
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements:
|
|
149
149
|
- - "~>"
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: '
|
|
151
|
+
version: '6.0'
|
|
152
152
|
- !ruby/object:Gem::Dependency
|
|
153
153
|
name: minitest-around
|
|
154
154
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -295,14 +295,14 @@ dependencies:
|
|
|
295
295
|
requirements:
|
|
296
296
|
- - "~>"
|
|
297
297
|
- !ruby/object:Gem::Version
|
|
298
|
-
version: '0
|
|
298
|
+
version: '1.0'
|
|
299
299
|
type: :development
|
|
300
300
|
prerelease: false
|
|
301
301
|
version_requirements: !ruby/object:Gem::Requirement
|
|
302
302
|
requirements:
|
|
303
303
|
- - "~>"
|
|
304
304
|
- !ruby/object:Gem::Version
|
|
305
|
-
version: '0
|
|
305
|
+
version: '1.0'
|
|
306
306
|
- !ruby/object:Gem::Dependency
|
|
307
307
|
name: timecop
|
|
308
308
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -386,6 +386,7 @@ files:
|
|
|
386
386
|
- lib/gds_api/test_helpers/search.rb
|
|
387
387
|
- lib/gds_api/test_helpers/support_api.rb
|
|
388
388
|
- lib/gds_api/test_helpers/worldwide.rb
|
|
389
|
+
- lib/gds_api/validators/base_path_validator.rb
|
|
389
390
|
- lib/gds_api/version.rb
|
|
390
391
|
- lib/gds_api/worldwide.rb
|
|
391
392
|
- test/fixtures/finder_api/cma-case-schema.json
|
|
@@ -411,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
411
412
|
- !ruby/object:Gem::Version
|
|
412
413
|
version: '0'
|
|
413
414
|
requirements: []
|
|
414
|
-
rubygems_version: 4.0.
|
|
415
|
+
rubygems_version: 4.0.17
|
|
415
416
|
specification_version: 4
|
|
416
417
|
summary: Adapters to work with GDS APIs
|
|
417
418
|
test_files: []
|