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

#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

#prefixString

The ID prefix (ex: CVE or GHSA).

Returns:

  • (String)


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

attribute :prefix, :string

#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:



135
136
137
# File 'lib/ronin/db/advisory.rb', line 135

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

.lookup(id) ⇒ Advisory?

Looks up the advisory.

Parameters:

  • id (String)

Returns:



120
121
122
# File 'lib/ronin/db/advisory.rb', line 120

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.



163
164
165
# File 'lib/ronin/db/advisory.rb', line 163

def to_s
  self.id
end

#urlString?

Generates a URL for the advisory.

Returns:

  • (String, nil)

    The URL for the advisory.



147
148
149
150
151
152
153
# File 'lib/ronin/db/advisory.rb', line 147

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