Class: Jekyll::Secinfo::Cve

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-secinfo/cve.rb

Class Method Summary collapse

Class Method Details



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jekyll-secinfo/cve.rb', line 12

def self.to_link(text, site, page)
  #Logger.log(context)
  config = Jekyll::Secinfo::Config.get(site, page)
  m = text.match(/^(CVE-|cve-)?(\d{4}-\d{4,})/) # See https://cve.mitre.org/cve/identifiers/syntaxchange.html
  if m
    if config["cve"]["url"] =~ /\%s/
      url=config["cve"]["url"] % m[2]
    else
      url="#{config["cve"]["url"]}#{m[2]}"
    end
    return "<a href='#{url}' class='cve secinfo'>CVE-#{m[2]}</a>"
  else
    return nil
  end
end