Skip to content

Commit 990ed30

Browse files
committed
Fix reference validation: allow optional third element for specific reference types (e.g., GHSA)
1 parent 2cb96bd commit 990ed30

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/msf/core/module/module_info.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ module Msf::Module::ModuleInfo
66
# The list of options that don't support merging in an information hash.
77
UpdateableOptions = [ "Name", "Description", "Alias", "PayloadCompat" , "Stance"]
88

9+
# Reference types that can have 2 or 3 elements (e.g., GHSA with optional repo)
10+
ReferencesWithOptionalThirdElement = ['GHSA'].freeze
11+
912
#
1013
# Instance Methods
1114
#
@@ -68,7 +71,18 @@ def info_fixups
6871
refs = module_info['References']
6972
if(refs and not refs.empty?)
7073
refs.each_index do |i|
71-
if !(refs[i].respond_to?('[]') and (refs[i].length == 2 || refs[i].length == 3))
74+
if !refs[i].respond_to?('[]') || refs[i].length < 1
75+
refs[i] = nil
76+
next
77+
end
78+
79+
# Some reference types can have 2 or 3 elements (e.g., GHSA with optional repo)
80+
# Other references should have 2 elements
81+
ref_type = refs[i][0]
82+
can_have_third_element = ReferencesWithOptionalThirdElement.include?(ref_type)
83+
valid_length = can_have_third_element ? (refs[i].length == 2 || refs[i].length == 3) : (refs[i].length == 2)
84+
85+
if !valid_length
7286
refs[i] = nil
7387
end
7488
end

0 commit comments

Comments
 (0)