nicinfo 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/bin/nicinfo +22 -0
  3. data/lib/autnum.rb +90 -0
  4. data/lib/bootstrap.rb +198 -0
  5. data/lib/bsfiles/asn.json +2326 -0
  6. data/lib/bsfiles/dns.json +25 -0
  7. data/lib/bsfiles/entity.json +52 -0
  8. data/lib/bsfiles/ipv4.json +244 -0
  9. data/lib/bsfiles/ipv6.json +97 -0
  10. data/lib/cache.rb +141 -0
  11. data/lib/common_json.rb +263 -0
  12. data/lib/common_names.rb +49 -0
  13. data/lib/config.rb +260 -0
  14. data/lib/constants.rb +113 -0
  15. data/lib/data_tree.rb +205 -0
  16. data/lib/demo/autnum.json +228 -0
  17. data/lib/demo/domain-dnr.json +695 -0
  18. data/lib/demo/domain-rir.json +569 -0
  19. data/lib/demo/domains.json +625 -0
  20. data/lib/demo/entities.json +545 -0
  21. data/lib/demo/entity-dnr.json +143 -0
  22. data/lib/demo/entity-rir.json +394 -0
  23. data/lib/demo/error-code.json +31 -0
  24. data/lib/demo/help.json +58 -0
  25. data/lib/demo/ip.json +306 -0
  26. data/lib/demo/nameservers.json +434 -0
  27. data/lib/demo/ns-simple.json +210 -0
  28. data/lib/demo/ns-very-simple.json +41 -0
  29. data/lib/demo/ns.json +63 -0
  30. data/lib/demo/simple-ip.json +41 -0
  31. data/lib/demo/simple.json +13 -0
  32. data/lib/domain.rb +203 -0
  33. data/lib/ds_data.rb +70 -0
  34. data/lib/entity.rb +372 -0
  35. data/lib/enum.rb +47 -0
  36. data/lib/error_code.rb +56 -0
  37. data/lib/female-first-names.txt +4275 -0
  38. data/lib/ip.rb +86 -0
  39. data/lib/key_data.rb +70 -0
  40. data/lib/last-names.txt +88799 -0
  41. data/lib/male-first-names.txt +1219 -0
  42. data/lib/nicinfo_logger.rb +370 -0
  43. data/lib/nicinfo_main.rb +1013 -0
  44. data/lib/notices.rb +110 -0
  45. data/lib/ns.rb +108 -0
  46. data/lib/utils.rb +189 -0
  47. metadata +90 -0
data/lib/demo/ns.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "nicInfo_demoUrl" : "http://rdappilot.arin.net/rdapbootstrap/nameserver/ns1.xn--fo-5ja.example",
3
+ "nicInfo_demoHint" : "nicinfo ns1.xn--fo-5ja.example",
4
+ "rdapConformance":[
5
+ "rdap_level_0"
6
+ ],
7
+ "notices":[
8
+ {
9
+ "title":"Rhetorical License",
10
+ "description":[
11
+ "Lorem ipsum dolor sit amet, has reque blandit recusabo ex, id cibo epicuri erroribus pri. Qui epicurei facilisis deseruisse at. Posse fierent persecuti mei te, ut vix lucilius expetenda. Quo ei inani minimum. In cum delenit definiebas, et dico case delicata vim, mei unum feugiat suscipiantur et. Sale soluta democritum ea eum.",
12
+ "Quo at diam fabulas. Cum dicant electram eu, his at graeco maiorum omittantur, numquam abhorreant instructior ad est. Legendos similique sea ei, fabellas voluptaria sed eu, pro et oblique utroque. Mea ornatus sapientem ex. Etiam gubergren eam id, eum id possit deleniti electram, dicat philosophia sed eu.",
13
+ "Ut vis dicunt laboramus, vis dolorem nostrum at. Vix suas nihil nostrud an, te his tation placerat luptatum, no minim nobis sea. Cum cu congue platonem hendrerit. Ex sint dolor constituam per, per an novum qualisque, rebum prompta ius ex. Nec in fabellas referrentur, quot dicit veniam has at, mea fuisset denique ut. Ut justo munere sed, facilisis efficiendi ei has.",
14
+ "Eros alterum oporteat nec ut, iriure malorum hendrerit ne est. Ius aliquam mandamus id, sea in vide soleat reprehendunt, has officiis maluisset prodesset cu. No qui dolore putent, ea veniam appetere persecuti mei, an eam tamquam delicata. Laoreet appetere scripserit mei eu, usu elit indoctum ex, error homero erroribus pro at. Cum an epicuri omittam conceptam. Ad tota utamur vix, illum eleifend efficiendi per ne.",
15
+ "Meliore vivendo concludaturque in pro, congue dictas usu at, ei viris assueverit mea. Veri rebum dicant no mea, ea facer altera mentitum sit. Eros sale reprimique id duo, graeco invenire ex eos, has affert munere bonorum te. Fuisset corpora eu pri. Aliquid sensibus duo id, mea assum maiestatis ad, integre accommodare eum no."
16
+ ],
17
+ "links":[
18
+ {
19
+ "value":"http://example.net/ip/192.0.2.0/24",
20
+ "rel":"license",
21
+ "type":"text/html",
22
+ "href":"http://www.example.com/license.html"
23
+ }
24
+ ]
25
+ }
26
+ ],
27
+ "handle":"XXXX",
28
+ "objectClassName":"entity",
29
+ "ldhName":"ns1.xn--fo-5ja.example",
30
+ "unicodeName":"foo.example",
31
+ "status":[ "active" ],
32
+ "ipAddresses":{
33
+ "v4":[ "192.0.2.1", "192.0.2.2" ],
34
+ "v6":[ "2001:db8::123" ]
35
+ },
36
+ "remarks":[
37
+ {
38
+ "description":[
39
+ "She sells sea shells down by the sea shore.",
40
+ "Originally written by Terry Sullivan."
41
+ ]
42
+ }
43
+ ],
44
+ "links":[
45
+ {
46
+ "value":"http://rdappilot.arin.net/rdapbootstrap/nameserver/ns1.xn--fo-5ja.example",
47
+ "rel":"self",
48
+ "href":"http://rdappilot.arin.net/rdapbootstrap/nameserver/ns1.xn--fo-5ja.example"
49
+ }
50
+ ],
51
+ "port43":"whois.example.net",
52
+ "events":[
53
+ {
54
+ "eventAction":"registration",
55
+ "eventDate":"1990-12-31T23:59:60Z"
56
+ },
57
+ {
58
+ "eventAction":"last changed",
59
+ "eventDate":"1991-12-31T23:59:60Z",
60
+ "eventActor":"joe@bob.com"
61
+ }
62
+ ]
63
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "nicInfo_demoUrl" : "http://rdappilot.arin.net/restfulwhois/rdap/ip/192.0.2.0/24",
3
+ "nicInfo_demoHint" : "nicinfo 192.0.2.0/24",
4
+ "rdapConformance":[
5
+ "rdap_level_0"
6
+ ],
7
+ "notices":[
8
+ {
9
+ "title":"Content Redacted",
10
+ "description":[
11
+ "Without full authorization, content has been redacted.",
12
+ "Sorry, dude!"
13
+ ],
14
+ "links":[
15
+ {
16
+ "value":"http://example.net/ip/192.0.2.0/24",
17
+ "rel":"alternate",
18
+ "type":"text/html",
19
+ "href":"http://www.example.com/redaction_policy.html"
20
+ }
21
+ ]
22
+ }
23
+ ],
24
+ "lang":"en",
25
+ "startAddress":"192.0.2.0",
26
+ "endAddress":"192.0.2.255",
27
+ "handle":"XXXX-RIR",
28
+ "objectClassName":"ip network",
29
+ "ipVersion":"v4",
30
+ "name":"NET-RTR-1",
31
+ "description":[ "A network used for example documentation" ],
32
+ "parentHandle":"YYYY-RIR",
33
+ "remarks":[
34
+ {
35
+ "description":[
36
+ "She sells sea shells down by the sea shore.",
37
+ "Originally written by Terry Sullivan."
38
+ ]
39
+ }
40
+ ]
41
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "nicInfo_demoUrl" : "http://rdappilot.arin.net/restfulwhois/rdap/entity/ABC123",
3
+ "nicInfo_demoHint" : "nicinfo --type entityhandle ABC123",
4
+ "handle":"ABC123",
5
+ "remarks":[
6
+ {
7
+ "description":[
8
+ "She sells sea shells down by the sea shore.",
9
+ "Originally written by Terry Sullivan."
10
+ ]
11
+ }
12
+ ]
13
+ }
data/lib/domain.rb ADDED
@@ -0,0 +1,203 @@
1
+ # Copyright (C) 2011,2012,2013,2014 American Registry for Internet Numbers
2
+ #
3
+ # Permission to use, copy, modify, and/or distribute this software for any
4
+ # purpose with or without fee is hereby granted, provided that the above
5
+ # copyright notice and this permission notice appear in all copies.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
13
+ # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+
15
+ require 'config'
16
+ require 'nicinfo_logger'
17
+ require 'utils'
18
+ require 'common_json'
19
+ require 'entity'
20
+ require 'ns'
21
+ require 'ds_data'
22
+ require 'key_data'
23
+ require 'data_tree'
24
+
25
+ module NicInfo
26
+
27
+ def NicInfo.display_domain json_data, config, data_node
28
+ obj_array = json_data
29
+ unless json_data.instance_of? Array
30
+ obj_array = Array.new
31
+ obj_array << json_data
32
+ end
33
+ respObjs = ResponseObjSet.new config
34
+ obj_array.each do |array_object|
35
+ domain = Domain.new( config ).process( array_object )
36
+ root = domain.to_node
37
+ data_node.add_root( root )
38
+ if !domain.entities.empty? or !domain.nameservers.empty?
39
+ domain.ds_data_objs.each do |ds|
40
+ ds_node = ds.to_node
41
+ root.add_child( ds_node )
42
+ end
43
+ domain.key_data_objs.each do |key|
44
+ key_node = key.to_node
45
+ root.add_child( key_node )
46
+ end
47
+ NicInfo::add_entity_nodes( domain.entities, root )
48
+ domain.nameservers.each do |ns|
49
+ ns_node = ns.to_node
50
+ root.add_child( ns_node )
51
+ NicInfo::add_entity_nodes( ns.entities, ns_node )
52
+ end
53
+ end
54
+ if domain.network
55
+ net_node = domain.network.to_node
56
+ root.add_child net_node
57
+ NicInfo::add_entity_nodes( domain.network.entities, net_node )
58
+ end
59
+ respObjs.add domain
60
+ domain.ds_data_objs.each do |ds|
61
+ respObjs.add ds
62
+ end
63
+ domain.key_data_objs.each do |key|
64
+ respObjs.add key
65
+ end
66
+ NicInfo::add_entity_respobjs( domain.entities, respObjs )
67
+ respObjs.associateEntities domain.entities
68
+ domain.nameservers.each do |ns|
69
+ respObjs.add ns
70
+ NicInfo::add_entity_respobjs( ns.entities, respObjs )
71
+ respObjs.associateEntities ns.entities
72
+ end
73
+ if domain.network
74
+ respObjs.add domain.network
75
+ NicInfo::add_entity_respobjs( domain.network.entities, respObjs )
76
+ end
77
+ end
78
+ data_node.to_normal_log( config.logger, true )
79
+ respObjs.display
80
+ end
81
+
82
+ def NicInfo.display_domains json_data, config, data_tree
83
+ domain_array = json_data[ "domainSearchResults" ]
84
+ if domain_array != nil
85
+ if domain_array.instance_of? Array
86
+ NicInfo.display_domain( domain_array, config, data_tree )
87
+ else
88
+ config.conf_msgs << "'domainSearchResults' is not an array"
89
+ end
90
+ else
91
+ config.conf_msgs << "'domainSearchResults' is not present"
92
+ end
93
+ end
94
+
95
+ # deals with RDAP nameserver structures
96
+ class Domain
97
+
98
+ attr_accessor :entities, :nameservers, :ds_data_objs, :key_data_objs, :objectclass, :asEventActors, :network
99
+
100
+ def initialize config
101
+ @config = config
102
+ @common = CommonJson.new config
103
+ @entities = Array.new
104
+ @asEventActors = Array.new
105
+ @nameservers = Array.new
106
+ @ds_data_objs = Array.new
107
+ @key_data_objs = Array.new
108
+ end
109
+
110
+ def process json_data
111
+ @objectclass = json_data
112
+ @entities = @common.process_entities @objectclass
113
+ json_nses = NicInfo::get_nameservers json_data
114
+ json_nses.each do |json_ns|
115
+ ns = Ns.new( @config )
116
+ ns.process( json_ns )
117
+ @nameservers << ns
118
+ end if json_nses
119
+ json_net = NicInfo::get_network json_data
120
+ if json_net
121
+ ip = Ip.new @config
122
+ ip.process json_net
123
+ @network = ip
124
+ end
125
+ json_ds_data_objs = NicInfo::get_ds_data_objs @objectclass
126
+ json_ds_data_objs.each do |json_ds|
127
+ dsData = DsData.new( @config )
128
+ dsData.process( json_ds )
129
+ @ds_data_objs << dsData
130
+ end if json_ds_data_objs
131
+ json_key_data_objs = NicInfo::get_key_data_objs @objectclass
132
+ json_key_data_objs.each do |json_key|
133
+ keyData = KeyData.new( @config )
134
+ keyData.process( json_key )
135
+ @key_data_objs << keyData
136
+ end if json_key_data_objs
137
+ return self
138
+ end
139
+
140
+ def display
141
+ @config.logger.start_data_item
142
+ @config.logger.data_title "[ DOMAIN ]"
143
+ @config.logger.terse "Handle", NicInfo::get_handle( @objectclass )
144
+ @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass )
145
+ @config.logger.terse "Domain Name", NicInfo::get_ldhName( @objectclass )
146
+ @config.logger.datum "I18N Domain Name", NicInfo::get_unicodeName( @objectclass )
147
+ variants = @objectclass[ "variants" ]
148
+ variant_no = 1
149
+ variants.each do |variant|
150
+ relation = variant[ "relation" ]
151
+ item_value = ""
152
+ if relation
153
+ arr = Array.new
154
+ relation.each do |rel|
155
+ arr << NicInfo.capitalize( rel )
156
+ end
157
+ item_value = arr.join( ", " )
158
+ end
159
+ @config.logger.extra "Variant #{variant_no}", item_value
160
+ @config.logger.extra "IDN Table", variant[ "idnTable" ]
161
+ variant_names = variant[ "variantNames" ]
162
+ variant_names.each do |variant_name|
163
+ @config.logger.extra "Variant Domain", NicInfo::get_ldhName( variant_name )
164
+ @config.logger.extra "Variant IDN", NicInfo::get_unicodeName( variant_name )
165
+ end if variant_names
166
+ variant_no = variant_no + 1
167
+ end if variants
168
+ @common.display_public_ids @objectclass
169
+ @common.display_status @objectclass
170
+ @common.display_events @objectclass
171
+ @common.display_as_events_actors @asEventActors
172
+ @common.display_port43 @objectclass
173
+ @common.display_remarks @objectclass
174
+ @common.display_links( get_cn, @objectclass )
175
+ secure_dns = NicInfo::get_secure_dns( @objectclass )
176
+ if secure_dns.instance_of? Array
177
+ secure_dns = secure_dns[ 0 ]
178
+ end
179
+ if secure_dns
180
+ @config.logger.terse "Zone Signed", secure_dns[ "zoneSigned" ]
181
+ @config.logger.terse "Delegation Signed", secure_dns[ "delegationSigned" ]
182
+ @config.logger.terse "Max Signature Life", secure_dns[ "maxSigLife" ]
183
+ end
184
+ @config.logger.end_data_item
185
+ end
186
+
187
+ def get_cn
188
+ handle = NicInfo::get_handle @objectclass
189
+ handle = NicInfo::get_ldhName @objectclass if !handle
190
+ handle = "(unidentifiable domain #{object_id})" if !handle
191
+ if (name = NicInfo::get_ldhName( @objectclass ) ) != nil
192
+ return "#{name} ( #{handle} )"
193
+ end
194
+ return handle
195
+ end
196
+
197
+ def to_node
198
+ DataNode.new( get_cn, nil, NicInfo::get_self_link( NicInfo::get_links( @objectclass, @config ) ) )
199
+ end
200
+
201
+ end
202
+
203
+ end
data/lib/ds_data.rb ADDED
@@ -0,0 +1,70 @@
1
+ # Copyright (C) 2011,2012,2013,2014 American Registry for Internet Numbers
2
+ #
3
+ # Permission to use, copy, modify, and/or distribute this software for any
4
+ # purpose with or without fee is hereby granted, provided that the above
5
+ # copyright notice and this permission notice appear in all copies.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
13
+ # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+
15
+ require 'config'
16
+ require 'nicinfo_logger'
17
+ require 'utils'
18
+ require 'common_json'
19
+ require 'data_tree'
20
+
21
+ module NicInfo
22
+
23
+ def NicInfo.display_ds_data json_data, config, data_node
24
+ ds_data = DsData.new( config ).process( json_data ).display
25
+ end
26
+
27
+ # deals with RDAP ds_data structures
28
+ class DsData
29
+
30
+ attr_accessor :objectclass, :asEventActors
31
+
32
+ def initialize config
33
+ @config = config
34
+ @common = CommonJson.new config
35
+ @asEventActors = Array.new
36
+ end
37
+
38
+ def process json_data
39
+ @objectclass = json_data
40
+ return self
41
+ end
42
+
43
+ def display
44
+ @config.logger.start_data_item
45
+ @config.logger.data_title "[ DELEGATION SIGNER ]"
46
+ @config.logger.terse "Algorithm", NicInfo::get_algorithm( @objectclass )
47
+ @config.logger.terse "Digest", @objectclass[ "digest" ]
48
+ @config.logger.terse "Digest Type", @objectclass[ "digestType" ]
49
+ @config.logger.terse "Key Tag", @objectclass[ "keyTag" ]
50
+ @common.display_events @objectclass
51
+ @common.display_as_events_actors @asEventActors
52
+ @config.logger.end_data_item
53
+ end
54
+
55
+ def get_cn
56
+ algorithm = NicInfo::DNSSEC_ALGORITHMS[ NicInfo::get_algorithm( @objectclass ) ]
57
+ algorithm = algorithm + " DS Data" if algorithm
58
+ algorithm = "(unidentifiable DS data #{object_id})" if !algorithm
59
+ return algorithm
60
+ end
61
+
62
+ def to_node
63
+ node = DataNode.new( get_cn, nil, NicInfo::get_self_link( NicInfo::get_links( @objectclass, @config ) ) )
64
+ node.data_type=self.class.name
65
+ return node
66
+ end
67
+
68
+ end
69
+
70
+ end