Class: Jekyll::Secinfo::Cwe

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-secinfo/cwe.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/cwe.rb', line 12

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