File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -115,16 +115,30 @@ def check_shebang
115
115
end
116
116
end
117
117
118
+ # Updated this check to see if Nokogiri::XML.parse is being called
119
+ # specifically. The main reason for this concern is that some versions
120
+ # of libxml2 are still vulnerable to XXE attacks. REXML is safer (and
121
+ # slower) since it's pure ruby. Unfortunately, there is no pure Ruby
122
+ # HTML parser (except Hpricot which is abandonware) -- easy checks
123
+ # can avoid Nokogiri (most modules use regex anyway), but more complex
124
+ # checks tends to require Nokogiri for HTML element and value parsing.
118
125
def check_nokogiri
119
- msg = "Requiring Nokogiri in modules can be risky, use REXML instead."
126
+ msg = "Using Nokogiri in modules can be risky, use REXML instead."
120
127
has_nokogiri = false
128
+ has_nokogiri_xml_parser = false
121
129
@source . each_line do |line |
122
- if line =~ /^\s *(require|load)\s +['"]nokogiri['"]/
123
- has_nokogiri = true
124
- break
130
+ if has_nokogiri
131
+ if line =~ /Nokogiri::XML\. parse/ or line =~ /Nokogiri::XML::Reader/
132
+ has_nokogiri_xml_parser = true
133
+ break
134
+ end
135
+ else
136
+ if line =~ /^\s *(require|load)\s +['"]nokogiri['"]/
137
+ has_nokogiri = true
138
+ end
125
139
end
126
140
end
127
- error ( msg ) if has_nokogiri
141
+ error ( msg ) if has_nokogiri_xml_parser
128
142
end
129
143
130
144
def check_ref_identifiers
You can’t perform that action at this time.
0 commit comments