Skip to content

Commit d5d80fa

Browse files
committed
Converted string enums back into regular attributes (closes #145).
* Note: `Cert#public_key_algorithm` now both stores and returns `"RSA"`, `"DSA"`, `"DH"`, and `"EC"`. * Note: `OS#flavor` now both stores and returns `"Linux"` and `"BSD"`. * Note: `DNSQuery#type` now both stores and returns `"A"`, `"AAAA"`, `"ANY"`, `"CNAME"`, `"HINFO"`, `"LOC"`, `"MX"`, `"NS"`, `"PTR"`, `"SOA"`, `"SRV"`, `"TXT"`, `"WKS"`. * Note: `HTTPRequest#request_method` now both stores and returns `"COPY"`, `"DELETE"`, `"GET"`, `"HEAD"`, `"LOCK"`, `"MKCOL"`, `"MOVE"`, `"OPTIONS"`, `"PATCH"`, `"POST"`, `"PROPFIND"`, `"PROPPATCH"`, `"PUT"`, `"TRACE"`, `"UNLOCK"`. * Note: `PersonalConnection#type` now both stores and returns `"friend"`, `"collegue"`, `"coworker"`, `"parent"`, `"mother"`, `"father"`, `"aunt"`, `"uncle"`, `"brother"`, `"sister"`, `"cousin"`, `"nephew`" `"niece"`, `"stepmother"`, `"stepfather"`, `"stepchild"`, `"stepbrother"`, `"stepsister"`, `"in-law"`, `"father-in-law"`, `"mother-in-law"`, `"partner"`, `"boyfriend"`, `"girlfriend"`, `"husband"`, `"wife"`, `"ex"`, `"ex-husband"`, `"ex-wife"`. * Note: `WebVuln#request_method` now both stores and returns `"COPY"`, `"DELETE"`, `"GET"`, `"HEAD"`, `"LOCK"`, `"MKCOL"`, `"MOVE"`, `"OPTIONS"`, `"PATCH"`, `"POST"`, `"PROPFIND"`, `"PROPPATCH"`, `"PUT"`, `"TRACE"`, `"UNLOCK"`. * Note: the following dynamically defined `WebVuln` enum methods were removed, and not replaced with explicit methods, as they were excessive: * `lfi_filter_bypass_base64?` * `lfi_filter_bypass_null_byte?` * `lfi_filter_bypass_rot13?` * `lfi_filter_bypass_zlib?` * `lfi_os_unix?` * `lfi_os_windows?` * `rfi_filter_bypass_double_encode?` * `rfi_filter_bypass_null_byte?` * `rfi_script_lang_asp?` * `rfi_script_lang_asp_net?` * `rfi_script_lang_cold_fusion?` * `rfi_script_lang_jsp?` * `rfi_script_lang_perl?` * `rfi_script_lang_php?` * `ssti_escape_type_angle_brackets_percent?` * `ssti_escape_type_custom?` * `ssti_escape_type_dollar_curly_braces?` * `ssti_escape_type_dollar_double_curly_braces?` * `ssti_escape_type_double_curly_braces?` * `ssti_escape_type_pound_curly_braces?`
1 parent 048cd26 commit d5d80fa

22 files changed

+1739
-798
lines changed

lib/ronin/db/arch.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ class Arch < ActiveRecord::Base
4545
# Endianness of the architecture.
4646
#
4747
# @return ["little", "big"]
48-
enum :endian, {little: 'little', big: 'big'}
49-
validates :endian, presence: true
48+
attribute :endian, :string
49+
validates :endian, presence: true,
50+
inclusion: {in: %w[little big]}
5051

5152
# @!attribute [rw] word_size
5253
# Address length of the architecture.

lib/ronin/db/cert.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ class Cert < ActiveRecord::Base
8787
# @!attribute [rw] public_key_algorithm
8888
# The public key algorithm.
8989
#
90-
# @return ["rsa", "dsa", "dh", "ec"]
91-
enum :public_key_algorithm, {rsa: 'RSA', dsa: 'DSA', dh: 'DH', ec: 'EC'}
92-
validates :public_key_algorithm, presence: true
90+
# @return ["RSA", "DSA", "DH", "EC"]
91+
attribute :public_key_algorithm, :string
92+
validates :public_key_algorithm, presence: true,
93+
inclusion: {in: %w[RSA DSA DH EC]}
9394

9495
# @!attribute [rw] public_key_size
9596
# The public key size in bits.
@@ -370,16 +371,16 @@ def self.lookup(cert)
370371
def self.import(cert)
371372
case (public_key = cert.public_key)
372373
when OpenSSL::PKey::RSA
373-
public_key_algorithm = :rsa
374+
public_key_algorithm = 'RSA'
374375
public_key_size = public_key.n.num_bits
375376
when OpenSSL::PKey::DSA
376-
public_key_algorithm = :dsa
377+
public_key_algorithm = 'DSA'
377378
public_key_size = public_key.p.num_bits
378379
when OpenSSL::PKey::DH
379-
public_key_algorithm = :dh
380+
public_key_algorithm = 'DH'
380381
public_key_size = public_key.p.num_bits
381382
when OpenSSL::PKey::EC
382-
public_key_algorithm = :ec
383+
public_key_algorithm = 'EC'
383384

384385
public_key_text = public_key.to_text
385386
public_key_size = if (match = public_key_text.match(/\((\d+) bit\)/))

lib/ronin/db/dns_query.rb

Lines changed: 136 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,25 @@ class DNSQuery < ActiveRecord::Base
4444
# The queried record type.
4545
#
4646
# @return [String]
47-
enum type: {
48-
a: 'A',
49-
aaaa: 'AAAA',
50-
any: 'ANY',
51-
cname: 'CNAME',
52-
hinfo: 'HINFO',
53-
loc: 'LOC',
54-
mx: 'MX',
55-
ns: 'NS',
56-
ptr: 'PTR',
57-
soa: 'SOA',
58-
srv: 'SRV',
59-
txt: 'TXT',
60-
wks: 'WKS'
61-
}, _suffix: :query
62-
validates :type, presence: true
47+
attribute :type, :string
48+
validates :type, presence: true,
49+
inclusion: {
50+
in: %w[
51+
A
52+
AAAA
53+
ANY
54+
CNAME
55+
HINFO
56+
LOC
57+
MX
58+
NS
59+
PTR
60+
SOA
61+
SRV
62+
TXT
63+
WKS
64+
]
65+
}
6366

6467
# @!attribute [rw] label
6568
# The queried domain label.
@@ -92,6 +95,123 @@ class DNSQuery < ActiveRecord::Base
9295
# @return [Array<DNSRecord>]
9396
has_many :records, class_name: 'DNSRecord'
9497

98+
#
99+
# Determines if the DNS query is an A record query.
100+
#
101+
# @return [Boolean]
102+
#
103+
def a_query?
104+
self.type == 'A'
105+
end
106+
107+
#
108+
# Determines if the DNS query is an AAAA record query.
109+
#
110+
# @return [Boolean]
111+
#
112+
def aaaa_query?
113+
self.type == 'AAAA'
114+
end
115+
116+
#
117+
# Determines if the DNS query is an ANY record query.
118+
#
119+
# @return [Boolean]
120+
#
121+
def any_query?
122+
self.type == 'ANY'
123+
end
124+
125+
#
126+
# Determines if the DNS query is an CNAME record query.
127+
#
128+
# @return [Boolean]
129+
#
130+
def cname_query?
131+
self.type == 'CNAME'
132+
end
133+
134+
#
135+
# Determines if the DNS query is an HINFO record query.
136+
#
137+
# @return [Boolean]
138+
#
139+
def hinfo_query?
140+
self.type == 'HINFO'
141+
end
142+
143+
#
144+
# Determines if the DNS query is an LOC record query.
145+
#
146+
# @return [Boolean]
147+
#
148+
def loc_query?
149+
self.type == 'LOC'
150+
end
151+
152+
#
153+
# Determines if the DNS query is an MX record query.
154+
#
155+
# @return [Boolean]
156+
#
157+
def mx_query?
158+
self.type == 'MX'
159+
end
160+
161+
#
162+
# Determines if the DNS query is an NS record query.
163+
#
164+
# @return [Boolean]
165+
#
166+
def ns_query?
167+
self.type == 'NS'
168+
end
169+
170+
#
171+
# Determines if the DNS query is an PTR record query.
172+
#
173+
# @return [Boolean]
174+
#
175+
def ptr_query?
176+
self.type == 'PTR'
177+
end
178+
179+
#
180+
# Determines if the DNS query is an SOA record query.
181+
#
182+
# @return [Boolean]
183+
#
184+
def soa_query?
185+
self.type == 'SOA'
186+
end
187+
188+
#
189+
# Determines if the DNS query is an SRV record query.
190+
#
191+
# @return [Boolean]
192+
#
193+
def srv_query?
194+
self.type == 'SRV'
195+
end
196+
197+
#
198+
# Determines if the DNS query is an TXT record query.
199+
#
200+
# @return [Boolean]
201+
#
202+
def txt_query?
203+
self.type == 'TXT'
204+
end
205+
206+
#
207+
# Determines if the DNS query is an WKS record query.
208+
#
209+
# @return [Boolean]
210+
#
211+
def wks_query?
212+
self.type == 'WKS'
213+
end
214+
95215
end
96216
end
97217
end

0 commit comments

Comments
 (0)