Class: Faker::VulnerabilityIdentifier

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/vulnerability_identifier.rb

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.cve(year: ::Date.today.year) ⇒ String

Produces a Common Vulnerabilities and Exposures (CVE) identifier.

Examples:

Faker::VulnerabilityIdentifier.cve #=> "CVE-2021-1337"
Faker::VulnerabilityIdentifier.cve(year: 1999) #=> "CVE-1999-0523"

Parameters:

  • year (Integer) (defaults to: ::Date.today.year)

    The year-part of the CVE identifier (defaults to the current year)

Returns:

  • (String)

Available since:

  • next



17
18
19
20
# File 'lib/faker/default/vulnerability_identifier.rb', line 17

def cve(year: ::Date.today.year)
  index = rand_in_range(1, 99_999).to_s.rjust(4, '0')
  "CVE-#{year}-#{index}"
end