Class: Ronin::DB::Advisory

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Model, Model::Importable
Defined in:
lib/ronin/db/advisory.rb

Overview

Represents a vulnerability Advisory, with a Publisher, Number and URL.

Defined Under Namespace

Modules: ID

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::Importable

included

Methods included from Model

included

Instance Attribute Details

#host_namesArray<HostName>

The host names that are vulnerable to this advisory.

Returns:

Since:

  • 0.2.0



108
# File 'lib/ronin/db/advisory.rb', line 108

has_many :host_names, through: :vulnerabilities

#idString

Primary key of the advisory.

Returns:

  • (String)


43
# File 'lib/ronin/db/advisory.rb', line 43

attribute :id, :string

#identifierString

The advisory identifier

Returns:

  • (String)


67
# File 'lib/ronin/db/advisory.rb', line 67

attribute :identifier, :string

#ip_addressesArray<IPAddress>

The IP Addresses that are vulnerable to this advisory.

Returns:

Since:

  • 0.2.0



92
# File 'lib/ronin/db/advisory.rb', line 92

has_many :ip_addresses, through: :vulnerabilities

#mac_addressesArray<MACAddress>

The MAC Addresses that are vulnerable to this advisory.

Returns:

Since:

  • 0.2.0



84
# File 'lib/ronin/db/advisory.rb', line 84

has_many :mac_addresses, through: :vulnerabilities

#notesArray<Note>

The associated notes.

Returns:

Since:

  • 0.2.0



125
# File 'lib/ronin/db/advisory.rb', line 125

has_many :notes, dependent: :destroy

#open_portsArray<OpenPort>

The open ports that are vulnerable to this advisory.

Returns:

Since:

  • 0.2.0



100
# File 'lib/ronin/db/advisory.rb', line 100

has_many :open_ports, through: :vulnerabilities

#prefixString

The ID prefix (ex: CVE or GHSA).

Returns:

  • (String)


49
# File 'lib/ronin/db/advisory.rb', line 49

attribute :prefix, :string

#urlsArray<URL>

The URLs that are vulnerable to this advisory.

Returns:

Since:

  • 0.2.0



116
117
# File 'lib/ronin/db/advisory.rb', line 116

has_many :urls, through: :vulnerabilities,
class_name: 'URL'

#vulnerabilitiesArray<Vulnerability>

The vulnerabilities which reference the advisory.

Returns:

Since:

  • 0.2.0



76
# File 'lib/ronin/db/advisory.rb', line 76

has_many :vulnerabilities, dependent: :destroy

#yearInteger

The year the advisory was published in.

Returns:

  • (Integer)


56
# File 'lib/ronin/db/advisory.rb', line 56

attribute :year, :integer

Class Method Details

.import(id) ⇒ Advisory

Parses an Advisory ID String.

Parameters:

  • id (String)

    The ID String for the advisory.

Returns:



192
193
194
# File 'lib/ronin/db/advisory.rb', line 192

def self.import(id)
  create(**ID.parse(id))
end

.lookup(id) ⇒ Advisory?

Looks up the advisory.

Parameters:

  • id (String)

Returns:



177
178
179
# File 'lib/ronin/db/advisory.rb', line 177

def self.lookup(id)
  find_by(id: id)
end

Instance Method Details

#to_sString

Converts the advisory to a String.

Returns:

  • (String)

    The advisory ID string.



220
221
222
# File 'lib/ronin/db/advisory.rb', line 220

def to_s
  self.id
end

#urlString?

Generates a URL for the advisory.

Returns:

  • (String, nil)

    The URL for the advisory.



204
205
206
207
208
209
210
# File 'lib/ronin/db/advisory.rb', line 204

def url
  case prefix
  when 'CVE'  then "https://nvd.nist.gov/vuln/detail/#{id}"
  when 'RHSA' then "https://access.redhat.com/errata/#{id}"
  when 'GHSA' then "https://github.com/advisories/#{id}"
  end
end