censu 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -1
- data/.rubocop.yml +41 -35
- data/README.md +2 -2
- data/censys.gemspec +1 -1
- data/lib/censu.rb +2 -0
- data/lib/censys.rb +2 -0
- data/lib/censys/account.rb +23 -0
- data/lib/censys/account/quota.rb +17 -0
- data/lib/censys/api.rb +11 -2
- data/lib/censys/autonomous_system.rb +2 -0
- data/lib/censys/certificate.rb +2 -0
- data/lib/censys/data.rb +2 -0
- data/lib/censys/data/response.rb +2 -0
- data/lib/censys/data/result.rb +2 -2
- data/lib/censys/data/series.rb +2 -7
- data/lib/censys/data/series_list.rb +2 -0
- data/lib/censys/document.rb +2 -0
- data/lib/censys/document/has_asn.rb +2 -0
- data/lib/censys/document/has_http_response.rb +3 -1
- data/lib/censys/document/has_location.rb +2 -0
- data/lib/censys/document/has_services.rb +2 -0
- data/lib/censys/exceptions.rb +7 -10
- data/lib/censys/http_response.rb +2 -0
- data/lib/censys/ipv4.rb +2 -0
- data/lib/censys/location.rb +16 -10
- data/lib/censys/report.rb +2 -0
- data/lib/censys/report/metadata.rb +2 -0
- data/lib/censys/report/response.rb +2 -0
- data/lib/censys/search.rb +2 -0
- data/lib/censys/search/certificate.rb +2 -0
- data/lib/censys/search/ipv4.rb +2 -0
- data/lib/censys/search/metadata.rb +2 -0
- data/lib/censys/search/response.rb +2 -0
- data/lib/censys/search/result.rb +2 -0
- data/lib/censys/search/website.rb +2 -0
- data/lib/censys/version.rb +3 -2
- data/lib/censys/website.rb +2 -0
- data/spec/account_spec.rb +15 -0
- data/spec/censys_spec.rb +1 -2
- data/spec/data_spec.rb +4 -4
- data/spec/fixtures/vcr_cassettes/Censys_API/_account/should_return_an_Account.yml +47 -0
- data/spec/fixtures/vcr_cassettes/Censys_API/_data/result/{should_return_Result_response.yml → should_return_a_Data_Result.yml} +1 -1
- data/spec/fixtures/vcr_cassettes/Censys_API/_data/series/should_return_a_Data_Series.yml +53 -0
- data/spec/fixtures/vcr_cassettes/Censys_API/_data/series_list/{should_return_SeriesList_response.yml → should_return_a_Data_SeriesList.yml} +124 -107
- data/spec/fixtures/vcr_cassettes/Censys_API/_report/certificates/{should_return_certificate_response.yml → should_return_a_certificate_response.yml} +7 -7
- data/spec/fixtures/vcr_cassettes/Censys_API/_report/ipv4/{should_return_ipv4_response.yml → should_return_an_ipv4_response.yml} +10 -10
- data/spec/fixtures/vcr_cassettes/Censys_API/_report/websites/{should_return_website_response.yml → should_return_a_website_response.yml} +9 -9
- data/spec/fixtures/vcr_cassettes/Censys_API/_search/certificates/should_return_Certificate_response.yml +294 -351
- data/spec/fixtures/vcr_cassettes/Censys_API/_search/ipv4/should_return_IPv4_response.yml +396 -544
- data/spec/fixtures/vcr_cassettes/Censys_API/_search/websites/should_return_Website_response.yml +71 -71
- data/spec/fixtures/vcr_cassettes/Censys_API/_view/certificates/{should_return_Certificate_response.yml → should_return_a_Certificate_response.yml} +65 -68
- data/spec/fixtures/vcr_cassettes/Censys_API/_view/ipv4/should_return_IPv4_response.yml +95 -114
- data/spec/fixtures/vcr_cassettes/Censys_API/_view/ipv4/should_return_an_IPv4_response.yml +156 -0
- data/spec/fixtures/vcr_cassettes/Censys_API/_view/websites/{should_return_Website_response.yml → should_return_a_Website_response.yml} +504 -514
- data/spec/report_spec.rb +4 -4
- data/spec/search_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -1
- data/spec/view_spec.rb +6 -6
- metadata +26 -18
- data/spec/fixtures/vcr_cassettes/Censys_API/_data/series/should_return_Series_response.yml +0 -130
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8770860ef1c212a40039c69c74ab333edac166d8c070e1ccb4adf027caa535
|
4
|
+
data.tar.gz: 8b78c15ee59f19dd999ed69488b508be26931cfd6766ff747f8a179088f4d9e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a032559c4b00a88f655afc64b17fa3bcf9b4f445c826539b473c6e202f3c2583e8290a77c46077069cd4944c04ba91abb721c62a4f4ceae403dd058a9e97d0e8
|
7
|
+
data.tar.gz: b8f51ba142b1d75c286f9fba9ea3fe209d99cc9d55d983293bd0296d6c8734dec0560284e9d3627e95ed908701b53788344a6d12fb14a02b93600236df9a19c6
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,141 +1,148 @@
|
|
1
1
|
# Relaxed.Ruby.Style
|
2
2
|
## Version 2.2
|
3
3
|
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.5
|
6
|
+
|
4
7
|
Style/Alias:
|
5
8
|
Enabled: false
|
6
|
-
StyleGuide:
|
9
|
+
StyleGuide: https://relaxed.ruby.style/#stylealias
|
7
10
|
|
8
11
|
Style/AsciiComments:
|
9
12
|
Enabled: false
|
10
|
-
StyleGuide:
|
13
|
+
StyleGuide: https://relaxed.ruby.style/#styleasciicomments
|
11
14
|
|
12
15
|
Style/BeginBlock:
|
13
16
|
Enabled: false
|
14
|
-
StyleGuide:
|
17
|
+
StyleGuide: https://relaxed.ruby.style/#stylebeginblock
|
15
18
|
|
16
19
|
Style/BlockDelimiters:
|
17
20
|
Enabled: false
|
18
|
-
StyleGuide:
|
21
|
+
StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
|
19
22
|
|
20
23
|
Style/CommentAnnotation:
|
21
24
|
Enabled: false
|
22
|
-
StyleGuide:
|
25
|
+
StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
|
23
26
|
|
24
27
|
Style/Documentation:
|
25
28
|
Enabled: false
|
26
|
-
StyleGuide:
|
29
|
+
StyleGuide: https://relaxed.ruby.style/#styledocumentation
|
27
30
|
|
28
31
|
Layout/DotPosition:
|
29
32
|
Enabled: false
|
30
|
-
StyleGuide:
|
33
|
+
StyleGuide: https://relaxed.ruby.style/#layoutdotposition
|
31
34
|
|
32
35
|
Style/DoubleNegation:
|
33
36
|
Enabled: false
|
34
|
-
StyleGuide:
|
37
|
+
StyleGuide: https://relaxed.ruby.style/#styledoublenegation
|
35
38
|
|
36
39
|
Style/EndBlock:
|
37
40
|
Enabled: false
|
38
|
-
StyleGuide:
|
41
|
+
StyleGuide: https://relaxed.ruby.style/#styleendblock
|
39
42
|
|
40
43
|
Style/FormatString:
|
41
44
|
Enabled: false
|
42
|
-
StyleGuide:
|
45
|
+
StyleGuide: https://relaxed.ruby.style/#styleformatstring
|
43
46
|
|
44
47
|
Style/IfUnlessModifier:
|
45
48
|
Enabled: false
|
46
|
-
StyleGuide:
|
49
|
+
StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
|
47
50
|
|
48
51
|
Style/Lambda:
|
49
52
|
Enabled: false
|
50
|
-
StyleGuide:
|
53
|
+
StyleGuide: https://relaxed.ruby.style/#stylelambda
|
51
54
|
|
52
55
|
Style/ModuleFunction:
|
53
56
|
Enabled: false
|
54
|
-
StyleGuide:
|
57
|
+
StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
|
55
58
|
|
56
59
|
Style/MultilineBlockChain:
|
57
60
|
Enabled: false
|
58
|
-
StyleGuide:
|
61
|
+
StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
|
59
62
|
|
60
63
|
Style/NegatedIf:
|
61
64
|
Enabled: false
|
62
|
-
StyleGuide:
|
65
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedif
|
63
66
|
|
64
67
|
Style/NegatedWhile:
|
65
68
|
Enabled: false
|
66
|
-
StyleGuide:
|
69
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
|
67
70
|
|
68
71
|
Style/ParallelAssignment:
|
69
72
|
Enabled: false
|
70
|
-
StyleGuide:
|
73
|
+
StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
|
71
74
|
|
72
75
|
Style/PercentLiteralDelimiters:
|
73
76
|
Enabled: false
|
74
|
-
StyleGuide:
|
77
|
+
StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
|
75
78
|
|
76
79
|
Style/PerlBackrefs:
|
77
80
|
Enabled: false
|
78
|
-
StyleGuide:
|
81
|
+
StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
|
79
82
|
|
80
83
|
Style/Semicolon:
|
81
84
|
Enabled: false
|
82
|
-
StyleGuide:
|
85
|
+
StyleGuide: https://relaxed.ruby.style/#stylesemicolon
|
83
86
|
|
84
87
|
Style/SignalException:
|
85
88
|
Enabled: false
|
86
|
-
StyleGuide:
|
89
|
+
StyleGuide: https://relaxed.ruby.style/#stylesignalexception
|
87
90
|
|
88
91
|
Style/SingleLineBlockParams:
|
89
92
|
Enabled: false
|
90
|
-
StyleGuide:
|
93
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
|
91
94
|
|
92
95
|
Style/SingleLineMethods:
|
93
96
|
Enabled: false
|
94
|
-
StyleGuide:
|
97
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
|
95
98
|
|
96
99
|
Layout/SpaceBeforeBlockBraces:
|
97
100
|
Enabled: false
|
98
|
-
StyleGuide:
|
101
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
|
99
102
|
|
100
103
|
Layout/SpaceInsideParens:
|
101
104
|
Enabled: false
|
102
|
-
StyleGuide:
|
105
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
|
103
106
|
|
104
107
|
Style/SpecialGlobalVars:
|
105
108
|
Enabled: false
|
106
|
-
StyleGuide:
|
109
|
+
StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
|
107
110
|
|
108
111
|
Style/StringLiterals:
|
109
112
|
Enabled: false
|
110
|
-
StyleGuide:
|
113
|
+
StyleGuide: https://relaxed.ruby.style/#stylestringliterals
|
111
114
|
|
112
115
|
Style/TrailingCommaInArguments:
|
113
116
|
Enabled: false
|
114
|
-
StyleGuide:
|
117
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
|
115
118
|
|
116
119
|
Style/TrailingCommaInArrayLiteral:
|
117
120
|
Enabled: false
|
118
|
-
StyleGuide:
|
121
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
|
119
122
|
|
120
123
|
Style/TrailingCommaInHashLiteral:
|
121
124
|
Enabled: false
|
122
|
-
StyleGuide:
|
125
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
|
126
|
+
|
127
|
+
Style/SymbolArray:
|
128
|
+
Enabled: false
|
129
|
+
StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
|
123
130
|
|
124
131
|
Style/WhileUntilModifier:
|
125
132
|
Enabled: false
|
126
|
-
StyleGuide:
|
133
|
+
StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
|
127
134
|
|
128
135
|
Style/WordArray:
|
129
136
|
Enabled: false
|
130
|
-
StyleGuide:
|
137
|
+
StyleGuide: https://relaxed.ruby.style/#stylewordarray
|
131
138
|
|
132
139
|
Lint/AmbiguousRegexpLiteral:
|
133
140
|
Enabled: false
|
134
|
-
StyleGuide:
|
141
|
+
StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
|
135
142
|
|
136
143
|
Lint/AssignmentInCondition:
|
137
144
|
Enabled: false
|
138
|
-
StyleGuide:
|
145
|
+
StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
|
139
146
|
|
140
147
|
Metrics/AbcSize:
|
141
148
|
Enabled: false
|
@@ -163,4 +170,3 @@ Metrics/ParameterLists:
|
|
163
170
|
|
164
171
|
Metrics/PerceivedComplexity:
|
165
172
|
Enabled: false
|
166
|
-
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ require 'censys'
|
|
20
20
|
api = Censys::API.new(uid, secret)
|
21
21
|
```
|
22
22
|
|
23
|
-
Initialize the API using `$CENSYS_ID` and `$CENSYS_SECRET` environment variables:
|
23
|
+
Initialize the API by using `$CENSYS_ID` and `$CENSYS_SECRET` environment variables:
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
api = Censys::API.new
|
@@ -96,7 +96,7 @@ end
|
|
96
96
|
|
97
97
|
## Requirements
|
98
98
|
|
99
|
-
|
99
|
+
- Ruby 2.4 / 2.5
|
100
100
|
|
101
101
|
## Install
|
102
102
|
|
data/censys.gemspec
CHANGED
data/lib/censu.rb
CHANGED
data/lib/censys.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'censys/account/quota'
|
4
|
+
|
5
|
+
module Censys
|
6
|
+
class Account
|
7
|
+
attr_reader :api_id
|
8
|
+
attr_reader :email
|
9
|
+
attr_reader :first_login
|
10
|
+
attr_reader :last_login
|
11
|
+
attr_reader :login
|
12
|
+
attr_reader :quota
|
13
|
+
|
14
|
+
def initialize(attributes)
|
15
|
+
@api_id = attributes["api_id"]
|
16
|
+
@email = attributes["email"]
|
17
|
+
@first_login = attributes["first_login"]
|
18
|
+
@last_login = attributes["last_login"]
|
19
|
+
@login = attributes["login"]
|
20
|
+
@quota = Quota.new(attributes["quota"])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Censys
|
4
|
+
class Account
|
5
|
+
class Quota
|
6
|
+
attr_reader :used
|
7
|
+
attr_reader :resets_at
|
8
|
+
attr_reader :allowance
|
9
|
+
|
10
|
+
def initialize(attributes)
|
11
|
+
@used = attributes["used"]
|
12
|
+
@resets_at = attributes["resets_at"]
|
13
|
+
@allowance = attributes["allowance"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/censys/api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'censys/exceptions'
|
2
4
|
require 'censys/search'
|
3
5
|
require 'censys/report'
|
@@ -5,6 +7,7 @@ require 'censys/ipv4'
|
|
5
7
|
require 'censys/website'
|
6
8
|
require 'censys/certificate'
|
7
9
|
require 'censys/data'
|
10
|
+
require 'censys/account'
|
8
11
|
|
9
12
|
require 'net/https'
|
10
13
|
require 'json'
|
@@ -12,8 +15,8 @@ require 'json'
|
|
12
15
|
module Censys
|
13
16
|
class API
|
14
17
|
VERSION = 1
|
15
|
-
HOST = 'www.censys.io'
|
16
|
-
URL = "https://#{HOST}/api/v#{VERSION}"
|
18
|
+
HOST = 'www.censys.io'
|
19
|
+
URL = "https://#{HOST}/api/v#{VERSION}"
|
17
20
|
|
18
21
|
class Resource
|
19
22
|
def initialize(type, api)
|
@@ -188,6 +191,12 @@ module Censys
|
|
188
191
|
end
|
189
192
|
end
|
190
193
|
|
194
|
+
def account
|
195
|
+
get("/account") do |response|
|
196
|
+
Account.new(response)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
191
200
|
private
|
192
201
|
|
193
202
|
#
|
data/lib/censys/certificate.rb
CHANGED
data/lib/censys/data.rb
CHANGED
data/lib/censys/data/response.rb
CHANGED
data/lib/censys/data/result.rb
CHANGED
data/lib/censys/data/series.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Censys
|
2
4
|
module Data
|
3
5
|
class Series
|
4
6
|
attr_reader :id
|
5
|
-
|
6
7
|
attr_reader :port
|
7
|
-
|
8
8
|
attr_reader :protocol
|
9
|
-
|
10
9
|
attr_reader :subprotocol
|
11
|
-
|
12
10
|
attr_reader :destination
|
13
|
-
|
14
11
|
attr_reader :name
|
15
|
-
|
16
12
|
attr_reader :description
|
17
|
-
|
18
13
|
attr_reader :results
|
19
14
|
|
20
15
|
def initialize(attributes)
|
data/lib/censys/document.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'censys/http_response'
|
2
4
|
|
3
5
|
module Censys
|
@@ -9,7 +11,7 @@ module Censys
|
|
9
11
|
# @return [HTTPResponse]
|
10
12
|
#
|
11
13
|
def http_response
|
12
|
-
@
|
14
|
+
@http_response ||= HTTPResponse.new(@attributes.dig("80", "http"))
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/censys/exceptions.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Censys
|
2
|
-
class ResponseError <
|
3
|
-
end
|
4
|
+
class ResponseError < StandardError; end
|
4
5
|
|
5
|
-
class AuthenticationError < ResponseError
|
6
|
-
end
|
6
|
+
class AuthenticationError < ResponseError; end
|
7
7
|
|
8
|
-
class NotFound < ResponseError
|
9
|
-
end
|
8
|
+
class NotFound < ResponseError; end
|
10
9
|
|
11
|
-
class RateLimited < ResponseError
|
12
|
-
end
|
10
|
+
class RateLimited < ResponseError; end
|
13
11
|
|
14
|
-
class InternalServerError < ResponseError
|
15
|
-
end
|
12
|
+
class InternalServerError < ResponseError; end
|
16
13
|
end
|