Class: Ronin::DB::OS
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ronin::DB::OS
- Includes:
- Model, Model::HasName
- Defined in:
- lib/ronin/db/os.rb
Overview
Represents an Operating System and pre-defines other common ones (OS.linux, OS.freebsd, OS.openbsd, OS.netbsd, OS.macos, and OS.windows.
Instance Attribute Summary collapse
-
#flavor ⇒ :linux, :bsd
The flavor of the OS (Linux, BSD).
-
#id ⇒ Integer
The primary key of the OS.
-
#ip_addresses ⇒ Array<IPAddress>
Any IP Addresses that might be running the Operating System.
-
#os_guesses ⇒ Array<OSGuess>
Any OS guesses for the Operating System.
-
#version ⇒ String
The version of the Operating System.
Attributes included from Model::HasName
Class Method Summary collapse
-
.freebsd(version) ⇒ OS
The FreeBSD OS.
-
.linux(version) ⇒ OS
The Linux OS.
-
.macos(version) ⇒ OS
The macOS OS.
-
.netbsd(version) ⇒ OS
The NetBSD OS.
-
.openbsd(version) ⇒ OS
The OpenBSD OS.
-
.windows(version) ⇒ OS
The Windows OS.
Instance Method Summary collapse
-
#recent_ip_address ⇒ IPAddress
The IP Address that was most recently guessed to be using the Operating System.
-
#to_s ⇒ String
Converts the Operating System to a String.
Methods included from Model::HasName
Methods included from Model
Instance Attribute Details
#flavor ⇒ :linux, :bsd
The flavor of the OS (Linux, BSD).
47 |
# File 'lib/ronin/db/os.rb', line 47 enum :flavor, {linux: 'Linux', bsd: 'BSD'} |
#id ⇒ Integer
The primary key of the OS.
41 |
# File 'lib/ronin/db/os.rb', line 41 attribute :id, :integer |
#ip_addresses ⇒ Array<IPAddress>
Any IP Addresses that might be running the Operating System
68 69 |
# File 'lib/ronin/db/os.rb', line 68 has_many :ip_addresses, through: :os_guesses, class_name: 'IPAddress' |
#os_guesses ⇒ Array<OSGuess>
Any OS guesses for the Operating System.
61 62 |
# File 'lib/ronin/db/os.rb', line 61 has_many :os_guesses, dependent: :destroy, class_name: 'OSGuess' |
#version ⇒ String
The version of the Operating System.
53 |
# File 'lib/ronin/db/os.rb', line 53 attribute :version, :string |
Class Method Details
.freebsd(version) ⇒ OS
The FreeBSD OS
91 92 93 |
# File 'lib/ronin/db/os.rb', line 91 def self.freebsd(version) find_or_create_by(name: 'FreeBSD', flavor: :bsd, version: version) end |
.linux(version) ⇒ OS
The Linux OS
79 80 81 |
# File 'lib/ronin/db/os.rb', line 79 def self.linux(version) find_or_create_by(name: 'Linux', flavor: :linux, version: version) end |
.macos(version) ⇒ OS
The macOS OS.
127 128 129 |
# File 'lib/ronin/db/os.rb', line 127 def self.macos(version) find_or_create_by(name: 'macOS', flavor: :bsd, version: version) end |
.netbsd(version) ⇒ OS
The NetBSD OS
115 116 117 |
# File 'lib/ronin/db/os.rb', line 115 def self.netbsd(version) find_or_create_by(name: 'NetBSD', flavor: :bsd, version: version) end |
.openbsd(version) ⇒ OS
The OpenBSD OS
103 104 105 |
# File 'lib/ronin/db/os.rb', line 103 def self.openbsd(version) find_or_create_by(name: 'OpenBSD', flavor: :bsd, version: version) end |
.windows(version) ⇒ OS
The Windows OS
139 140 141 |
# File 'lib/ronin/db/os.rb', line 139 def self.windows(version) find_or_create_by(name: 'Windows', version: version) end |
Instance Method Details
#recent_ip_address ⇒ IPAddress
The IP Address that was most recently guessed to be using the Operating System.
153 154 155 156 157 158 159 |
# File 'lib/ronin/db/os.rb', line 153 def recent_ip_address relation = self.os_guesses.order('created_at DESC').first if relation return relation.ip_address end end |
#to_s ⇒ String
Converts the Operating System to a String.
174 175 176 |
# File 'lib/ronin/db/os.rb', line 174 def to_s "#{self.name} #{self.version}" end |