domain_name_format_validator 1.0.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 +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +56 -0
- data/.rubocop.yml +13 -0
- data/Changelog.md +94 -0
- data/Developers.md +70 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +23 -0
- data/README.md +139 -0
- data/Rakefile +16 -0
- data/SECURITY.md +29 -0
- data/domain_name_format_validator.gemspec +28 -0
- data/lib/domain_name_format_validator.rb +9 -0
- data/lib/domain_name_format_validator/settings.rb +27 -0
- data/lib/domain_name_format_validator/validator.rb +80 -0
- data/lib/domain_name_format_validator/version.rb +5 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a9628f250ac1c08caf5d289860d1fe37ba167425204c6912325f60fa5365bfc
|
4
|
+
data.tar.gz: 22ca205ad10c88913b099fca6473a19f9bc63eb6784e2e2e696973459e345be4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ee8b081426b91af56f66ead0501d74fd7e50de07548ab8ce289acedc1cc880790232fdca93e12d2cbd039a6d8b1a427c6e47be1605f35e0b59f19071beb079f7
|
7
|
+
data.tar.gz: 007c9db3ae2e32c2948e0ae4b550f660722722ba2347eeb40188134c5afc1d17e2f67245cd3e1c3682e9d59d7ceb19753d6bf86bcf58bd98aecea2c94fa788b1
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.0.0
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.3
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/.rubocop.yml
ADDED
data/Changelog.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
1.0 (2021-08-18)
|
2
|
+
----------------
|
3
|
+
|
4
|
+
* Fixed issues with newline in domain-names
|
5
|
+
|
6
|
+
* Changed behavior for Top-Level-Domain-checks: they are now limited by 63
|
7
|
+
characters.
|
8
|
+
|
9
|
+
* Changed class into a ruby module and added a error-function as requested in
|
10
|
+
https://github.com/dkeener/domain_name_validator/issues/6
|
11
|
+
|
12
|
+
* Added tests for common top level domains and some random valid domains
|
13
|
+
|
14
|
+
* Added tests for regex bypass
|
15
|
+
|
16
|
+
* Ruby style: added rubocop and fixed styling issues
|
17
|
+
|
18
|
+
* Replaced rspec with minitest
|
19
|
+
|
20
|
+
* New name 'domain_name_format_validator' indicates that the format will be
|
21
|
+
validated and not if it is an existing domain or top-level-domain
|
22
|
+
|
23
|
+
* Modified Rakefile it can run test-tasks and rubycop-tasks
|
24
|
+
|
25
|
+
* Constants and error-messages are now placed in another ruby-file
|
26
|
+
|
27
|
+
0.5 (2013-10-24)
|
28
|
+
----------------
|
29
|
+
|
30
|
+
* By request, the gem now ignores leading/trailing whitespace when validating
|
31
|
+
domain names. This includes ignoring newlines at the end of domain names.
|
32
|
+
|
33
|
+
* Remove timestamp from gemspec so Rubygems will calculate gem dates for us.
|
34
|
+
|
35
|
+
* (0.5.1 - 2013-11-06) The validate method now avoids accidental memoization
|
36
|
+
on the part of the caller by ensuring that the contents of the array
|
37
|
+
argument have been cleared. Previously, if the caller called the method
|
38
|
+
multiple times using the same array, then all calls would result in FALSE
|
39
|
+
after the first FALSE was legitemately encountered. Yes, somebody did
|
40
|
+
this.
|
41
|
+
|
42
|
+
0.4 (2013-07-17)
|
43
|
+
----------------
|
44
|
+
|
45
|
+
* By request, added rudimentary TLD checking. A TLD, the right-most label of a
|
46
|
+
domain name, should be either 2 or 3 characters, unless it's "aero", "arpa",
|
47
|
+
"museum" or begins with "xn--" (for a normalized Unicode TLD). This check
|
48
|
+
does not validate against a master list of TLD's, but basically just fails
|
49
|
+
a domain name if the TLD basically could not be valid under any
|
50
|
+
circumstances. This validation would, for example, reject a domain name
|
51
|
+
such as "test.domain".
|
52
|
+
|
53
|
+
* (0.4.1 - 2013-07-17) Added "info" as a valid extra-long TLD. How I missed
|
54
|
+
this one, I have no idea.
|
55
|
+
|
56
|
+
* (0.4.2 - 2013-07-17) Added a check for zero-length domain names, either
|
57
|
+
empty strings or Ruby nil values being passed in. In practice, these edge
|
58
|
+
cases were actually happening.
|
59
|
+
|
60
|
+
* (0.4.3 - 2013-08-01) For the TLD reality check, IANA (the Internet Assigned
|
61
|
+
Numbers Authority) recognizes some long TLD's that were not on the original
|
62
|
+
list for this gem, such as ".travel", ".jobs", etc. To reiterate, the gem
|
63
|
+
does not validate against the full list of TLD's or effective TLD's, but
|
64
|
+
it does validate that the TLD length COULD be a valid TLD. As an example,
|
65
|
+
a TLD of 14 characters would be rejected because there are no valid domains
|
66
|
+
that could match that pattern.
|
67
|
+
|
68
|
+
* (0.4.3 - 2013-08-01) Added the "license" attribute to the gemspec. This is
|
69
|
+
in response to an issue that was opened on GitHub.
|
70
|
+
|
71
|
+
* (0.4.4 - 2013-08-28) Fixed bug involving proper handling of domain names with
|
72
|
+
capital letters. Reported by a user.
|
73
|
+
|
74
|
+
0.3 (2013-06-28)
|
75
|
+
----------------
|
76
|
+
|
77
|
+
* Added a check, because labels cannot begin with a period.
|
78
|
+
* Updated documentation, plus defined Road Map for future changes.
|
79
|
+
|
80
|
+
0.2 (2013-06-17)
|
81
|
+
----------------
|
82
|
+
|
83
|
+
First version built and deployed as a gem on a real project. Released on
|
84
|
+
Rubygems.org for the first time.
|
85
|
+
|
86
|
+
* Added more RSpec tests for improved test coverage.
|
87
|
+
* Enhanced documentation.
|
88
|
+
|
89
|
+
|
90
|
+
0.1 (2013-06-10)
|
91
|
+
----------------
|
92
|
+
|
93
|
+
Initial working version of the code, with minimal RSpec tests. Released on
|
94
|
+
GitHub for review, but not yet published as a gem to the Ruby community.
|
data/Developers.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
For Developers Only
|
2
|
+
===================
|
3
|
+
|
4
|
+
Building and testing the domain_name_validator gem is pretty easy.
|
5
|
+
|
6
|
+
Gemspec
|
7
|
+
-------
|
8
|
+
|
9
|
+
The gemspec file for the gem, domain_name_validator.gemspec, is an active
|
10
|
+
file containing Ruby code. In other words, the gemspec file itself has code
|
11
|
+
to figure out what files should be included in the gem, etc. Each time a
|
12
|
+
release is done, the only thing that needs to be edited is the "gem.date"
|
13
|
+
property.
|
14
|
+
|
15
|
+
Version
|
16
|
+
-------
|
17
|
+
|
18
|
+
The version number is defined in the version.rb file, located in the lib
|
19
|
+
directory tree. The version number should be bumped up in some fashion with
|
20
|
+
each release. Version numbers often have 3 digits, e.g. - 1.2.3. The left-most
|
21
|
+
number is a release, followed by a sub-release and a patch. All versions
|
22
|
+
within a release should generally be backwards compatible. A sub-release
|
23
|
+
generally include significant new features, whilea patch is generally a minor
|
24
|
+
update (often a bug fix).
|
25
|
+
|
26
|
+
The gemspec file automatically picks up the version number from the version.rb
|
27
|
+
file, so make sure you keep it updated properly.
|
28
|
+
|
29
|
+
Testing the Code
|
30
|
+
----------------
|
31
|
+
|
32
|
+
Testing the code is simple. Run the following command from the top level
|
33
|
+
of the gem's directory tree:
|
34
|
+
|
35
|
+
$ rake test
|
36
|
+
|
37
|
+
Lists for testing domains and top-level-domains
|
38
|
+
-----------------------------------------------
|
39
|
+
|
40
|
+
The following lists were downloaded in order to perform tests with existing
|
41
|
+
domains and top level domains:
|
42
|
+
|
43
|
+
* https://raw.githubusercontent.com/opendns/public-domain-lists/master/opendns-random-domains.txt
|
44
|
+
|
45
|
+
* https://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
46
|
+
|
47
|
+
Testing for styling issues
|
48
|
+
--------------------------
|
49
|
+
|
50
|
+
This gem was setup with rubocop. Run the following command from the top level
|
51
|
+
of the gem's directory tree:
|
52
|
+
|
53
|
+
$ rake rubocop
|
54
|
+
|
55
|
+
Creating the Gem
|
56
|
+
----------------
|
57
|
+
|
58
|
+
To create the gem file for this gem, run the following command from the top
|
59
|
+
level of the gem's directory tree:
|
60
|
+
|
61
|
+
$ gem build domain_name_validator.gemspec
|
62
|
+
|
63
|
+
Pushing to RubyGems
|
64
|
+
-------------------
|
65
|
+
|
66
|
+
Obviously, you can only do this step if you've got the appropriate privileges
|
67
|
+
at RubyGems.org and everything is properly configured.
|
68
|
+
|
69
|
+
$ gem push domain_name_validator.gem
|
70
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ast (2.4.2)
|
5
|
+
minitest (5.14.4)
|
6
|
+
parallel (1.20.1)
|
7
|
+
parser (3.0.2.0)
|
8
|
+
ast (~> 2.4.1)
|
9
|
+
rainbow (3.0.0)
|
10
|
+
rake (13.0.6)
|
11
|
+
regexp_parser (2.1.1)
|
12
|
+
rexml (3.2.5)
|
13
|
+
rubocop (0.93.1)
|
14
|
+
parallel (~> 1.10)
|
15
|
+
parser (>= 2.7.1.5)
|
16
|
+
rainbow (>= 2.2.2, < 4.0)
|
17
|
+
regexp_parser (>= 1.8)
|
18
|
+
rexml
|
19
|
+
rubocop-ast (>= 0.6.0)
|
20
|
+
ruby-progressbar (~> 1.7)
|
21
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
22
|
+
rubocop-ast (1.10.0)
|
23
|
+
parser (>= 3.0.1.1)
|
24
|
+
ruby-progressbar (1.11.0)
|
25
|
+
unicode-display_width (1.7.0)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
x86_64-linux
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
minitest (~> 5.0)
|
32
|
+
rake (~> 13.0)
|
33
|
+
rubocop (~> 0.80)
|
34
|
+
|
35
|
+
BUNDLED WITH
|
36
|
+
2.2.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2013 David Keener
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
[](https://github.com/whotwagner/domain_name_format_validator/actions/workflows/main.yml)
|
2
|
+
|
3
|
+
domain_name_format_validator
|
4
|
+
============================
|
5
|
+
|
6
|
+
Ever needed to validate the format of a domain name? This gem will validate any domain name
|
7
|
+
represented in ASCII.
|
8
|
+
|
9
|
+
The scope of this gem is deliberately focused on validating the format of domain names. It
|
10
|
+
simply answers the question: "Is this a real domain name?" Using this command,
|
11
|
+
you can make a realistic assessment about whether you want to store a domain
|
12
|
+
name or URL in your database. This gem will tell you 1) that a domain is or
|
13
|
+
is not valid, and 2) if it's not valid, what the errors are.
|
14
|
+
|
15
|
+
Some existing gems for domain name validation use insecure regular expressions.
|
16
|
+
For example if you have the following regex-pattern: `^do_some_checks$`, the
|
17
|
+
check can be bypassed by domainn names like: `example.com\n<script>alert('xss')</script>`.
|
18
|
+
Such a bypass doesn't work with this gem.
|
19
|
+
|
20
|
+
_Please note that this gem is a fork of https://github.com/dkeener/domain_name_validator which seems to be abandoned_
|
21
|
+
|
22
|
+
How It Works
|
23
|
+
------------
|
24
|
+
|
25
|
+
To validate a domain name:
|
26
|
+
|
27
|
+
if DomainNameFormatValidator.valid?("example.com")
|
28
|
+
# Do something
|
29
|
+
end
|
30
|
+
|
31
|
+
What about error messages? If a domain isn't valid, it's often desirable to
|
32
|
+
find out why the domain ewasn't valid. To do this, simply pass an array into
|
33
|
+
the "validate" message as the optional second argument.
|
34
|
+
|
35
|
+
errs = DomainNameFormatValidator.errors("example.123")
|
36
|
+
unless errs.empty?
|
37
|
+
puts("Errors: #{errs.inspect}")
|
38
|
+
end
|
39
|
+
|
40
|
+
This generates the following output:
|
41
|
+
|
42
|
+
Errors: ["The top-level domain (the extension) cannot be numerical"]
|
43
|
+
|
44
|
+
This gem should make it easy to validate domain names.
|
45
|
+
|
46
|
+
About Domain Names
|
47
|
+
------------------
|
48
|
+
|
49
|
+
Domain names provide a unique, memorizable name to represent numerically
|
50
|
+
addressable Internet resources. They also provide a level of abstraction that
|
51
|
+
allows the underlying Internet address to be changed while still referencing
|
52
|
+
a resource by its domain name. The domain name space is managed by the
|
53
|
+
Internet Corporation for Assigned Names and Numbers (ICANN).
|
54
|
+
|
55
|
+
The right-most label of a domain name is referred to as the top-level domain,
|
56
|
+
or TLD. A limited set of top-level domain names, and two-character country
|
57
|
+
codes, have been standardized. The Internet Assigned Numbers Authority (IANA)
|
58
|
+
maintains an annotated list of top-level domains, as well as a list of
|
59
|
+
"special use," or reserved, top-level domain names.
|
60
|
+
|
61
|
+
* http://www.iana.org/domains/root/db/
|
62
|
+
* http://www.iana.org/assignments/special-use-domain-names/special-use-domain-names.xml
|
63
|
+
|
64
|
+
Domain names follow some very detailed rules:
|
65
|
+
|
66
|
+
* The maximum length of a domain name is 253 characters.
|
67
|
+
|
68
|
+
* A domain name is divided into "labels" separated by periods. The maximum
|
69
|
+
number of labels is 127.
|
70
|
+
|
71
|
+
* The maximum length of any label within a domain name is 63 characters.
|
72
|
+
|
73
|
+
* No label, including TLDs, can begin or end with a dash.
|
74
|
+
|
75
|
+
* Top-level domain names cannot be all numeric.
|
76
|
+
|
77
|
+
* The right-most label must be either a recognized TLD or a 2-letter country
|
78
|
+
code. The only exception is for international domain names
|
79
|
+
|
80
|
+
* Top-level domain names cannot be all numeric.
|
81
|
+
|
82
|
+
* Domain names may not begin with a period.
|
83
|
+
|
84
|
+
* The characters allowed in labels are a subset of the ASCII character set, consisting of
|
85
|
+
characters a through z, A through Z, digits 0 through 9, and hyphen.
|
86
|
+
|
87
|
+
|
88
|
+
Internationalized Domain Names
|
89
|
+
------------------------------
|
90
|
+
|
91
|
+
What about internationalized domain names? ICANN approved the Internationalized
|
92
|
+
Domain Name (IDNA) system in 2003. This standard allows for Unicode domain
|
93
|
+
names to be encoded into ASCII using Punycode. Essentially, a label may contain
|
94
|
+
"xn--" as a prefix, followed by the Punycode representation of a Unicode string,
|
95
|
+
resulting in domain names such as xn--kbenhavn-54.eu. Note that there are also
|
96
|
+
some approved Unicode TLDs.
|
97
|
+
|
98
|
+
The process of rendering an internationalized domain name in ASCII via
|
99
|
+
Punycode is called normalization. This gem will validate a normalized domain
|
100
|
+
name, but not a Unicode domain name. Note, however, that it currently does not
|
101
|
+
validate normalized TLDs against ICANN's list of valid TLDs.
|
102
|
+
|
103
|
+
It's also unclear whether the "xn--" prefix should count against the label
|
104
|
+
size limit of 63 characters. In the absence of specific guidelines, and because
|
105
|
+
I've never actually seen an overly long label, I have chosen to apply the limit
|
106
|
+
irregardless of the presence of the "xn--" prefix within a label.
|
107
|
+
|
108
|
+
Requirements
|
109
|
+
------------
|
110
|
+
|
111
|
+
This is a Ruby gem with no run-time dependencies on anything else. It has
|
112
|
+
been tested under Ruby 3.0.0p0 but might work with older Ruby versions too.
|
113
|
+
|
114
|
+
Install
|
115
|
+
-------
|
116
|
+
|
117
|
+
Installation doesn't get much simpler than this:
|
118
|
+
|
119
|
+
gem install domain_name_format_validator
|
120
|
+
|
121
|
+
|
122
|
+
Author
|
123
|
+
------
|
124
|
+
|
125
|
+
This gem was refactored and relaunched by [Wolfgang Hotwagner](https://github.com/whotwagner/domain_name_format_validator).
|
126
|
+
The original code was written by [David Keener](https://github.com/dkeener/domain_name_validator).
|
127
|
+
|
128
|
+
|
129
|
+
Contributors
|
130
|
+
------------
|
131
|
+
|
132
|
+
Many thanks for the support of General Dynamics and the Department of
|
133
|
+
Homeland Security (DHS). And more specifically on input from Andrew Finch,
|
134
|
+
Josh Lentz, Jonathan Quigg and Dave Roberts.
|
135
|
+
|
136
|
+
YOUR SUPPORT
|
137
|
+
------------
|
138
|
+
|
139
|
+
Every contribution is welcome. Please feel free to open Pull-Requests.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/SECURITY.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
| Version | Supported |
|
6
|
+
| ------- | ------------------ |
|
7
|
+
| 1.x.x | :white_check_mark: |
|
8
|
+
| < 1.0.0 | :x: |
|
9
|
+
|
10
|
+
## Reporting a Vulnerability
|
11
|
+
|
12
|
+
Please email reports about any security related issues you find to code@feedyourhead.at. This mail is delivered to a small developer team. Your email will be acknowledged within a few days, and you'll receive a more detailed response to your email within 14 days indicating the next steps in handling your report.
|
13
|
+
|
14
|
+
Please use a descriptive subject line for your report email. After the initial reply to your report, our team will endeavor to keep you informed of the progress being made towards a fix and announcement.
|
15
|
+
|
16
|
+
In addition, please include the following information along with your report:
|
17
|
+
|
18
|
+
* Your name and affiliation (if any).
|
19
|
+
* A description of the technical details of the vulnerabilities. It is very important to let us know how we can reproduce your findings.
|
20
|
+
* An explanation who can exploit this vulnerability, and what they gain when doing so -- write an attack scenario. This will help us evaluate your report quickly, especially if the issue is complex.
|
21
|
+
* Whether this vulnerability public or known to third parties. If it is, please provide details.
|
22
|
+
* Whether we could mention your name in the changelogs.
|
23
|
+
|
24
|
+
Once an issue is reported we use the following disclosure process:
|
25
|
+
|
26
|
+
* When a report is received, we confirm the issue and determine its severity.
|
27
|
+
* If we know of specific third-party services or software based on this software that require mitigation before publication, those projects will be notified.
|
28
|
+
* Fixes are prepared for the last minor release of the latest major release.
|
29
|
+
* Patch releases are published for all fixed released versions.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/domain_name_format_validator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "domain_name_format_validator"
|
7
|
+
gem.version = DomainNameFormatValidator::VERSION
|
8
|
+
gem.platform = Gem::Platform::RUBY
|
9
|
+
gem.authors = ["David Keener", "Wolfgang Hotwagner"]
|
10
|
+
gem.email = ["code@feedyourhead.at"]
|
11
|
+
gem.homepage = "https://github.com/whotwagner/domain_name_format_validator"
|
12
|
+
gem.summary = "Domain Name Format Validator"
|
13
|
+
gem.description = "Checks if the format of a domain name is valid."
|
14
|
+
gem.license = "MIT"
|
15
|
+
gem.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
+
|
17
|
+
gem.metadata["source_code_uri"] = "https://github.com/whotwagner/domain_name_format_validator"
|
18
|
+
|
19
|
+
gem.rubyforge_project = "domain_name_format_validator"
|
20
|
+
|
21
|
+
gem.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
gem.bindir = "exe"
|
26
|
+
gem.executables = gem.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
|
+
gem.require_paths = ["lib"]
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Some constants and error-codes for DomainNameFormatValidator
|
4
|
+
# are defined here
|
5
|
+
module DomainNameFormatValidator
|
6
|
+
MAX_DOMAIN_LENGTH = 253
|
7
|
+
MAX_LABEL_LENGTH = 63
|
8
|
+
MAX_LEVELS = 127
|
9
|
+
MAX_TLD_LENGTH = 63
|
10
|
+
MIN_LEVELS = 2
|
11
|
+
MIN_TLD_LENGTH = 2
|
12
|
+
|
13
|
+
ERRS = {
|
14
|
+
bogus_tld: "Malformed TLD: Could not possibly match any valid TLD",
|
15
|
+
illegal_chars: "Domain label contains an illegal character",
|
16
|
+
illegal_start: "No domain name may start with a period",
|
17
|
+
label_dash_begin: "No domain label may begin with a dash",
|
18
|
+
label_dash_end: "No domain label may end with a dash",
|
19
|
+
max_domain_size: "Maximum domain length of 253 exceeded",
|
20
|
+
max_label_size: "Maximum domain label length of 63 exceeded",
|
21
|
+
max_level_size: "Maximum domain level limit of 127 exceeded",
|
22
|
+
min_level_size: "Minimum domain level limit of 2 not achieved",
|
23
|
+
top_numerical: "The top-level domain (TLD) cannot be numerical",
|
24
|
+
top_illegal_chars: "The top-level domain (TLD) must only contain a-z 0-9 and -",
|
25
|
+
zero_size: "Zero-length domain name"
|
26
|
+
}.freeze
|
27
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The purpose of this module is to provide a simple capability for validating
|
4
|
+
# domain names represented in ASCII.
|
5
|
+
module DomainNameFormatValidator
|
6
|
+
# Validates the proper formatting of a normalized domain name, i.e. - a
|
7
|
+
# domain that is represented in ASCII. Thus, international domain names are
|
8
|
+
# supported and validated, if they have undergone the required IDN
|
9
|
+
# conversion to ASCII. The validation rules are:
|
10
|
+
#
|
11
|
+
# 1. The maximum length of a domain name is 253 characters.
|
12
|
+
# 2. A domain name is divided into "labels" separated by periods. The maximum
|
13
|
+
# number of labels (including the top-level domain as a label) is 127.
|
14
|
+
# 3. The maximum length of any label within a domain name is 63 characters.
|
15
|
+
# 4. No label, including top-level domains, can begin or end with a dash.
|
16
|
+
# 5. Top-level names cannot be all numeric.
|
17
|
+
# 6. A domain name cannot begin with a period.
|
18
|
+
|
19
|
+
# this internal function validates a single label
|
20
|
+
# and is used by validate_parts?
|
21
|
+
def self.validate_part?(part, errs = [])
|
22
|
+
errs << ERRS[:max_label_size] if part.size > MAX_LABEL_LENGTH
|
23
|
+
errs << ERRS[:label_dash_begin] if part[0] == "-"
|
24
|
+
errs << ERRS[:label_dash_end] if part[-1] == "-"
|
25
|
+
errs << ERRS[:illegal_chars] unless part.match(/\A[a-z0-9\-\_]+\Z/)
|
26
|
+
end
|
27
|
+
|
28
|
+
# This internal function validates the labels of a domain name
|
29
|
+
def self.validate_parts?(parts, errs = [])
|
30
|
+
errs << ERRS[:max_level_size] if parts.size > MAX_LEVELS
|
31
|
+
errs << ERRS[:min_level_size] if parts.size < MIN_LEVELS
|
32
|
+
errs << ERRS[:illegal_start] if parts.first[0] == "."
|
33
|
+
parts.each do |part|
|
34
|
+
validate_part?(part, errs)
|
35
|
+
end
|
36
|
+
errs
|
37
|
+
end
|
38
|
+
|
39
|
+
# this internal function validates the top level domain
|
40
|
+
# if its nummerical only, if illegal characters occur
|
41
|
+
# or if the length of the tld is not valid
|
42
|
+
def self.validate_tld?(tld, errs = [])
|
43
|
+
errs << ERRS[:top_numerical] if tld.match(/\A[0-9]+\Z/)
|
44
|
+
errs << ERRS[:top_illegal_chars] unless tld.match(/\A[a-z0-9\-]+\Z/)
|
45
|
+
errs << ERRS[:bogus_tld] if tld.size < MIN_TLD_LENGTH || tld.size > MAX_TLD_LENGTH
|
46
|
+
errs
|
47
|
+
end
|
48
|
+
|
49
|
+
# This internal function validates the domain if its nil or zero
|
50
|
+
def self.validate_args?(domain, errs = [])
|
51
|
+
if domain.nil?
|
52
|
+
errs << ERRS[:zero_size]
|
53
|
+
else
|
54
|
+
domain = domain.strip
|
55
|
+
errs << ERRS[:zero_size] if domain.size.zero?
|
56
|
+
end
|
57
|
+
errs
|
58
|
+
end
|
59
|
+
|
60
|
+
# This function validates domain names and returns an array
|
61
|
+
# with errors or an empty array if no error occurred.
|
62
|
+
# see: https://github.com/dkeener/domain_name_validator/issues/6
|
63
|
+
def self.errors(domain)
|
64
|
+
errs = []
|
65
|
+
errs = validate_args?(domain, errs)
|
66
|
+
if errs.size.zero?
|
67
|
+
errs << ERRS[:max_domain_size] if domain.size > MAX_DOMAIN_LENGTH
|
68
|
+
parts = domain.downcase.split(".")
|
69
|
+
errs = validate_parts?(parts, errs)
|
70
|
+
errs = validate_tld?(parts.last, errs)
|
71
|
+
end
|
72
|
+
errs
|
73
|
+
end
|
74
|
+
|
75
|
+
# This function validates domain names and returns true or false
|
76
|
+
def self.valid?(domain)
|
77
|
+
errs = errors(domain)
|
78
|
+
errs.size.zero? # TRUE if valid, FALSE otherwise
|
79
|
+
end
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: domain_name_format_validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Keener
|
8
|
+
- Wolfgang Hotwagner
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Checks if the format of a domain name is valid.
|
15
|
+
email:
|
16
|
+
- code@feedyourhead.at
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".github/workflows/main.yml"
|
22
|
+
- ".gitignore"
|
23
|
+
- ".rubocop.yml"
|
24
|
+
- Changelog.md
|
25
|
+
- Developers.md
|
26
|
+
- Gemfile
|
27
|
+
- Gemfile.lock
|
28
|
+
- LICENSE.txt
|
29
|
+
- README.md
|
30
|
+
- Rakefile
|
31
|
+
- SECURITY.md
|
32
|
+
- domain_name_format_validator.gemspec
|
33
|
+
- lib/domain_name_format_validator.rb
|
34
|
+
- lib/domain_name_format_validator/settings.rb
|
35
|
+
- lib/domain_name_format_validator/validator.rb
|
36
|
+
- lib/domain_name_format_validator/version.rb
|
37
|
+
homepage: https://github.com/whotwagner/domain_name_format_validator
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata:
|
41
|
+
source_code_uri: https://github.com/whotwagner/domain_name_format_validator
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.4.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.2.3
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Domain Name Format Validator
|
61
|
+
test_files: []
|