Class: Ronin::DB::Advisory
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ronin::DB::Advisory
- 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
-
#id ⇒ String
Primary key of the advisory.
-
#identifier ⇒ String
The advisory identifier.
-
#prefix ⇒ String
The ID prefix (ex:
CVE
orGHSA
). -
#year ⇒ Integer
The year the advisory was published in.
Class Method Summary collapse
-
.import(id) ⇒ Advisory
Parses an Advisory ID String.
-
.lookup(id) ⇒ Advisory?
Looks up the advisory.
Instance Method Summary collapse
-
#to_s ⇒ String
Converts the advisory to a String.
-
#url ⇒ String?
Generates a URL for the advisory.
Methods included from Model::Importable
Methods included from Model
Instance Attribute Details
#id ⇒ String
Primary key of the advisory.
43 |
# File 'lib/ronin/db/advisory.rb', line 43 attribute :id, :string |
#identifier ⇒ String
The advisory identifier
67 |
# File 'lib/ronin/db/advisory.rb', line 67 attribute :identifier, :string |
#prefix ⇒ String
The ID prefix (ex: CVE
or GHSA
).
49 |
# File 'lib/ronin/db/advisory.rb', line 49 attribute :prefix, :string |
#year ⇒ Integer
The year the advisory was published in.
56 |
# File 'lib/ronin/db/advisory.rb', line 56 attribute :year, :integer |
Class Method Details
.import(id) ⇒ Advisory
Parses an Advisory ID String.
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.
120 121 122 |
# File 'lib/ronin/db/advisory.rb', line 120 def self.lookup(id) find_by(id: id) end |
Instance Method Details
#to_s ⇒ String
Converts the advisory to a String.
163 164 165 |
# File 'lib/ronin/db/advisory.rb', line 163 def to_s self.id end |
#url ⇒ String?
Generates a 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 |