Sha256: 832950a3eb126e0587e29c4d5223b144650fbc80c2e1d2500ae76707d896299e

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

#
# ronin-exploits - A Ruby library for ronin-rb that provides exploitation and
# payload crafting functionality.
#
# Copyright (c) 2007-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# ronin-exploits is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-exploits is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-exploits.  If not, see <https://www.gnu.org/licenses/>.
#

module Ronin
  module Exploits
    #
    # Represents a security advisory.
    #
    # @api semipublic
    #
    # @since 1.0.0
    #
    class Advisory

      # The advisory ID.
      #
      # @return [String]
      attr_reader :id

      # The advisory URL.
      #
      # @return [String]
      attr_reader :url

      #
      # Initializes the advisory.
      #
      # @param [String] id
      #   The advisory ID.
      #
      # @param [String] url
      #   The advisory URL.
      #
      def initialize(id,url=self.class.url_for(id))
        @id  = id
        @url = url
      end

      #
      # Generates a default URL for the given advisory ID.
      #
      # @param [String] id
      #   The advisory ID.
      #
      # @return [String, nil]
      #   The URL for the advisory.
      #
      def self.url_for(id)
        case id
        when /\ACVE-/  then "https://nvd.nist.gov/vuln/detail/#{id}"
        when /\AGHSA-/ then "https://github.com/advisories/#{id}"
        end
      end

      #
      # Converts the advisory to a String.
      #
      # @return [String]
      #   The advisory ID.
      #
      def to_s
        @id.to_s
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-exploits-1.0.0.beta1 lib/ronin/exploits/advisory.rb