caa_rr_patch 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: be22f74c1a49a1eb045dcf456286ac875639f76917003059f5b12d0efc0d8ff6
4
+ data.tar.gz: 06e589c5833069842cb8cbd52039f429b1d8bb9acb7b3e087fd8595327fb1563
5
+ SHA512:
6
+ metadata.gz: a037930285801cb29b729c1261f3f5bdf7056d153c527fa7190671ec3f85deaaf220e6aa429ea8388fc3aecd483c45c88556da503238e8818bf68c76401204b9
7
+ data.tar.gz: 48dbda52f0891509cea202f98d585c2b9bac280c97b2e8ef952e8230869cfd03b794b7f0e1dd532eb07d730d7682fe121737ab129f6154911fd55d977559b9ca
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ ci:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['2.6.x', '2.7.x']
17
+ steps:
18
+ - name: Set up Ruby
19
+ uses: actions/setup-ruby@v1
20
+ - uses: actions/checkout@v1
21
+ - name: Install dependencies
22
+ run: |
23
+ gem --version
24
+ gem install bundler
25
+ bundle --version
26
+ bundle install
27
+ - name: Run test
28
+ run: |
29
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ Gemfile.lock
4
+ .config
5
+ .rvmrc
6
+ /.bundle/
7
+ /vendor/
8
+ /lib/bundler/man/
9
+ /pkg/
10
+ /.yardoc/
11
+ /_yardoc/
12
+ /doc/
13
+ /rdoc/
14
+ /coverage/
15
+ /spec/reports/
16
+ /tmp/
17
+ *.rdb
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/ConditionalAssignment:
5
+ Enabled: false
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/NumericLiterals:
11
+ Enabled: false
12
+
13
+ Metrics/AbcSize:
14
+ Max: 30
15
+
16
+ Metrics/MethodLength:
17
+ Max: 30
18
+
19
+ Naming/MethodParameterName:
20
+ MinNameLength: 1
21
+
22
+ Metrics/BlockLength:
23
+ Exclude:
24
+ - 'spec/*.rb'
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rake'
6
+
7
+ group :test do
8
+ gem 'pry'
9
+ gem 'pry-byebug'
10
+ gem 'rspec', '3.9.0'
11
+ gem 'rubocop', '0.78.0'
12
+ end
13
+
14
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Tomoya Kuwayama
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # caa_rr_patch
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/caa_rr_patch.svg)](https://badge.fury.io/rb/caa_rr_patch)
4
+ [![Actions Status](https://github.com/thekuwayama/caa_rr_patch/workflows/CI/badge.svg)](https://github.com/thekuwayama/caa_rr_patch/actions?workflow=CI)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/48c9eeb9b52f0dc63cb6/maintainability)](https://codeclimate.com/github/thekuwayama/caa_rr_patch/maintainability)
6
+
7
+ `caa_rr_patch` is the patch that adds CAA Resource Record.
8
+
9
+ * https://tools.ietf.org/html/rfc8659
10
+
11
+
12
+ ## Installation
13
+
14
+ The gem is available at [rubygems.org](https://rubygems.org/gems/caa_rr_patch). You can install it the following.
15
+
16
+ ```bash
17
+ $ gem install caa_rr_patch
18
+ ```
19
+
20
+
21
+ ## Usage
22
+
23
+ You can resolve CAA resources.
24
+
25
+ ```bash
26
+ $ irb
27
+ irb(main):001:0> require 'caa_rr_patch'
28
+ => true
29
+ irb(main):002:1* Resolv::DNS.new.getresources(
30
+ irb(main):003:1* "google.com",
31
+ irb(main):004:1* Resolv::DNS::Resource::IN::CAA
32
+ irb(main):005:0> ) { |rr| pp rr }
33
+ => [#<Resolv::DNS::Resource::IN::CAA:0x0123456789abcdef @flags="\x00", @tag="issue", @value="pki.goog", @ttl=77777>]
34
+ ```
35
+
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rubocop/rake_task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RuboCop::RakeTask.new
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: %i[rubocop spec]
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'caa_rr_patch/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'caa_rr_patch'
9
+ spec.version = CaaRrPatch::VERSION
10
+ spec.authors = ['thekuwayama']
11
+ spec.email = ['thekuwayama@gmail.com']
12
+ spec.summary = 'the patch that adds CAA Resource Record'
13
+ spec.description = spec.summary
14
+ spec.homepage = 'https://github.com/thekuwayama/caa_rr_patch'
15
+ spec.license = 'MIT'
16
+ spec.required_ruby_version = '>=2.6.0'
17
+
18
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler'
23
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'resolv'
4
+
5
+ require 'caa_rr_patch/caa'
6
+ require 'caa_rr_patch/version'
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # The Certification Authority Authorization (CAA) DNS Resource Record
5
+
6
+ # rubocop: disable Style/ClassAndModuleChildren
7
+ class Resolv::DNS::Resource::IN::CAA < Resolv::DNS::Resource
8
+ TypeValue = 257 # rubocop: disable Naming/ConstantName
9
+ ClassValue = IN::ClassValue
10
+ ClassHash[[TypeValue, ClassValue]] = self
11
+
12
+ def initialize(flags, tag, value)
13
+ # https://tools.ietf.org/html/rfc8659#section-4.1
14
+ # +0-1-2-3-4-5-6-7-|0-1-2-3-4-5-6-7-|
15
+ # | Flags | Tag Length = n |
16
+ # +----------------|----------------+...+---------------+
17
+ # | Tag char 0 | Tag char 1 |...| Tag char n-1 |
18
+ # +----------------|----------------+...+---------------+
19
+ # +----------------|----------------+.....+----------------+
20
+ # | Value byte 0 | Value byte 1 |.....| Value byte m-1 |
21
+ # +----------------|----------------+.....+----------------+
22
+ @flags = flags
23
+ @tag = tag
24
+ @value = value
25
+ end
26
+
27
+ ##
28
+ # Critical Flag
29
+
30
+ attr_reader :flags
31
+
32
+ ##
33
+ # Property identifier
34
+
35
+ attr_reader :tag
36
+
37
+ ##
38
+ # A sequence of octets representing the Property Value
39
+
40
+ attr_reader :value
41
+
42
+ # :nodoc:
43
+ def encode_rdata(msg)
44
+ msg.put_bytes(@flags)
45
+ msg.put_string(@tag)
46
+ msg.put_bytes(@value)
47
+ end
48
+
49
+ # :nodec:
50
+ def self.decode_rdata(msg)
51
+ flags = msg.get_bytes(1)
52
+ tag = msg.get_string
53
+ value = msg.get_bytes
54
+ new(flags, tag, value)
55
+ end
56
+ end
57
+ # rubocop: enable Style/ClassAndModuleChildren
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CaaRrPatch
4
+ VERSION = '0.0.1'
5
+ end
data/spec/caa_spec.rb ADDED
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'spec_helper'
4
+
5
+ RSpec.describe Resolv::DNS::Resource::IN::CAA do
6
+ context 'CAA Resource Record initialize' do
7
+ let(:caa) do
8
+ Resolv::DNS::Resource::IN::CAA.new(0.chr, 'issuer', 'letsencrypt.org')
9
+ end
10
+
11
+ it 'should return CAA object' do
12
+ expect(caa.flags).to eq "\x00"
13
+ expect(caa.tag).to eq 'issuer'
14
+ expect(caa.value).to eq 'letsencrypt.org'
15
+ end
16
+ end
17
+
18
+ context 'CAA Resource Record decode' do
19
+ let(:bin) do
20
+ <<~BIN.split.map(&:hex).map(&:chr).join
21
+ 00 00 81 80 00 01 00 01 00 00 00 00 06 67 6f 6f
22
+ 67 6c 65 03 63 6f 6d 00 01 01 00 01 c0 0c 01 01
23
+ 00 01 00 01 51 80 00 0f 00 05 69 73 73 75 65 70
24
+ 6b 69 2e 67 6f 6f 67
25
+ BIN
26
+ end
27
+
28
+ let(:msg) do
29
+ Resolv::DNS::Message.decode(bin)
30
+ end
31
+
32
+ it 'should contain CAA queries' do
33
+ expect(msg.question)
34
+ .to include(->(m) { m[1] == Resolv::DNS::Resource::IN::CAA })
35
+ end
36
+
37
+ it 'should contain CAA answers' do
38
+ expect(msg.answer)
39
+ .to include(->(m) { m[2].is_a?(Resolv::DNS::Resource::IN::CAA) })
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure(&:disable_monkey_patching!)
4
+
5
+ require 'caa_rr_patch'
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: caa_rr_patch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - thekuwayama
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: the patch that adds CAA Resource Record
28
+ email:
29
+ - thekuwayama@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/main.yml"
35
+ - ".gitignore"
36
+ - ".rubocop.yml"
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - caa_rr_patch.gemspec
42
+ - lib/caa_rr_patch.rb
43
+ - lib/caa_rr_patch/caa.rb
44
+ - lib/caa_rr_patch/version.rb
45
+ - spec/caa_spec.rb
46
+ - spec/spec_helper.rb
47
+ homepage: https://github.com/thekuwayama/caa_rr_patch
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.6.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.1.2
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: the patch that adds CAA Resource Record
70
+ test_files:
71
+ - spec/caa_spec.rb
72
+ - spec/spec_helper.rb