lib/brakeman/report/report_json.rb in brakeman-4.3.1 vs lib/brakeman/report/report_json.rb in brakeman-4.4.0

- old
+ new

@@ -36,10 +36,31 @@ end def convert_to_hashes warnings warnings.map do |w| hash = w.to_hash + hash[:render_path] = convert_render_path hash[:render_path] hash[:file] = warning_file w + hash end.sort_by { |w| "#{w[:fingerprint]}#{w[:line]}" } + end + + def convert_render_path render_path + return unless render_path and not @tracker.options[:absolute_paths] + + render_path.map do |r| + r = r.dup + + if r[:file] + r[:file] = relative_path(r[:file]) + end + + if r[:rendered] and r[:rendered][:file] + r[:rendered] = r[:rendered].dup + r[:rendered][:file] = relative_path(r[:rendered][:file]) + end + + r + end end end