Class: Ronin::DB::HostName
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ronin::DB::HostName
- Includes:
- Model, Model::Importable, Model::LastScannedAt
- Defined in:
- lib/ronin/db/host_name.rb
Overview
Represents host names and their associated IP addresses.
Instance Attribute Summary collapse
-
#advisories ⇒ Array<Advisory>
The advisories that the host names is vulnerable to.
-
#created_at ⇒ Time
When the host name was first created.
-
#email_addresses ⇒ Array<EmailAddress>
The email addresses that are associated with the host-name.
-
#host_name_ip_addresses ⇒ Array<HostNameIPAddress>
The IP Address associations.
-
#id ⇒ Integer
The primary ID of the host name.
-
#ip_addresses ⇒ Array<IPAddress>
The IP Addresses that host the host name.
-
#name ⇒ String
The address of the host name.
-
#notes ⇒ Array<Note>
The associated notes.
-
#open_ports ⇒ Array<OpenPort>
The open ports of the host.
-
#organization_host_names ⇒ Array<OrganizationHostName>
The association of host names and organizations.
-
#organizations ⇒ Array<Organization>
The organizations that claim ownership of the host name.
-
#ports ⇒ Array<Port>
The ports of the host.
-
#urls ⇒ Array<URL>
The URLs that point to this host name.
-
#vulnerabilities ⇒ Array<Vulnerability>
The vulnerabilities which reference the host name.
Attributes included from Model::LastScannedAt
Class Method Summary collapse
-
.import(name) ⇒ HostName
Creates a new host name.
-
.lookup(name) ⇒ HostName?
Looks up the host name.
-
.with_domain(name) ⇒ Array<HostName>
Searches for all host names sharing a canonical domain name.
-
.with_ip_address(ip) ⇒ Array<HostName>
Searches for host names associated with the given IP address(es).
-
.with_port_number(number) ⇒ Array<HostName>
Searches for host names with the given open port(s).
-
.with_tld(name) ⇒ Array<HostName>
Searches for all host names under the Top-Level Domain (TLD).
Instance Method Summary collapse
-
#recent_ip_address ⇒ IPAddress
The IP Address that was most recently used by the host name.
-
#to_s ⇒ String
Converts the host name to a String.
Methods included from Model::LastScannedAt
Methods included from Model::Importable
Methods included from Model
Instance Attribute Details
#advisories ⇒ Array<Advisory>
The advisories that the host names is vulnerable to.
118 |
# File 'lib/ronin/db/host_name.rb', line 118 has_many :advisories, through: :vulnerabilities |
#created_at ⇒ Time
When the host name was first created.
63 |
# File 'lib/ronin/db/host_name.rb', line 63 attribute :created_at, :datetime |
#email_addresses ⇒ Array<EmailAddress>
The email addresses that are associated with the host-name.
95 |
# File 'lib/ronin/db/host_name.rb', line 95 has_many :email_addresses, dependent: :destroy |
#host_name_ip_addresses ⇒ Array<HostNameIPAddress>
The IP Address associations.
69 70 |
# File 'lib/ronin/db/host_name.rb', line 69 has_many :host_name_ip_addresses, dependent: :destroy, class_name: 'HostNameIPAddress' |
#id ⇒ Integer
The primary ID of the host name.
44 |
# File 'lib/ronin/db/host_name.rb', line 44 attribute :id, :integer |
#ip_addresses ⇒ Array<IPAddress>
The IP Addresses that host the host name.
76 77 |
# File 'lib/ronin/db/host_name.rb', line 76 has_many :ip_addresses, through: :host_name_ip_addresses, class_name: 'IPAddress' |
#name ⇒ String
The address of the host name.
50 |
# File 'lib/ronin/db/host_name.rb', line 50 attribute :name, :string |
#notes ⇒ Array<Note>
The associated notes.
142 |
# File 'lib/ronin/db/host_name.rb', line 142 has_many :notes, dependent: :destroy |
#open_ports ⇒ Array<OpenPort>
The open ports of the host.
83 |
# File 'lib/ronin/db/host_name.rb', line 83 has_many :open_ports, through: :ip_addresses |
#organization_host_names ⇒ Array<OrganizationHostName>
The association of host names and organizations.
126 |
# File 'lib/ronin/db/host_name.rb', line 126 has_many :organization_host_names, dependent: :destroy |
#organizations ⇒ Array<Organization>
The organizations that claim ownership of the host name.
134 |
# File 'lib/ronin/db/host_name.rb', line 134 has_many :organizations, through: :organization_host_names |
#ports ⇒ Array<Port>
The ports of the host.
89 |
# File 'lib/ronin/db/host_name.rb', line 89 has_many :ports, through: :ip_addresses |
#urls ⇒ Array<URL>
The URLs that point to this host name.
101 102 |
# File 'lib/ronin/db/host_name.rb', line 101 has_many :urls, dependent: :destroy, class_name: 'URL' |
#vulnerabilities ⇒ Array<Vulnerability>
The vulnerabilities which reference the host name.
110 |
# File 'lib/ronin/db/host_name.rb', line 110 has_many :vulnerabilities, dependent: :destroy |
Class Method Details
.import(name) ⇒ HostName
Creates a new host name.
166 167 168 |
# File 'lib/ronin/db/host_name.rb', line 166 def self.import(name) create(name: name) end |
.lookup(name) ⇒ HostName?
Looks up the host name.
153 154 155 |
# File 'lib/ronin/db/host_name.rb', line 153 def self.lookup(name) find_by(name: name) end |
.with_domain(name) ⇒ Array<HostName>
Searches for all host names sharing a canonical domain name.
228 229 230 231 232 233 234 |
# File 'lib/ronin/db/host_name.rb', line 228 def self.with_domain(name) name_column = self.arel_table[:name] name = sanitize_sql_like(name) where(name: name).or(where(name_column.matches("%.#{name}"))) end |
.with_ip_address(ip) ⇒ Array<HostName>
Searches for host names associated with the given IP address(es).
181 182 183 |
# File 'lib/ronin/db/host_name.rb', line 181 def self.with_ip_address(ip) joins(:ip_addresses).where(ip_addresses: {address: ip}) end |
.with_port_number(number) ⇒ Array<HostName>
Searches for host names with the given open port(s).
196 197 198 |
# File 'lib/ronin/db/host_name.rb', line 196 def self.with_port_number(number) joins(:ports).where(ports: {number: number}) end |
.with_tld(name) ⇒ Array<HostName>
Searches for all host names under the Top-Level Domain (TLD).
211 212 213 214 215 |
# File 'lib/ronin/db/host_name.rb', line 211 def self.with_tld(name) name_column = self.arel_table[:name] where(name_column.matches("%.#{sanitize_sql_like(name)}")) end |
Instance Method Details
#recent_ip_address ⇒ IPAddress
The IP Address that was most recently used by the host name.
244 245 246 |
# File 'lib/ronin/db/host_name.rb', line 244 def recent_ip_address self.host_name_ip_addresses.order('created_at DESC').ip_addresses.first end |
#to_s ⇒ String
Converts the host name to a String.
256 257 258 |
# File 'lib/ronin/db/host_name.rb', line 256 def to_s self.name.to_s end |