summaryrefslogtreecommitdiffstats
path: root/doc/asciidoctor-macros/cveidlink-inline-macro/extension.rb
blob: 2dec88da3c73be262004014689e48ce24ea8974e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# SPDX-License-Identifier: MIT
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'

include ::Asciidoctor

# An inline macro that generates a link to a CVE Record identified by its CVE
# Number.
#
# Usage
#
#   cveidlink:<cve-number>[]
#
class CVEIdLinkInlineMacro < Extensions::InlineMacroProcessor
  include WsUtils
  use_dsl

  named :cveidlink

  def process(parent, cvenum, _attrs)
    cvename = "CVE-#{cvenum}"
    target = %(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-#{cvenum})
    create_doc_links(parent, target, cvename)
  end
end