Class: Ronin::DB::Service
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ronin::DB::Service
- Includes:
- Model, Model::HasUniqueName, Model::Importable
- Defined in:
- lib/ronin/db/service.rb
Overview
Represents a TCP/UDP Service that runs on various common ports.
Instance Attribute Summary collapse
-
#created_at ⇒ Time
readonly
Defines the created_at timestamp.
-
#id ⇒ Integer
Primary key of the service.
-
#ip_addresses ⇒ Array<IPAddress>
The IP Addresses that that run this service.
-
#notes ⇒ Array<Note>
The associated notes.
-
#open_ports ⇒ Array<OpenPort>
The open ports running the service.
-
#ports ⇒ Array<Port>
The ports that that use this service.
Attributes included from Model::HasUniqueName
Class Method Summary collapse
-
.import(name) ⇒ Service
Imports a service.
-
.lookup(name) ⇒ Service?
Looks up the service.
-
.with_ip_address(address) ⇒ Array<Service>
Queries all services associated with the IP address.
-
.with_port_number(number) ⇒ Array<Service>
Queries all services associated with the port number.
-
.with_protocol(protocol) ⇒ Array<Service>
Queries all services associated with the protocol.
Methods included from Model::HasUniqueName
Methods included from Model::Importable
Methods included from Model
Instance Attribute Details
#created_at ⇒ Time (readonly)
Defines the created_at timestamp
48 |
# File 'lib/ronin/db/service.rb', line 48 attribute :created_at, :datetime |
#id ⇒ Integer
Primary key of the service
40 |
# File 'lib/ronin/db/service.rb', line 40 attribute :id, :integer |
#ip_addresses ⇒ Array<IPAddress>
The IP Addresses that that run this service.
62 |
# File 'lib/ronin/db/service.rb', line 62 has_many :ip_addresses, through: :open_ports |
#notes ⇒ Array<Note>
The associated notes.
78 |
# File 'lib/ronin/db/service.rb', line 78 has_many :notes, dependent: :destroy |
#open_ports ⇒ Array<OpenPort>
The open ports running the service
54 |
# File 'lib/ronin/db/service.rb', line 54 has_many :open_ports |
#ports ⇒ Array<Port>
The ports that that use this service.
70 |
# File 'lib/ronin/db/service.rb', line 70 has_many :ports, through: :open_ports |
Class Method Details
.import(name) ⇒ Service
Imports a service.
169 170 171 |
# File 'lib/ronin/db/service.rb', line 169 def self.import(name) create(name: name) end |
.lookup(name) ⇒ Service?
Looks up the service.
154 155 156 |
# File 'lib/ronin/db/service.rb', line 154 def self.lookup(name) find_by(name: name) end |
.with_ip_address(address) ⇒ Array<Service>
Queries all services associated with the IP address.
135 136 137 138 139 140 141 |
# File 'lib/ronin/db/service.rb', line 135 def self.with_ip_address(address) joins(open_ports: :ip_address).where( open_ports: { ronin_ip_addresses: {address: address} } ) end |
.with_port_number(number) ⇒ Array<Service>
Queries all services associated with the port number.
93 94 95 96 97 98 99 |
# File 'lib/ronin/db/service.rb', line 93 def self.with_port_number(number) joins(open_ports: :port).where( open_ports: { ronin_ports: {number: number} } ) end |
.with_protocol(protocol) ⇒ Array<Service>
Queries all services associated with the protocol.
114 115 116 117 118 119 120 |
# File 'lib/ronin/db/service.rb', line 114 def self.with_protocol(protocol) joins(open_ports: :port).where( open_ports: { ronin_ports: {protocol: protocol} } ) end |