Skip to content

Commit 8aa8b6d

Browse files
committed
Land rapid7#9532, Fix a bug in the MD docs references
Land rapid7#9532
2 parents cb1b595 + c612dbf commit 8aa8b6d

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

lib/msf/util/document_generator/normalizer.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def normalize_pull_requests(pull_requests)
144144
formatted_pr = []
145145

146146
pull_requests.each_pair do |number, pr|
147-
formatted_pr << "* <a href=\"https://github.com/rapid7/metasploit-framework/pull/#{number}\">##{number}</a> - #{pr[:title]}"
147+
formatted_pr << "* [##{number} #{pr[:title]}](https://github.com/rapid7/metasploit-framework/pull/#{number})"
148148
end
149149

150150
formatted_pr * "\n"
@@ -204,7 +204,23 @@ def normalize_targets(targets)
204204
# @param refs [Array] Module references.
205205
# @return [String]
206206
def normalize_references(refs)
207-
refs.collect { |r| "* <a href=\"#{r}\">#{r}</a>" } * "\n"
207+
normalized = ''
208+
refs.each do |ref|
209+
case ref.ctx_id
210+
when 'AKA'
211+
normalized << "* *Also known as:* #{ref.ctx_val}"
212+
when 'MSB'
213+
normalized << "* [#{ref.ctx_val}](#{ref.site})"
214+
when 'URL'
215+
normalized << "* [#{ref.site}](#{ref.site})"
216+
when 'US-CERT-VU'
217+
normalized << "* [VU##{ref.ctx_val}](#{ref.site})"
218+
else
219+
normalized << "* [#{ref.ctx_id}-#{ref.ctx_val}](#{ref.site})"
220+
end
221+
normalized << "\n"
222+
end
223+
normalized
208224
end
209225

210226

spec/lib/msf/util/document_generator/normalizer_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'rex'
2+
require 'msf/core/module/reference'
23
require 'msf/util/document_generator'
34
require 'msf/util/document_generator/pull_request_finder'
45

@@ -10,7 +11,7 @@
1011
let(:mod_shortname) { 'ms08_067_netapi' }
1112
let(:mod_name) { 'MS08-067' }
1213
let(:mod_pull_requests) { good_pull_requests }
13-
let(:mod_refs) { ['URL', 'http://example.com'] }
14+
let(:mod_refs) { [Msf::Module::SiteReference.new('URL', 'http://example.com')] }
1415
let(:mod_platforms) { 'win' }
1516
let(:mod_options) { { 'RHOST' => rhost_option } }
1617
let(:mod_normal_rank) { 300 }
@@ -111,7 +112,7 @@
111112
describe 'normalize_pull_requests' do
112113
context 'when a hash of pull requests are given' do
113114
it 'returns HTML links' do
114-
expect(subject.send(:normalize_pull_requests, good_pull_requests)).to include('* <a href=')
115+
expect(subject.send(:normalize_pull_requests, good_pull_requests)).to include('](https://github.com/')
115116
end
116117
end
117118

@@ -159,7 +160,7 @@
159160
describe 'normalize_references' do
160161
context 'when an array of references is given' do
161162
it 'returns the reference list in HTML' do
162-
expect(subject.send(:normalize_references, msf_mod.references)).to include('* <a href=')
163+
expect(subject.send(:normalize_references, msf_mod.references)).to include('* [http://')
163164
end
164165
end
165166
end

0 commit comments

Comments
 (0)