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.
-
.with_flavor(flavor) ⇒ Array<OS>
Queries all OSes with the matching flavor.
-
.with_version(version) ⇒ Array<OS>
Queries all OSes with the matching version.
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
125 126 127 |
# File 'lib/ronin/db/os.rb', line 125 def self.freebsd(version) find_or_create_by(name: 'FreeBSD', flavor: :bsd, version: version) end |
.linux(version) ⇒ OS
The Linux OS
113 114 115 |
# File 'lib/ronin/db/os.rb', line 113 def self.linux(version) find_or_create_by(name: 'Linux', flavor: :linux, version: version) end |
.macos(version) ⇒ OS
The macOS OS.
161 162 163 |
# File 'lib/ronin/db/os.rb', line 161 def self.macos(version) find_or_create_by(name: 'macOS', flavor: :bsd, version: version) end |
.netbsd(version) ⇒ OS
The NetBSD OS
149 150 151 |
# File 'lib/ronin/db/os.rb', line 149 def self.netbsd(version) find_or_create_by(name: 'NetBSD', flavor: :bsd, version: version) end |
.openbsd(version) ⇒ OS
The OpenBSD OS
137 138 139 |
# File 'lib/ronin/db/os.rb', line 137 def self.openbsd(version) find_or_create_by(name: 'OpenBSD', flavor: :bsd, version: version) end |
.windows(version) ⇒ OS
The Windows OS
173 174 175 |
# File 'lib/ronin/db/os.rb', line 173 def self.windows(version) find_or_create_by(name: 'Windows', version: version) end |
.with_flavor(flavor) ⇒ Array<OS>
Queries all OSes with the matching flavor.
84 85 86 |
# File 'lib/ronin/db/os.rb', line 84 def self.with_flavor(flavor) where(flavor: flavor) end |
.with_version(version) ⇒ Array<OS>
Queries all OSes with the matching version.
101 102 103 |
# File 'lib/ronin/db/os.rb', line 101 def self.with_version(version) where(version: version) end |
Instance Method Details
#recent_ip_address ⇒ IPAddress
The IP Address that was most recently guessed to be using the Operating System.
187 188 189 190 191 192 193 |
# File 'lib/ronin/db/os.rb', line 187 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.
208 209 210 |
# File 'lib/ronin/db/os.rb', line 208 def to_s "#{self.name} #{self.version}" end |